mapbased

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DiscoveryIterations = 30
)

Variables

View Source
var ErrSlotNotFound = errors.New("storage slot not found")

ErrSlotNotFound represents the storage slot not found error

Functions

func VerifyProof

func VerifyProof(holder common.Address, storageRoot common.Hash,
	proof ethstorageproof.StorageResult, mapIndexSlot int, targetBalance, targetBlock *big.Int) error

VerifyProof verifies a map based storage proof. The targetBalance parameter is the full balance value, without decimals.

Types

type Mapbased

type Mapbased struct {
	// contains filtered or unexported fields
}

Mapbased tokens are those where the balance is stored on a map `address => uint256`. Most of ERC20 tokens follows this approach.

func New

func New(ctx context.Context, rpcCli *rpc.Client, tokenAddress common.Address) (*Mapbased, error)

New creates a new Mapbased to get and verify Mapbased token proofs

func (*Mapbased) DiscoverSlot

func (m *Mapbased) DiscoverSlot(ctx context.Context, holder common.Address) (int, *big.Rat, error)

DiscoverSlot tries to find the EVM storage index slot. A token holder address must be provided in order to have a balance to search and compare. Returns ErrSlotNotFound if the slot cannot be found. If found, returns also the amount stored.

func (*Mapbased) GetProof

func (m *Mapbased) GetProof(ctx context.Context, holder common.Address,
	block *big.Int, islot int) (*ethstorageproof.StorageProof, error)

GetProof returns the storage merkle proofs for the acount holder.

func (*Mapbased) VerifyProof

func (m *Mapbased) VerifyProof(holder common.Address, storageRoot common.Hash,
	proofs []ethstorageproof.StorageResult, mapIndexSlot int, targetBalance,
	targetBlock *big.Int) error

VerifyProof verifies a map based storage proof.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL