Documentation ¶
Index ¶
- type ERC20Token
- func (w *ERC20Token) Balance(ctx context.Context, address common.Address) (*big.Rat, error)
- func (w *ERC20Token) GetProof(ctx context.Context, keys [][]byte, block *big.Int) (*ethstorageproof.StorageProof, error)
- func (w *ERC20Token) GetTokenData(ctx context.Context) (*TokenData, error)
- func (w *ERC20Token) TokenDecimals(ctx context.Context) (uint8, error)
- func (w *ERC20Token) TokenName(ctx context.Context) (string, error)
- func (w *ERC20Token) TokenSymbol(ctx context.Context) (string, error)
- func (w *ERC20Token) TokenTotalSupply(ctx context.Context) (*big.Int, error)
- type TokenData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ERC20Token ¶
type ERC20Token struct { RPCCli *rpc.Client EthCli *ethclient.Client TokenAddr common.Address // contains filtered or unexported fields }
ERC20Token holds a reference to a go-ethereum client, to an ERC20 like contract and to an ENS. It is expected for the ERC20 contract to implement the standard optional ERC20 functions: {name, symbol, decimals, totalSupply}
func New ¶
func New(ctx context.Context, rpcCli *rpc.Client, contractAddress common.Address) (*ERC20Token, error)
New creates a new ERC20Token to access ERC20 token data and get storage proofs
func (*ERC20Token) GetProof ¶
func (w *ERC20Token) GetProof(ctx context.Context, keys [][]byte, block *big.Int) (*ethstorageproof.StorageProof, error)
GetProof calls the eth_getProof web3 method. If block is nil, the proof at the latest block will be retreived.
func (*ERC20Token) GetTokenData ¶
func (w *ERC20Token) GetTokenData(ctx context.Context) (*TokenData, error)
GetTokenData gets useful data abount the token
func (*ERC20Token) TokenDecimals ¶
func (w *ERC20Token) TokenDecimals(ctx context.Context) (uint8, error)
TokenDecimals wraps the decimals() function contract call
func (*ERC20Token) TokenName ¶
func (w *ERC20Token) TokenName(ctx context.Context) (string, error)
TokenName wraps the name() function contract call
func (*ERC20Token) TokenSymbol ¶
func (w *ERC20Token) TokenSymbol(ctx context.Context) (string, error)
TokenSymbol wraps the symbol() function contract call
func (*ERC20Token) TokenTotalSupply ¶
TokenTotalSupply wraps the totalSupply function contract call