Documentation ¶
Index ¶
- Constants
- func Encode(vals ...interface{}) []byte
- func NewAddressEncodeDecoder() address.EncodeDecoder
- type Address
- func (addr Address) Bytes() pack.Bytes
- func (addr Address) Marshal(buf []byte, rem int) ([]byte, int, error)
- func (addr Address) MarshalJSON() ([]byte, error)
- func (Address) SizeHint() int
- func (addr Address) String() string
- func (addr *Address) Unmarshal(buf []byte, rem int) ([]byte, int, error)
- func (addr *Address) UnmarshalJSON(data []byte) error
- type AddressDecoder
- type AddressEncodeDecoder
- type AddressEncoder
- type Client
- func (client *Client) AccountBalance(ctx context.Context, addr address.Address) (pack.U256, error)
- func (client *Client) AccountNonce(ctx context.Context, addr address.Address) (pack.U256, error)
- func (client *Client) CallContract(ctx context.Context, program address.Address, calldata contract.CallData) (pack.Bytes, error)
- func (client *Client) LatestBlock(ctx context.Context) (pack.U64, error)
- func (client *Client) SubmitTx(ctx context.Context, tx account.Tx) error
- func (client *Client) Tx(ctx context.Context, txID pack.Bytes) (account.Tx, pack.U64, error)
- type GasEstimator
- type Payload
- type Tx
- func (tx Tx) From() address.Address
- func (tx Tx) Hash() pack.Bytes
- func (tx Tx) Nonce() pack.U256
- func (tx Tx) Payload() contract.CallData
- func (tx Tx) Serialize() (pack.Bytes, error)
- func (tx Tx) Sighashes() ([]pack.Bytes32, error)
- func (tx *Tx) Sign(signatures []pack.Bytes65, pubkey pack.Bytes) error
- func (tx Tx) To() address.Address
- func (tx Tx) Value() pack.U256
- type TxBuilder
Constants ¶
const ( // DefaultClientRPCURL is the RPC URL used by default, to interact with the // ethereum node. DefaultClientRPCURL = "http://127.0.0.1:8545/" )
Variables ¶
This section is empty.
Functions ¶
func Encode ¶
func Encode(vals ...interface{}) []byte
Encode values into an Ethereum ABI compatible byte slice.
func NewAddressEncodeDecoder ¶ added in v0.2.1
func NewAddressEncodeDecoder() address.EncodeDecoder
NewAddressEncodeDecoder constructs a new AddressEncodeDecoder.
Types ¶
type Address ¶
An Address represents a public address on the Ethereum blockchain. It can be the address of an external account, or the address of a smart contract.
func NewAddressFromHex ¶
NewAddressFromHex returns an Address decoded from a hex string.
func (Address) MarshalJSON ¶
MarshalJSON implements JSON marshaling by encoding the address as a hex string.
func (Address) SizeHint ¶
SizeHint returns the number of bytes needed to represent this address in binary.
func (*Address) UnmarshalJSON ¶
UnmarshalJSON implements JSON unmarshaling by expected the data be a hex encoded string representation of an address.
type AddressDecoder ¶
type AddressDecoder interface {
DecodeAddress(address.Address) (address.RawAddress, error)
}
AddressDecoder implements the address.Decoder interface.
func NewAddressDecoder ¶
func NewAddressDecoder() AddressDecoder
NewAddressDecoder constructs a new AddressDecoder.
type AddressEncodeDecoder ¶ added in v0.2.1
type AddressEncodeDecoder struct { AddressEncoder AddressDecoder }
AddressEncodeDecoder implements the address.EncodeDecoder interface
type AddressEncoder ¶
type AddressEncoder interface {
EncodeAddress(address.RawAddress) (address.Address, error)
}
AddressEncoder implements the address.Encoder interface.
func NewAddressEncoder ¶
func NewAddressEncoder() AddressEncoder
NewAddressEncoder constructs a new AddressEncoder.
type Client ¶ added in v0.3.14
type Client struct {
// contains filtered or unexported fields
}
Client holds the underlying RPC client instance.
func NewClient ¶ added in v0.3.14
NewClient creates and returns a new JSON-RPC client to the Ethereum node
func (*Client) AccountBalance ¶ added in v0.3.14
AccountBalance returns the account balancee for a given address.
func (*Client) AccountNonce ¶ added in v0.3.14
AccountNonce returns the current nonce of the account. This is the nonce to be used while building a new transaction.
func (*Client) CallContract ¶ added in v0.3.14
func (client *Client) CallContract(ctx context.Context, program address.Address, calldata contract.CallData) (pack.Bytes, error)
CallContract implements the multichain Contract API.
func (*Client) LatestBlock ¶ added in v0.3.14
LatestBlock returns the block number at the current chain head.
type GasEstimator ¶ added in v0.3.14
type GasEstimator struct {
// contains filtered or unexported fields
}
A GasEstimator returns the gas price and the provide gas limit that is needed in order to confirm transactions with an estimated maximum delay of one block.
func NewGasEstimator ¶ added in v0.3.14
func NewGasEstimator(client *Client) *GasEstimator
NewGasEstimator returns a simple gas estimator that fetches the ideal gas price for a ethereum transaction to be included in a block with minimal delay.
func (*GasEstimator) EstimateGas ¶ added in v0.3.14
EstimateGas returns an estimate of the current gas price and returns the gas limit provided. These numbers change with congestion. These estimates are often a little bit off, and this should be considered when using them.
type Payload ¶
type Payload struct { ABI pack.Bytes `json:"abi"` Fn pack.Bytes `json:"fn"` Data pack.Bytes `json:"data"` }
A Payload is an Ethereum encoded function call. It includes an ABI, the function being called from the ABI, and the data being passed to the function.
type Tx ¶ added in v0.3.14
type Tx struct {
// contains filtered or unexported fields
}
Tx represents a ethereum transaction, encapsulating a payload/data and its signer.
func (Tx) From ¶ added in v0.3.14
From returns the address that is sending the transaction. Generally, this is also the address that must sign the transaction.
func (Tx) Hash ¶ added in v0.3.14
Hash returns the hash that uniquely identifies the transaction. Generally, hashes are irreversible hash functions that consume the content of the transaction.
func (Tx) Nonce ¶ added in v0.3.14
Nonce returns the nonce used to order the transaction with respect to all other transactions signed and submitted by the sender.
func (Tx) Payload ¶ added in v0.3.14
Payload returns arbitrary data that is associated with the transaction. Generally, this payload is used to send notes between external accounts, or invoke business logic on a contract.
func (Tx) Serialize ¶ added in v0.3.14
Serialize the transaction into bytes. Generally, this is the format in which the transaction will be submitted by the client.
func (Tx) Sighashes ¶ added in v0.3.14
Sighashes returns the digests that must be signed before the transaction can be submitted by the client.
func (*Tx) Sign ¶ added in v0.3.14
Sign the transaction by injecting signatures for the required sighashes. The serialized public key used to sign the sighashes must also be specified.
type TxBuilder ¶ added in v0.3.14
TxBuilder represents a transaction builder that builds transactions to be broadcasted to the ethereum network. The TxBuilder is configured using a chain id.
func NewTxBuilder ¶ added in v0.3.14
NewTxBuilder creates a new transaction builder.