ethereum

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: MIT Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultAddress = "0x3F43E75Aaba2c2fD6E227C10C6E7DC125A93DE3c"
)

Variables

This section is empty.

Functions

func Sign

func Sign(private *ecdsa.PrivateKey, hash []byte) ([]byte, error)

func SignTx

func SignTx(tx *web3.Transaction, private *ecdsa.PrivateKey, chainID uint64) (*web3.Transaction, error)

Types

type AddressEncoder

type AddressEncoder struct {
}

func NewAddressEncoder

func NewAddressEncoder() *AddressEncoder

func (*AddressEncoder) AddressToHex

func (a *AddressEncoder) AddressToHex(addr address.Address) string

func (*AddressEncoder) HexToAddress

func (a *AddressEncoder) HexToAddress(addr string) address.Address

type Client

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

func NewClient

func NewClient(provider provider.CommonProvider) (*Client, error)

func (*Client) BalanceOf

func (c *Client) BalanceOf(address string, optionAsset *client.OptionAsset) (amount *big.Int, err error)

func (*Client) EstimateGas

func (c *Client) EstimateGas(tx tx.Tx) (feeRes *fee.OptionFee, err error)

func (*Client) GetAccount

func (c *Client) GetAccount() string

func (*Client) GetChainID

func (c *Client) GetChainID() (string, error)

func (*Client) QueryContract

func (c *Client) QueryContract(req client.CallContractParam) (res *client.CallContractRes, err error)

func (*Client) QueryTx

func (c *Client) QueryTx(txHash string, isWait bool) (txData *tx.TxData, err error)

func (*Client) SendSignedTx

func (c *Client) SendSignedTx(signedTx tx.Tx) (txHash string, err error)

func (*Client) SendTx

func (c *Client) SendTx(tx tx.Tx, feeOption *fee.OptionFee) (txHash string, err error)

func (*Client) SetPrivate

func (c *Client) SetPrivate(hexPrivate string) (err error)

func (*Client) SetProvider

func (c *Client) SetProvider(provider provider.CommonProvider) (err error)

func (*Client) Transfer

func (c *Client) Transfer(to string, amount *big.Int, optionAsset *client.OptionAsset, optionFee *fee.OptionFee) (txHash string, err error)

type Contract

type Contract struct {
	Addr     web3.Address
	From     *web3.Address
	Abi      *abi.ABI
	Provider *jsonrpc.Client
}

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

func (c *Contract) Call(method string, block web3.BlockNumber, args ...interface{}) (string, 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) Event

func (c *Contract) Event(name string) (*Event, bool)

Event returns a specific event

func (*Contract) GetAddr

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

Addr returns the address of the contract

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 ContractTxBuilder

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

func NewContractTxBuilder

func NewContractTxBuilder(provider provider.CommonProvider) (*ContractTxBuilder, error)

func (*ContractTxBuilder) BuildDeployTx

func (b *ContractTxBuilder) BuildDeployTx(req txbuilder.BuildDeployTxReq) (tx.Tx, error)

构建部署合约的交易

func (*ContractTxBuilder) BuildInvokeTx

func (b *ContractTxBuilder) BuildInvokeTx(req txbuilder.BuildInvokeTxReq) (tx.Tx, error)

构建调用合约的交易

type Event

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

Event is a solidity event

func (*Event) Encode

func (e *Event) Encode() web3.Hash

Encode encodes an event

func (*Event) ParseLog

func (e *Event) ParseLog(log *web3.Log) (map[string]interface{}, error)

ParseLog parses a log

type TxBuilder

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

func NewTxBuilder

func NewTxBuilder(provider provider.CommonProvider) (*TxBuilder, error)

func (*TxBuilder) BuildTx

func (t *TxBuilder) BuildTx(req txbuilder.BuildTxParam) (tx tx.Tx, err error)

func (*TxBuilder) DecodeTx

func (t *TxBuilder) DecodeTx(encodedTx string) (tx tx.Tx, err error)

type Txn

type Txn struct {
	Private    *ecdsa.PrivateKey `json:"private"`
	From       web3.Address      `json:"from"`
	Nonce      uint64            `json:"nonce"`
	Addr       *web3.Address     `json:"to"`
	Value      *big.Int          `json:"value"`
	GasPrice   uint64            `json:"gasPrice"`
	GasLimit   uint64            `json:"gas"`
	Data       []byte            `json:"input"`
	Provider   *jsonrpc.Client   `json:"provider"`
	Method     *abi.Method       `json:"method"`
	Args       []interface{}     `json:"args"`
	Bin        []byte            `json:"bin"`
	SignedHash []byte            `json:"signedHash"`
	SignedTx   []byte            `json:"signedTx"`
	Hash       web3.Hash         `json:"hash"`
	Receipt    *web3.Receipt     `json:"receipt"`
}

func (*Txn) AddArgs

func (t *Txn) AddArgs(args ...interface{}) *Txn

AddArgs is used to set the arguments of the transaction

func (*Txn) EncodeTx

func (t *Txn) EncodeTx() (txEncoded string, err error)

func (*Txn) EstimateGas

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

EstimateGas estimates the gas for the call

func (*Txn) GetFee

func (t *Txn) GetFee() *fee.OptionFee

func (*Txn) GetFrom

func (t *Txn) GetFrom() string

func (*Txn) GetHash

func (t *Txn) GetHash() string

func (*Txn) GetNonce

func (t *Txn) GetNonce() uint64

func (*Txn) GetPayload

func (t *Txn) GetPayload() []byte

func (*Txn) GetReceipt

func (t *Txn) GetReceipt() *web3.Receipt

Receipt returns the receipt of the transaction after wait

func (*Txn) GetTo

func (t *Txn) GetTo() string

func (*Txn) GetTxHash

func (t *Txn) GetTxHash(chainID string) (string, error)

func (*Txn) GetValue

func (t *Txn) GetValue() *big.Int

func (*Txn) InjectSignature

func (t *Txn) InjectSignature(hexSignature string, chainID string) (err error)

func (*Txn) SetFee

func (t *Txn) SetFee(fee *fee.OptionFee)

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

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

SetValue sets the value for the txn

func (*Txn) SignHash

func (t *Txn) SignHash(privateHex string, chainID string, hexHash string) (hexSignature string, err error)

func (*Txn) SignTx

func (t *Txn) SignTx(privateHex string, chainID string) error

func (*Txn) Validate

func (t *Txn) Validate() error

Validate validates the arguments of the transaction

func (*Txn) Wait

func (t *Txn) Wait() error

Wait waits till the transaction is mined

Jump to

Keyboard shortcuts

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