etrueclient

package
v2.1.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2022 License: GPL-3.0 Imports: 13 Imported by: 5

Documentation

Overview

Package common contains various helper functions.

Package etrueclient provides a client for the Ethereum RPC API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes2Hex added in v1.1.2

func Bytes2Hex(d []byte) string

Bytes2Hex returns the hexadecimal encoding of d.

func CopyBytes added in v1.1.2

func CopyBytes(b []byte) (copiedBytes []byte)

CopyBytes returns an exact copy of the provided bytes.

func FromHex added in v1.1.2

func FromHex(s string) []byte

FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".

func Hex2Bytes added in v1.1.2

func Hex2Bytes(str string) []byte

Hex2Bytes returns the bytes represented by the hexadecimal string str.

func Hex2BytesFixed added in v1.1.2

func Hex2BytesFixed(str string, flen int) []byte

Hex2BytesFixed returns bytes of a specified fixed length flen.

func LeftPadBytes added in v1.1.2

func LeftPadBytes(slice []byte, l int) []byte

LeftPadBytes zero-pads slice to the left up to length l.

func RightPadBytes added in v1.1.2

func RightPadBytes(slice []byte, l int) []byte

RightPadBytes zero-pads slice to the right up to length l.

func ToHex deprecated added in v1.1.2

func ToHex(b []byte) string

ToHex returns the hex representation of b, prefixed with '0x'. For empty slices, the return value is "0x0".

Deprecated: use hexutil.Encode instead.

func ToHexArray added in v1.1.2

func ToHexArray(b [][]byte) []string

ToHexArray creates a array of hex-string based on []byte

Types

type Client

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

Client defines typed wrappers for the Ethereum RPC API.

func Dial

func Dial(rawurl string) (*Client, error)

Dial connects a client to the given URL.

func DialContext

func DialContext(ctx context.Context, rawurl string) (*Client, error)

func NewClient

func NewClient(c *rpc.Client) *Client

NewClient creates a client that uses the given RPC client.

func (*Client) BalanceAt

func (ec *Client) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)

BalanceAt returns the wei balance of the given account. The block number can be nil, in which case the balance is taken from the latest known block.

func (*Client) BlockByHash

func (ec *Client) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)

BlockByHash returns the given full block.

Note that loading full blocks requires two requests. Use HeaderByHash if you don't need all transactions or uncle headers.

func (*Client) BlockByNumber

func (ec *Client) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)

BlockByNumber returns a block from the current canonical chain. If number is nil, the latest known block is returned.

Note that loading full blocks requires two requests. Use HeaderByNumber if you don't need all transactions or uncle headers.

func (*Client) CallContract

func (ec *Client) CallContract(ctx context.Context, msg truechain.CallMsg, blockNumber *big.Int) ([]byte, error)

CallContract executes a message call transaction, which is directly executed in the VM of the node, but never mined into the blockchain.

blockNumber selects the block height at which the call runs. It can be nil, in which case the code is taken from the latest known block. Note that state from very old blocks might not be available.

func (*Client) ChainID added in v1.1.2

func (ec *Client) ChainID(ctx context.Context) (*big.Int, error)

SnailBlockchain Access ChainId retrieves the current chain ID for transaction replay protection.

func (*Client) Close

func (ec *Client) Close()

func (*Client) CodeAt

func (ec *Client) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)

CodeAt returns the contract code of the given account. The block number can be nil, in which case the code is taken from the latest known block.

func (*Client) Coinbase added in v1.1.1

func (ec *Client) Coinbase(ctx context.Context) (string, error)

etrue_coinbase

func (*Client) EstimateGas

func (ec *Client) EstimateGas(ctx context.Context, msg truechain.CallMsg) (uint64, error)

EstimateGas tries to estimate the gas needed to execute a specific transaction based on the current pending state of the backend blockchain. There is no guarantee that this is the true gas limit requirement as other transactions may be added or removed by miners, but it should provide a basis for setting a reasonable default.

func (*Client) FilterLogs

func (ec *Client) FilterLogs(ctx context.Context, q truechain.FilterQuery) ([]types.Log, error)

FilterLogs executes a filter query.

func (*Client) FruitByHash added in v1.1.2

func (ec *Client) FruitByHash(ctx context.Context, hash common.Hash, fullSigns bool) (*rpcFruit, error)

FruitByHash returns the given fruit.

Note that loading full blocks requires three requests.

func (*Client) FruitByNumber added in v1.1.2

