erc20

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: 11 Imported by: 1

Documentation

Index

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) Balance

func (w *ERC20Token) Balance(ctx context.Context, address common.Address) (*big.Rat, error)

Balance returns the current address balance

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

func (w *ERC20Token) TokenTotalSupply(ctx context.Context) (*big.Int, error)

TokenTotalSupply wraps the totalSupply function contract call

type TokenData

type TokenData struct {
	Address     common.Address `json:"address"`
	Name        string         `json:"name"`
	Symbol      string         `json:"symbol"`
	Decimals    uint8          `json:"decimals"`
	TotalSupply *big.Int       `json:"totalSupply,omitempty"`
}

func (*TokenData) String

func (t *TokenData) String() string

Jump to

Keyboard shortcuts

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