contract

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MPL-2.0 Imports: 16 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeTopics

func MakeTopics(query ...[]interface{}) ([][]web3.Hash, error)

MakeTopics converts a filter query argument list into a filter topic set.

Types

type Contract

type Contract struct {
	Abi      *abi.ABI
	Provider *jsonrpc.Client
	// contains filtered or unexported fields
}

Contract is an Ethereum contract

func NewContract

func NewContract(addr web3.Address, abi *abi.ABI, provider *jsonrpc.Client) *Contract

NewContract creates a new contract instance

func (*Contract) Addr

func (c *Contract) Addr() web3.Address

Addr returns the address of the contract

func (*Contract) Call

func (c *Contract) Call(method string, block web3.BlockNumber, args ...interface{}) (map[string]interface{}, error)

Call calls a method in the contract

func (*Contract) EstimateGas

func (c *Contract) EstimateGas(method string, args ...interface{}) (uint64, error)

EstimateGas estimates the gas for a contract call

func (*Contract) FilterLogs

func (c *Contract) FilterLogs(opts *web3.FilterOpts, name string, query ...[]interface{}) ([]*web3.Log, error)

func (*Contract) FilterLogsWithTopic added in v0.1.2

func (c *Contract) FilterLogsWithTopic(topics [][]web3.Hash, startBlock uint64, endBlock ...uint64) ([]*web3.Log, error)

func (*Contract) SetFrom

func (c *Contract) SetFrom(addr web3.Address)

SetFrom sets the origin of the calls

func (*Contract) Txn

func (c *Contract) Txn(method string, args ...interface{}) *Txn

Txn creates a new transaction object

type SignedTx

type SignedTx struct {
	*web3.Transaction
}

func (*SignedTx) SendTransaction

func (self *SignedTx) SendTransaction(signer *Signer) *web3.Receipt

type Signer

type Signer struct {
	*wallet.Key

	*jsonrpc.Client
	Executor *executor.Executor
	Submit   bool
	Nonce    uint64 // only used when in simulate mode
	// contains filtered or unexported fields
}

func NewSigner

func NewSigner(hexPrivKey string, client *jsonrpc.Client, chainId uint64) *Signer

func (*Signer) ExecuteTxn

func (self *Signer) ExecuteTxn(tx *web3.Transaction) (*web3.ExecutionResult, *web3.Receipt)

func (*Signer) GetNonce

func (e *Signer) GetNonce(blockNumber web3.BlockNumber) (uint64, error)

func (*Signer) SendTransaction

func (self *Signer) SendTransaction(tx *web3.Transaction) *web3.Receipt

func (*Signer) SignTx

func (self *Signer) SignTx(tx *web3.Transaction) *web3.Transaction

func (*Signer) TransferEther

func (self *Signer) TransferEther(to web3.Address, value *big.Int, msg string) *web3.Transaction

func (*Signer) WaitTx

func (self *Signer) WaitTx(hs web3.Hash) *web3.Receipt

type Txn

type Txn struct {
	Data []byte
	// contains filtered or unexported fields
}

Txn is a transaction object

func DeployContract

func DeployContract(provider *jsonrpc.Client, from web3.Address, abiVal *abi.ABI, bin []byte, args ...interface{}) *Txn

DeployContract deploys a contract

func (*Txn) Do

func (t *Txn) Do() error

Do sends the transaction to the network

func (*Txn) DoAndWait

func (t *Txn) DoAndWait() (*web3.Receipt, error)

both Do and Wait functions

func (*Txn) EstimateGas

func (t *Txn) EstimateGas() (uint64, error)

EstimateGas estimates the gas for the call

func (*Txn) MustToTransaction

func (t *Txn) MustToTransaction() *web3.Transaction

func (*Txn) SetGasLimit

func (t *Txn) SetGasLimit(gasLimit uint64) *Txn

SetGasLimit sets the gas limit of the transaction

func (*Txn) SetGasPrice

func (t *Txn) SetGasPrice(gasPrice uint64) *Txn

SetGasPrice sets the gas price of the transaction

func (*Txn) SetNonce

func (t *Txn) SetNonce(nonce uint64) *Txn

func (*Txn) SetValue

func (t *Txn) SetValue(v *big.Int) *Txn

SetValue sets the value for the txn

func (*Txn) Sign

func (t *Txn) Sign(signer *Signer) *SignedTx

func (*Txn) ToTransaction

func (t *Txn) ToTransaction() (*web3.Transaction, error)

func (*Txn) Wait

func (t *Txn) Wait() (receipt *web3.Receipt, err error)

Wait waits till the transaction is mined

Directories

Path Synopsis
builtin
ens

Jump to

Keyboard shortcuts

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