erc20

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package erc20 provides base functionality for interacting with ERC20 tokens using the IERC20 standard.

Package erc20 provides base functionality for interacting with ERC20 tokens using the IERC20 standard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseError

func ParseError(rawErr any) error

ParseError parses raw contract errors into human-readable error messages for ERC20 operations.

Types

type BaseERC20Signature

type BaseERC20Signature string

BaseERC20Signature represents function signatures for basic ERC20 token operations

const (
	// Name represents the name function signature
	Name BaseERC20Signature = "name()"
	// Symbol represents the symbol function signature
	Symbol BaseERC20Signature = "symbol()"
	// Decimals represents the decimals function signature
	Decimals BaseERC20Signature = "decimals()"
	// BalanceOf represents the balanceOf function signature
	BalanceOf BaseERC20Signature = "balanceOf(address)"
	// TotalSupply represents the totalSupply function signature
	TotalSupply BaseERC20Signature = "totalSupply()"
	// TokenURI represents the tokenURI function signature
	TokenURI BaseERC20Signature = "tokenURI(uint256)" // #nosec G101
	// Approve represents the approve function signature
	Approve BaseERC20Signature = "approve(address,uint256)"
	// TransferFrom represents the transferFrom function signature
	TransferFrom BaseERC20Signature = "transferFrom(address,address,uint256)"
	// SafeTransferFrom represents the safeTransferFrom function signature
	SafeTransferFrom BaseERC20Signature = "safeTransferFrom(address,address,uint256)"
)

func (BaseERC20Signature) GetHex

func (s BaseERC20Signature) GetHex() string

GetHex returns the hex representation of the function signature

func (BaseERC20Signature) GetSelector

func (s BaseERC20Signature) GetSelector() []byte

GetSelector returns the hex representation of the function signature

func (BaseERC20Signature) String

func (s BaseERC20Signature) String() string

type Interactions

type Interactions struct {
	*base.Interactions
	// contains filtered or unexported fields
}

Interactions provides methods for interacting with ERC20 token contracts.

func NewIERC20Interactions

func NewIERC20Interactions(
	baseInteractions *base.Interactions,
	address common.Address,
	signatures []BaseERC20Signature,
	transactOps ...*bind.TransactOpts,
) (*Interactions, error)

NewIERC20Interactions creates a new instance of IERC20AInteractions from a base interaction interface and an NFT contract address.

func (*Interactions) Allowance

func (d *Interactions) Allowance(owner, spender common.Address) (*big.Int, error)

Allowance returns the amount of tokens that spender is allowed to spend on behalf of owner

func (*Interactions) Approve

func (d *Interactions) Approve(to common.Address, allowance *big.Int) (*types.Transaction, error)

Approve approves an address to transfer a specific token.

func (*Interactions) BalanceOf

func (d *Interactions) BalanceOf(owner common.Address) (*big.Int, error)

BalanceOf retrieves the NFT balance for a given owner.

func (Interactions) CallOpts

func (s Interactions) CallOpts() *bind.CallOpts

func (*Interactions) Decimals

func (d *Interactions) Decimals() (uint8, error)

Decimals returns the number of decimals used to get its user representation.

func (*Interactions) GetAddress

func (d *Interactions) GetAddress() common.Address

GetAddress returns the ERC20 contract address.

func (*Interactions) GetBalance

func (d *Interactions) GetBalance() (*big.Int, error)

GetBalance retrieves the balance of NFTs for the associated address.

func (*Interactions) GetSession

func (d *Interactions) GetSession() transaction.Session

GetSession returns the current session used for NFT interactions.

func (Interactions) Instance

func (s Interactions) Instance() *bind.BoundContract

func (*Interactions) Name

func (d *Interactions) Name() (string, error)

Name returns the name of the NFT.

func (*Interactions) Symbol

func (d *Interactions) Symbol() (string, error)

Symbol returns the symbol of the NFT.

func (*Interactions) TokenMetaInfos

func (d *Interactions) TokenMetaInfos() (*models.TokenMeta, error)

TokenMetaInfos retrieves metadata about the specified token such as name, symbol, and URI.

func (*Interactions) TotalSupply

func (d *Interactions) TotalSupply() (*big.Int, error)

TotalSupply returns the total number of NFTs minted.

func (*Interactions) TransferTo

func (d *Interactions) TransferTo(to common.Address, amount *big.Int) (*types.Transaction, error)

TransferTo transfers a specific token to another address after verifying ownership.

Directories

Path Synopsis
Package burnable provides functions to interact with ERC20 burnable properties.
Package burnable provides functions to interact with ERC20 burnable properties.

Jump to

Keyboard shortcuts

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