func (ec *Client) FruitByNumber(ctx context.Context, number *big.Int, fullSigns bool) (*rpcFruit, error)

FruitByNumber returns a block from the current canonical chain. If number is nil, the latest known fruit is returned.

Note that loading full blocks requires three requests.

func (*Client) FruitCount added in v1.1.2

func (ec *Client) FruitCount(ctx context.Context, blockHash common.Hash) (uint, error)

FruitCount returns the total number of fruits in the given block.

func (*Client) FruitInBlockByHash added in v1.1.2

func (ec *Client) FruitInBlockByHash(ctx context.Context, snailBlockHash common.Hash, index uint, fullSigns bool) (*rpcFruit, error)

FruitInBlockByHash returns a single fruit at index in the given block.

func (*Client) FruitInBlockByNumber added in v1.1.2

func (ec *Client) FruitInBlockByNumber(ctx context.Context, snailBlockNumber *big.Int, index uint, fullSigns bool) (*rpcFruit, error)

FruitInBlockByNumber returns a single fruit at index in the given block.

func (*Client) GetAllCancelableAsset

func (ec *Client) GetAllCancelableAsset(ctx context.Context, account common.Address, number *big.Int) ([]vm.CancelableAsset, error)

impawn_getAllCancelableAsset

func (*Client) GetAllStakingAccount

func (ec *Client) GetAllStakingAccount(ctx context.Context, number *big.Int) (json.RawMessage, error)

impawn_getAllStakingAccount

func (*Client) GetBalanceAtBlockNumber added in v1.1.2

func (ec *Client) GetBalanceAtBlockNumber(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)

GetBalanceAtBlockNumber returns the wei balance of the given account. The block number can be nil, in which case the balance is taken from the latest known block.

func (*Client) GetChainRewardContent

func (ec *Client) GetChainRewardContent(ctx context.Context, account common.Address, number *big.Int) (map[string]interface{}, error)

etrue_getChainRewardContent

func (*Client) GetImpawnSummay

func (ec *Client) GetImpawnSummay(ctx context.Context, number *big.Int) (map[string]interface{}, error)

func (*Client) GetLockedAsset

func (ec *Client) GetLockedAsset(ctx context.Context, account common.Address, number *big.Int) ([]vm.LockedAsset, error)

impawn_getLockedAsset

func (*Client) GetNonceAtBlockNumber added in v1.1.2

func (ec *Client) GetNonceAtBlockNumber(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)

GetNonceAtBlockNumber returns the account nonce of the given account. The block number can be nil, in which case the nonce is taken from the latest known block.

func (*Client) GetProtocolVersion added in v1.1.1

func (ec *Client) GetProtocolVersion(ctx context.Context) (string, error)

etrue_protocolVersion

func (*Client) GetStakingAccount

func (ec *Client) GetStakingAccount(ctx context.Context, account common.Address, number *big.Int) (map[string]interface{}, error)

impawn_getStakingAccount

func (*Client) GetStakingAsset

func (ec *Client) GetStakingAsset(ctx context.Context, account common.Address, number *big.Int) ([]vm.StakingAsset, error)

impawn_getStakingAsset

func (*Client) HeaderByHash

func (ec *Client) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

HeaderByHash returns the block header with the given hash.

func (*Client) HeaderByNumber

func (ec *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.

func (*Client) IsMining added in v1.1.1

func (ec *Client) IsMining(ctx context.Context) (bool, error)

etrue_mining

func (*Client) ListAccounts added in v1.1.2

func (ec *Client) ListAccounts(ctx context.Context) ([]common.Address, error)

personal_listAccounts

func (*Client) LockBalanceAt

func (ec *Client) LockBalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)

LockBalanceAt returns the wei balance of the given account. The block number can be nil, in which case the balance is taken from the latest known block.

func (*Client) NetworkID

func (ec *Client) NetworkID(ctx context.Context) (*big.Int, error)

NetworkID returns the network ID (also known as the chain ID) for this chain.

func (*Client) NonceAt

func (ec *Client) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)

NonceAt returns the account nonce of the given account. The block number can be nil, in which case the nonce is taken from the latest known block.

func (*Client) PendingBalanceAt

func (ec *Client) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error)

PendingBalanceAt returns the wei balance of the given account in the pending state.

func (*Client) PendingCallContract

func (ec *Client) PendingCallContract(ctx context.Context, msg truechain.CallMsg) ([]byte, error)

PendingCallContract executes a message call transaction using the EVM. The state seen by the contract call is the pending state.

