contract

package
v0.0.0-...-8850773 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMethodNotFound    = fmt.Errorf("method not found")
	ErrEventTypeNotFound = fmt.Errorf("event type not found")
)

Functions

This section is empty.

Types

type ApprovalEvent

type ApprovalEvent struct {
	Address        address.Address
	Owner, Spender address.Address
	Value          *big.Int
}

type ConstantMethod

type ConstantMethod func(ctx context.Context, args ...any) ([]any, error)

type Contract

type Contract struct {
	Signer client.Signer
	// contains filtered or unexported fields
}

func New

func New(client *client.Client, addr address.Address) *Contract

func (*Contract) Call

func (c *Contract) Call(ctx context.Context, methodName string, args ...any) ([]any, error)

func (*Contract) Clone

func (c *Contract) Clone() *Contract

func (*Contract) GetConstantMethod

func (c *Contract) GetConstantMethod(methodName string) ConstantMethod

func (*Contract) GetEvents

func (c *Contract) GetEvents(tx *tx.Transaction) ([]Event, error)

func (*Contract) GetEventsByName

func (c *Contract) GetEventsByName(tx *tx.Transaction, eventName string) ([]Event, error)

func (*Contract) GetMethod

func (c *Contract) GetMethod(methodName string) Method

func (*Contract) GetResult

func (c *Contract) GetResult(tx *tx.Transaction, methodName string) ([]any, error)

func (*Contract) LoadABI

func (c *Contract) LoadABI(abiJson []byte) error

func (*Contract) Send

func (c *Contract) Send(ctx context.Context, methodName string, args ...any) (*tx.Transaction, error)

type Erc20

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

func NewErc20

func NewErc20(client *client.Client, addr address.Address) *Erc20

func (*Erc20) Allowance

func (c *Erc20) Allowance(ctx context.Context, owner, spender address.Address) (*big.Int, error)

func (*Erc20) Approve

func (c *Erc20) Approve(ctx context.Context, spender address.Address, amount *big.Int, option *SendOption) (*tx.Transaction, error)

func (*Erc20) BalanceOf

func (c *Erc20) BalanceOf(ctx context.Context, addr address.Address) (*big.Int, error)

func (*Erc20) Clone

func (c *Erc20) Clone() *Erc20

func (*Erc20) Decimals

func (c *Erc20) Decimals(ctx context.Context) (int, error)

func (*Erc20) GetApprovalEvents

func (c *Erc20) GetApprovalEvents(tx *tx.Transaction) ([]ApprovalEvent, error)

func (*Erc20) GetEvents

func (c *Erc20) GetEvents(tx *tx.Transaction) ([]Erc20Event, error)

func (*Erc20) GetTransferEvents

func (c *Erc20) GetTransferEvents(tx *tx.Transaction) ([]TransferEvent, error)

func (*Erc20) Name

func (c *Erc20) Name(ctx context.Context) (string, error)

func (*Erc20) SetSigner

func (c *Erc20) SetSigner(signer client.Signer)

func (*Erc20) Signer

func (c *Erc20) Signer() client.Signer

func (*Erc20) Symbol

func (c *Erc20) Symbol(ctx context.Context) (string, error)

func (*Erc20) TotalSupply

func (c *Erc20) TotalSupply(ctx context.Context) (*big.Int, error)

func (*Erc20) Transfer

func (c *Erc20) Transfer(ctx context.Context, to address.Address, amount *big.Int, option *SendOption) (*tx.Transaction, error)

func (*Erc20) TransferFrom

func (c *Erc20) TransferFrom(ctx context.Context, from, to address.Address, amount *big.Int, option *SendOption) (*tx.Transaction, error)

type Erc20Event

type Erc20Event struct {
	Name string
	TransferEvent
	ApprovalEvent
}

func (Erc20Event) String

func (e Erc20Event) String() string

type Event

type Event struct {
	Name        string
	Sig         []byte
	IsAnonymous bool
	Address     address.Address
	Inputs      []EventInput
}

type EventInput

type EventInput struct {
	Name  string
	Value any
}

type Method

type Method func(ctx context.Context, args ...any) (*tx.Transaction, error)

type SendOption

type SendOption struct {
	FeeLimit int64
}

type TransferEvent

type TransferEvent struct {
	Address  address.Address
	From, To address.Address
	Value    *big.Int
}

Jump to

Keyboard shortcuts

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