Documentation
¶
Overview ¶
Package prlclient provides a client for the Parallax RPC API.
Index ¶
- type AccountResult
- type Client
- func (ec *Client) BalanceAt(ctx context.Context, account util.Address, blockNumber *big.Int) (*big.Int, error)
- func (ec *Client) BlockByHash(ctx context.Context, hash util.Hash) (*types.Block, error)
- func (ec *Client) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
- func (ec *Client) BlockNumber(ctx context.Context) (uint64, error)
- func (ec *Client) CallContract(ctx context.Context, msg parallax.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (ec *Client) CallContractAtHash(ctx context.Context, msg parallax.CallMsg, blockHash util.Hash) ([]byte, error)
- func (ec *Client) CallContractWithOverrides(ctx context.Context, msg parallax.CallMsg, blockNumber *big.Int, ...) ([]byte, error)
- func (ec *Client) ChainID(ctx context.Context) (*big.Int, error)
- func (ec *Client) Close()
- func (ec *Client) CodeAt(ctx context.Context, account util.Address, blockNumber *big.Int) ([]byte, error)
- func (ec *Client) CreateAccessList(ctx context.Context, msg parallax.CallMsg) (*types.AccessList, uint64, string, error)
- func (ec *Client) EstimateGas(ctx context.Context, msg parallax.CallMsg) (uint64, error)
- func (ec *Client) FilterLogs(ctx context.Context, q parallax.FilterQuery) ([]types.Log, error)
- func (ec *Client) GCStats(ctx context.Context) (*debug.GCStats, error)
- func (ec *Client) GetNodeInfo(ctx context.Context) (*p2p.NodeInfo, error)
- func (ec *Client) GetProof(ctx context.Context, account util.Address, keys []string, blockNumber *big.Int) (*AccountResult, error)
- func (ec *Client) HeaderByHash(ctx context.Context, hash util.Hash) (*types.Header, error)
- func (ec *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (ec *Client) MemStats(ctx context.Context) (*runtime.MemStats, error)
- func (ec *Client) NetworkID(ctx context.Context) (*big.Int, error)
- func (ec *Client) NonceAt(ctx context.Context, account util.Address, blockNumber *big.Int) (uint64, error)
- func (ec *Client) PeerCount(ctx context.Context) (uint64, error)
- func (ec *Client) PendingBalanceAt(ctx context.Context, account util.Address) (*big.Int, error)
- func (ec *Client) PendingCallContract(ctx context.Context, msg parallax.CallMsg) ([]byte, error)
- func (ec *Client) PendingCodeAt(ctx context.Context, account util.Address) ([]byte, error)
- func (ec *Client) PendingNonceAt(ctx context.Context, account util.Address) (uint64, error)
- func (ec *Client) PendingStorageAt(ctx context.Context, account util.Address, key util.Hash) ([]byte, error)
- func (ec *Client) PendingTransactionCount(ctx context.Context) (uint, error)
- func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (ec *Client) SetHead(ctx context.Context, number *big.Int) error
- func (ec *Client) StorageAt(ctx context.Context, account util.Address, key util.Hash, blockNumber *big.Int) ([]byte, error)
- func (ec *Client) SubscribeFilterLogs(ctx context.Context, q parallax.FilterQuery, ch chan<- types.Log) (parallax.Subscription, error)
- func (ec *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (parallax.Subscription, error)
- func (ec *Client) SubscribePendingTransactions(ctx context.Context, ch chan<- util.Hash) (*rpc.ClientSubscription, error)
- func (ec *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (ec *Client) SuggestGasTipCap(ctx context.Context) (*big.Int, error)
- func (ec *Client) SyncProgress(ctx context.Context) (*parallax.SyncProgress, error)
- func (ec *Client) TransactionByHash(ctx context.Context, hash util.Hash) (tx *types.Transaction, isPending bool, err error)
- func (ec *Client) TransactionCount(ctx context.Context, blockHash util.Hash) (uint, error)
- func (ec *Client) TransactionInBlock(ctx context.Context, blockHash util.Hash, index uint) (*types.Transaction, error)
- func (ec *Client) TransactionReceipt(ctx context.Context, txHash util.Hash) (*types.Receipt, error)
- func (ec *Client) TransactionSender(ctx context.Context, tx *types.Transaction, block util.Hash, index uint) (util.Address, error)
- type OverrideAccount
- type StorageResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountResult ¶
type AccountResult struct {
Address util.Address `json:"address"`
AccountProof []string `json:"accountProof"`
Balance *big.Int `json:"balance"`
CodeHash util.Hash `json:"codeHash"`
Nonce uint64 `json:"nonce"`
StorageHash util.Hash `json:"storageHash"`
StorageProof []StorageResult `json:"storageProof"`
}
AccountResult is the result of a GetProof operation.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client defines typed wrappers for the Parallax RPC API.
func (*Client) BalanceAt ¶
func (ec *Client) BalanceAt(ctx context.Context, account util.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 ¶
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 ¶
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) BlockNumber ¶
BlockNumber returns the most recent block number
func (*Client) CallContract ¶
func (ec *Client) CallContract(ctx context.Context, msg parallax.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) CallContractAtHash ¶
func (ec *Client) CallContractAtHash(ctx context.Context, msg parallax.CallMsg, blockHash util.Hash) ([]byte, error)
CallContractAtHash is almost the same as CallContract except that it selects the block by block hash instead of block height.
func (*Client) CallContractWithOverrides ¶
func (ec *Client) CallContractWithOverrides(ctx context.Context, msg parallax.CallMsg, blockNumber *big.Int, overrides *map[util.Address]OverrideAccount) ([]byte, error)
CallContractWithOverrides executes a message call transaction with state overrides.
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.
overrides specifies a map of contract states that should be overwritten before executing the message call.
func (*Client) CodeAt ¶
func (ec *Client) CodeAt(ctx context.Context, account util.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) CreateAccessList ¶
func (ec *Client) CreateAccessList(ctx context.Context, msg parallax.CallMsg) (*types.AccessList, uint64, string, error)
CreateAccessList tries to create an access list for a specific transaction based on the current pending state of the blockchain.
func (*Client) EstimateGas ¶
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 ¶
FilterLogs executes a filter query.
func (*Client) GetNodeInfo ¶
GetNodeInfo retrieves the node info of a node.
func (*Client) GetProof ¶
func (ec *Client) GetProof(ctx context.Context, account util.Address, keys []string, blockNumber *big.Int) (*AccountResult, error)
GetProof returns the account and storage values of the specified account including the Merkle-proof. The block number can be nil, in which case the value is taken from the latest known block.
func (*Client) HeaderByHash ¶
HeaderByHash returns the block header with the given hash.
func (*Client) HeaderByNumber ¶
HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.
func (*Client) NetworkID ¶
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 util.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) PeerCount ¶
PeerCount returns the number of p2p peers as reported by the net_peerCount method.
func (*Client) PendingBalanceAt ¶
PendingBalanceAt returns the wei balance of the given account in the pending state.
func (*Client) PendingCallContract ¶
PendingCallContract executes a message call transaction using the PVM. The state seen by the contract call is the pending state.
func (*Client) PendingCodeAt ¶
PendingCodeAt returns the contract code of the given account in the pending state.
func (*Client) PendingNonceAt ¶
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 util.Address, key util.Hash) ([]byte, error)
PendingStorageAt returns the value of key in the contract storage of the given account in the pending state.
func (*Client) PendingTransactionCount ¶
PendingTransactionCount returns the total number of transactions in the pending state.
func (*Client) SendTransaction ¶
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) SetHead ¶
SetHead sets the current head of the local chain by block number. Note, this is a destructive action and may severely damage your chain. Use with extreme caution.
func (*Client) StorageAt ¶
func (ec *Client) StorageAt(ctx context.Context, account util.Address, key util.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 parallax.FilterQuery, ch chan<- types.Log) (parallax.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) (parallax.Subscription, error)
SubscribeNewHead subscribes to notifications about the current blockchain head on the given channel.
func (*Client) SubscribePendingTransactions ¶
func (ec *Client) SubscribePendingTransactions(ctx context.Context, ch chan<- util.Hash) (*rpc.ClientSubscription, error)
SubscribePendingTransactions subscribes to new pending transactions.
func (*Client) SuggestGasPrice ¶
SuggestGasPrice retrieves the currently suggested gas price to allow a timely execution of a transaction.
func (*Client) SuggestGasTipCap ¶
SuggestGasTipCap retrieves the currently suggested gas tip cap after 1559 to allow a timely execution of a transaction.
func (*Client) SyncProgress ¶
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 util.Hash) (tx *types.Transaction, isPending bool, err error)
TransactionByHash returns the transaction with the given hash.
func (*Client) TransactionCount ¶
TransactionCount returns the total number of transactions in the given block.
func (*Client) TransactionInBlock ¶
func (ec *Client) TransactionInBlock(ctx context.Context, blockHash util.Hash, index uint) (*types.Transaction, error)
TransactionInBlock returns a single transaction at index in the given block.
func (*Client) TransactionReceipt ¶
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 util.Hash, index uint) (util.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.
type OverrideAccount ¶
type OverrideAccount struct {
Nonce uint64 `json:"nonce"`
Code []byte `json:"code"`
Balance *big.Int `json:"balance"`
State map[util.Hash]util.Hash `json:"state"`
StateDiff map[util.Hash]util.Hash `json:"stateDiff"`
}
OverrideAccount specifies the state of an account to be overridden.