func (*Client) PendingCodeAt

func (ec *Client) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)

PendingCodeAt returns the contract code of the given account in the pending state.

func (*Client) PendingFruitCount added in v1.1.2

func (ec *Client) PendingFruitCount(ctx context.Context) (uint, error)

PendingFruitCount returns the total number of fruits in the pending state.

func (*Client) PendingNonceAt

func (ec *Client) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)

PendingNonceAt returns the account nonce of the given account in the pending state. This is the nonce that should be used for the next transaction.

func (*Client) PendingStorageAt

func (ec *Client) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error)

PendingStorageAt returns the value of key in the contract storage of the given account in the pending state.

func (*Client) PendingTransactionCount

func (ec *Client) PendingTransactionCount(ctx context.Context) (uint, error)

PendingTransactionCount returns the total number of transactions in the pending state.

func (*Client) Pubkey

func (ec *Client) Pubkey(ctx context.Context) (string, error)

etrue_pubkey

func (*Client) SendPayTransaction added in v1.1.2

func (ec *Client) SendPayTransaction(ctx context.Context, tx *types.Transaction) error

SendPayTransaction injects a signed transaction(both sender and payer) into the pending pool for execution.

If the transaction was a contract creation use the TransactionReceipt method to get the contract address after the transaction has been mined.

func (*Client) SendTransaction

func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) error

SendTransaction injects a signed transaction into the pending pool for execution.

If the transaction was a contract creation use the TransactionReceipt method to get the contract address after the transaction has been mined.

func (*Client) SnailBlockByHash added in v1.1.2

func (ec *Client) SnailBlockByHash(ctx context.Context, hash common.Hash) (*rpcSnailBlock, error)

SnailBlockByHash returns the given full block.

Note that loading full blocks requires two requests.

func (*Client) SnailBlockByNumber added in v1.1.2

func (ec *Client) SnailBlockByNumber(ctx context.Context, number *big.Int) (*rpcSnailBlock, error)

SnailBlockByNumber returns a block from the current canonical chain. If number is nil, the latest known block is returned.

Note that loading full blocks requires two requests.

func (*Client) SnailHeaderByHash added in v1.1.2

func (ec *Client) SnailHeaderByHash(ctx context.Context, hash common.Hash) (*rpcSnailHeader, error)

SnailHeaderByHash returns the block header with the given hash.

func (*Client) SnailHeaderByNumber added in v1.1.2

func (ec *Client) SnailHeaderByNumber(ctx context.Context, number *big.Int) (*rpcSnailHeader, error)

SnailHeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.

func (*Client) StorageAt

func (ec *Client) StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)

StorageAt returns the value of key in the contract storage of the given account. The block number can be nil, in which case the value is taken from the latest known block.

func (*Client) SubscribeFilterLogs

func (ec *Client) SubscribeFilterLogs(ctx context.Context, q truechain.FilterQuery, ch chan<- types.Log) (truechain.Subscription, error)

SubscribeFilterLogs subscribes to the results of a streaming filter query.

func (*Client) SubscribeNewHead

func (ec *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (truechain.Subscription, error)

SubscribeNewHead subscribes to notifications about the current blockchain head on the given channel.

func (*Client) SuggestGasPrice

func (ec *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error)

SuggestGasPrice retrieves the currently suggested gas price to allow a timely execution of a transaction.

func (*Client) SyncProgress

func (ec *Client) SyncProgress(ctx context.Context) (*truechain.SyncProgress, error)

SyncProgress retrieves the current progress of the sync algorithm. If there's no sync currently running, it returns nil.

func (*Client) TransactionByHash

func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)

TransactionByHash returns the transaction with the given hash.

func (*Client) TransactionCount

func (ec *Client) TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error)

TransactionCount returns the total number of transactions in the given block.

func (*Client) TransactionInBlock

func (ec *Client) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error)

TransactionInBlock returns a single transaction at index in the given block.

func (*Client) TransactionReceipt

func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)

TransactionReceipt returns the receipt of a transaction by transaction hash. Note that the receipt is not available for pending transactions.

func (*Client) TransactionSender

func (ec *Client) TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error)

TransactionSender returns the sender address of the given transaction. The transaction must be known to the remote node and included in the blockchain at the given block and index. The sender is the one derived by the protocol at the time of inclusion.

There is a fast-path for transactions retrieved by TransactionByHash and TransactionInBlock. Getting their sender address can be done without an RPC interaction.

Jump to

Keyboard shortcuts

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