Documentation ¶
Overview ¶
Package ethapi implements the general Ethereum API functions.
Index ¶
- func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrHash, ...) (acl types.AccessList, gasUsed uint64, vmErr error, err error)
- func DoCall(ctx context.Context, b Backend, args TransactionArgs, ...) (*core.ExecutionResult, error)
- func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, ...) (hexutil.Uint64, error)
- func GetAPIs(apiBackend Backend) []rpc.API
- func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *params.ChainConfig) (map[string]interface{}, error)
- func RPCMarshalHeader(head *types.Header) map[string]interface{}
- func SubmitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (common.Hash, error)
- type AccountResult
- type AddrLocker
- type Backend
- type BadBlockArgs
- type BlockChainAPI
- func (s *BlockChainAPI) BlockNumber() hexutil.Uint64
- func (s *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, ...) (hexutil.Bytes, error)
- func (s *BlockChainAPI) CallDetailed(ctx context.Context, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, ...) (*ExecutionResult, error)
- func (api *BlockChainAPI) ChainId() *hexutil.Big
- func (s *BlockChainAPI) CreateAccessList(ctx context.Context, args TransactionArgs, ...) (*accessListResult, error)
- func (s *BlockChainAPI) EstimateGas(ctx context.Context, args TransactionArgs, ...) (hexutil.Uint64, error)
- func (s *BlockChainAPI) GetAssetBalance(ctx context.Context, address common.Address, ...) (*hexutil.Big, error)
- func (s *BlockChainAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs, error)
- func (s *BlockChainAPI) GetBalance(ctx context.Context, address common.Address, ...) (*hexutil.Big, error)
- func (s *BlockChainAPI) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (map[string]interface{}, error)
- func (s *BlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)
- func (api *BlockChainAPI) GetChainConfig(ctx context.Context) *params.ChainConfig
- func (s *BlockChainAPI) GetCode(ctx context.Context, address common.Address, ...) (hexutil.Bytes, error)
- func (s *BlockChainAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) map[string]interface{}
- func (s *BlockChainAPI) GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (map[string]interface{}, error)
- func (s *BlockChainAPI) GetProof(ctx context.Context, address common.Address, storageKeys []string, ...) (*AccountResult, error)
- func (s *BlockChainAPI) GetStorageAt(ctx context.Context, address common.Address, key string, ...) (hexutil.Bytes, error)
- func (s *BlockChainAPI) GetUncleByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (map[string]interface{}, error)
- func (s *BlockChainAPI) GetUncleByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (map[string]interface{}, error)
- func (s *BlockChainAPI) GetUncleCountByBlockHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint
- func (s *BlockChainAPI) GetUncleCountByBlockNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint
- type BlockOverrides
- type DebugAPI
- func (api *DebugAPI) GetBlockRlp(ctx context.Context, number uint64) (hexutil.Bytes, error)
- func (api *DebugAPI) GetHeaderRlp(ctx context.Context, number uint64) (hexutil.Bytes, error)
- func (api *DebugAPI) GetRawReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]hexutil.Bytes, error)
- func (api *DebugAPI) PrintBlock(ctx context.Context, number uint64) (string, error)
- type EthereumAPI
- func (s *EthereumAPI) BaseFee(ctx context.Context) (*hexutil.Big, error)
- func (s *EthereumAPI) FeeHistory(ctx context.Context, blockCount rpc.DecimalOrHex, lastBlock rpc.BlockNumber, ...) (*feeHistoryResult, error)
- func (s *EthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error)
- func (s *EthereumAPI) MaxPriorityFeePerGas(ctx context.Context) (*hexutil.Big, error)
- func (s *EthereumAPI) Syncing() (interface{}, error)
- type EthereumAccountAPI
- type ExecutionResult
- type NetAPI
- type OverrideAccount
- type PersonalAccountAPI
- func (s *PersonalAccountAPI) DeriveAccount(url string, path string, pin *bool) (accounts.Account, error)
- func (s *PersonalAccountAPI) EcRecover(ctx context.Context, data, sig hexutil.Bytes) (common.Address, error)
- func (s *PersonalAccountAPI) ImportRawKey(privkey string, password string) (common.Address, error)
- func (s *PersonalAccountAPI) InitializeWallet(ctx context.Context, url string) (string, error)
- func (s *PersonalAccountAPI) ListAccounts() []common.Address
- func (s *PersonalAccountAPI) ListWallets() []rawWallet
- func (s *PersonalAccountAPI) LockAccount(addr common.Address) bool
- func (s *PersonalAccountAPI) NewAccount(password string) (common.Address, error)
- func (s *PersonalAccountAPI) OpenWallet(url string, passphrase *string) error
- func (s *PersonalAccountAPI) SendTransaction(ctx context.Context, args TransactionArgs, passwd string) (common.Hash, error)
- func (s *PersonalAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr common.Address, passwd string) (hexutil.Bytes, error)
- func (s *PersonalAccountAPI) SignTransaction(ctx context.Context, args TransactionArgs, passwd string) (*SignTransactionResult, error)
- func (s *PersonalAccountAPI) UnlockAccount(ctx context.Context, addr common.Address, password string, duration *uint64) (bool, error)
- func (s *PersonalAccountAPI) Unpair(ctx context.Context, url string, pin string) error
- type RPCTransaction
- type SignTransactionResult
- type StateOverride
- type StorageResult
- type TransactionAPI
- func (s *TransactionAPI) FillTransaction(ctx context.Context, args TransactionArgs) (*SignTransactionResult, error)
- func (s *TransactionAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint
- func (s *TransactionAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint
- func (s *TransactionAPI) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) hexutil.Bytes
- func (s *TransactionAPI) GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) hexutil.Bytes
- func (s *TransactionAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error)
- func (s *TransactionAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) *RPCTransaction
- func (s *TransactionAPI) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) *RPCTransaction
- func (s *TransactionAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error)
- func (s *TransactionAPI) GetTransactionCount(ctx context.Context, address common.Address, ...) (*hexutil.Uint64, error)
- func (s *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error)
- func (s *TransactionAPI) PendingTransactions() ([]*RPCTransaction, error)
- func (s *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs, gasPrice *hexutil.Big, ...) (common.Hash, error)
- func (s *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error)
- func (s *TransactionAPI) SendTransaction(ctx context.Context, args TransactionArgs) (common.Hash, error)
- func (s *TransactionAPI) Sign(addr common.Address, data hexutil.Bytes) (hexutil.Bytes, error)
- func (s *TransactionAPI) SignTransaction(ctx context.Context, args TransactionArgs) (*SignTransactionResult, error)
- type TransactionArgs
- type TxPoolAPI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccessList ¶ added in v0.8.13
func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrHash, args TransactionArgs) (acl types.AccessList, gasUsed uint64, vmErr error, err error)
AccessList creates an access list for the given transaction. If the accesslist creation fails an error is returned. If the transaction itself fails, an vmErr is returned.
func DoCall ¶
func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *StateOverride, timeout time.Duration, globalGasCap uint64) (*core.ExecutionResult, error)
func DoEstimateGas ¶
func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap uint64) (hexutil.Uint64, error)
func RPCMarshalBlock ¶
func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *params.ChainConfig) (map[string]interface{}, error)
RPCMarshalBlock converts the given block to the RPC output which depends on fullTx. If inclTx is true transactions are returned. When fullTx is true the returned block contains full transaction details, otherwise it will only contain transaction hashes.
func RPCMarshalHeader ¶
RPCMarshalHeader converts the given header to the RPC output .
func SubmitTransaction ¶
SubmitTransaction is a helper function that submits tx to txPool and logs a message.
Types ¶
type AccountResult ¶
type AccountResult struct { Address common.Address `json:"address"` AccountProof []string `json:"accountProof"` Balance *hexutil.Big `json:"balance"` CodeHash common.Hash `json:"codeHash"` Nonce hexutil.Uint64 `json:"nonce"` StorageHash common.Hash `json:"storageHash"` StorageProof []StorageResult `json:"storageProof"` }
Result structs for GetProof
type AddrLocker ¶
type AddrLocker struct {
// contains filtered or unexported fields
}
func (*AddrLocker) LockAddr ¶
func (l *AddrLocker) LockAddr(address common.Address)
LockAddr locks an account's mutex. This is used to prevent another tx getting the same nonce until the lock is released. The mutex prevents the (an identical nonce) from being read again during the time that the first transaction is being signed.
func (*AddrLocker) UnlockAddr ¶
func (l *AddrLocker) UnlockAddr(address common.Address)
UnlockAddr unlocks the mutex of the given account.
type Backend ¶
type Backend interface { // General Ethereum API EstimateBaseFee(ctx context.Context) (*big.Int, error) SuggestPrice(ctx context.Context) (*big.Int, error) SuggestGasTipCap(ctx context.Context) (*big.Int, error) FeeHistory(ctx context.Context, blockCount int, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) ChainDb() ethdb.Database AccountManager() *accounts.Manager ExtRPCEnabled() bool RPCGasCap() uint64 // global gas cap for eth_call over rpc: DoS protection RPCEVMTimeout() time.Duration // global timeout for eth_call over rpc: DoS protection RPCTxFeeCap() float64 // global tx fee cap for all transaction related APIs UnprotectedAllowed(tx *types.Transaction) bool // allows only for EIP155 transactions. // Blockchain API HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Header, error) CurrentHeader() *types.Header CurrentBlock() *types.Block BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error) StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error) StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header, vmConfig *vm.Config) (*vm.EVM, func() error, error) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription BadBlocks() ([]*types.Block, []*core.BadBlockReason) // Transaction pool API SendTx(ctx context.Context, signedTx *types.Transaction) error GetTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) GetPoolTransactions() (types.Transactions, error) GetPoolTransaction(txHash common.Hash) *types.Transaction GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error) Stats() (pending int, queued int) TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions) TxPoolContentFrom(addr common.Address) (types.Transactions, types.Transactions) SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription ChainConfig() *params.ChainConfig Engine() consensus.Engine LastAcceptedBlock() *types.Block // eth/filters needs to be initialized from this backend type, so methods needed by // it must also be included here. filters.Backend }
Backend interface provides the common API services (that are provided by both full and light clients) with access to necessary functions.
type BadBlockArgs ¶ added in v0.10.0
type BadBlockArgs struct { Hash common.Hash `json:"hash"` Block map[string]interface{} `json:"block"` RLP string `json:"rlp"` Reason *core.BadBlockReason `json:"reason"` }
Note: this API is moved directly from ./eth/api.go to ensure that it is available under an API that is enabled by default without duplicating the code and serving the same API in the original location as well without creating a cyclic import.
BadBlockArgs represents the entries in the list returned when bad blocks are queried.
type BlockChainAPI ¶ added in v0.8.15
type BlockChainAPI struct {
// contains filtered or unexported fields
}
BlockChainAPI provides an API to access Ethereum blockchain data.
func NewBlockChainAPI ¶ added in v0.8.15
func NewBlockChainAPI(b Backend) *BlockChainAPI
NewBlockChainAPI creates a new Ethereum blockchain API.
func (*BlockChainAPI) BlockNumber ¶ added in v0.8.15
func (s *BlockChainAPI) BlockNumber() hexutil.Uint64
BlockNumber returns the block number of the chain head.
func (*BlockChainAPI) Call ¶ added in v0.8.15
func (s *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *StateOverride) (hexutil.Bytes, error)
Call executes the given transaction on the state for the given block number.
Additionally, the caller can specify a batch of contract for fields overriding.
Note, this function doesn't make and changes in the state/blockchain and is useful to execute and retrieve values.
func (*BlockChainAPI) CallDetailed ¶ added in v0.10.0
func (s *BlockChainAPI) CallDetailed(ctx context.Context, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *StateOverride) (*ExecutionResult, error)
CallDetailed performs the same call as Call, but returns the full context
func (*BlockChainAPI) ChainId ¶ added in v0.8.15
func (api *BlockChainAPI) ChainId() *hexutil.Big
ChainId is the EIP-155 replay-protection chain id for the current Ethereum chain config.
Note, this method does not conform to EIP-695 because the configured chain ID is always returned, regardless of the current head block. We used to return an error when the chain wasn't synced up to a block where EIP-155 is enabled, but this behavior caused issues in CL clients.
func (*BlockChainAPI) CreateAccessList ¶ added in v0.8.15
func (s *BlockChainAPI) CreateAccessList(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (*accessListResult, error)
CreateAccessList creates a EIP-2930 type AccessList for the given transaction. Reexec and BlockNrOrHash can be specified to create the accessList on top of a certain state.
func (*BlockChainAPI) EstimateGas ¶ added in v0.8.15
func (s *BlockChainAPI) EstimateGas(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error)
EstimateGas returns an estimate of the amount of gas needed to execute the given transaction against the current pending block.
func (*BlockChainAPI) GetAssetBalance ¶ added in v0.8.15
func (s *BlockChainAPI) GetAssetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash, assetID ids.ID) (*hexutil.Big, error)
GetAssetBalance returns the amount of [assetID] for the given address in the state of the given block number. The rpc.LatestBlockNumber, rpc.PendingBlockNumber, and rpc.AcceptedBlockNumber meta block numbers are also allowed.
func (*BlockChainAPI) GetBadBlocks ¶ added in v0.10.0
func (s *BlockChainAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs, error)
GetBadBlocks returns a list of the last 'bad blocks' that the client has seen on the network and returns them as a JSON list of block hashes.
func (*BlockChainAPI) GetBalance ¶ added in v0.8.15
func (s *BlockChainAPI) GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)
GetBalance returns the amount of wei for the given address in the state of the given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.
func (*BlockChainAPI) GetBlockByHash ¶ added in v0.8.15
func (s *BlockChainAPI) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (map[string]interface{}, error)
GetBlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.
func (*BlockChainAPI) GetBlockByNumber ¶ added in v0.8.15
func (s *BlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)
GetBlockByNumber returns the requested canonical block.
- When blockNr is -1 the chain head is returned.
- When blockNr is -2 the pending chain head is returned.
- When fullTx is true all transactions in the block are returned, otherwise only the transaction hash is returned.
func (*BlockChainAPI) GetChainConfig ¶ added in v0.11.4
func (api *BlockChainAPI) GetChainConfig(ctx context.Context) *params.ChainConfig
GetChainConfig returns the chain config.
func (*BlockChainAPI) GetCode ¶ added in v0.8.15
func (s *BlockChainAPI) GetCode(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)
GetCode returns the code stored at the given address in the state for the given block number.
func (*BlockChainAPI) GetHeaderByHash ¶ added in v0.8.15
func (s *BlockChainAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) map[string]interface{}
GetHeaderByHash returns the requested header by hash.
func (*BlockChainAPI) GetHeaderByNumber ¶ added in v0.8.15
func (s *BlockChainAPI) GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (map[string]interface{}, error)
GetHeaderByNumber returns the requested canonical block header. * When blockNr is -1 the chain head is returned. * When blockNr is -2 the pending chain head is returned.
func (*BlockChainAPI) GetProof ¶ added in v0.8.15
func (s *BlockChainAPI) GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNrOrHash rpc.BlockNumberOrHash) (*AccountResult, error)
GetProof returns the Merkle-proof for a given account and optionally some storage keys.
func (*BlockChainAPI) GetStorageAt ¶ added in v0.8.15
func (s *BlockChainAPI) GetStorageAt(ctx context.Context, address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)
GetStorageAt returns the storage from the state at the given address, key and block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.
func (*BlockChainAPI) GetUncleByBlockHashAndIndex ¶ added in v0.8.15
func (s *BlockChainAPI) GetUncleByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (map[string]interface{}, error)
GetUncleByBlockHashAndIndex returns the uncle block for the given block hash and index.
func (*BlockChainAPI) GetUncleByBlockNumberAndIndex ¶ added in v0.8.15
func (s *BlockChainAPI) GetUncleByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (map[string]interface{}, error)
GetUncleByBlockNumberAndIndex returns the uncle block for the given block number and index.
func (*BlockChainAPI) GetUncleCountByBlockHash ¶ added in v0.8.15
func (s *BlockChainAPI) GetUncleCountByBlockHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint
GetUncleCountByBlockHash returns number of uncles in the block for the given block hash
func (*BlockChainAPI) GetUncleCountByBlockNumber ¶ added in v0.8.15
func (s *BlockChainAPI) GetUncleCountByBlockNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint
GetUncleCountByBlockNumber returns number of uncles in the block for the given block number
type BlockOverrides ¶ added in v0.8.15
type BlockOverrides struct { Number *hexutil.Big Difficulty *hexutil.Big Time *hexutil.Big GasLimit *hexutil.Uint64 Coinbase *common.Address BaseFee *hexutil.Big }
BlockOverrides is a set of header fields to override.
func (*BlockOverrides) Apply ¶ added in v0.8.15
func (diff *BlockOverrides) Apply(blockCtx *vm.BlockContext)
Apply overrides the given header fields into the given block context.
type DebugAPI ¶ added in v0.8.15
type DebugAPI struct {
// contains filtered or unexported fields
}
DebugAPI is the collection of Ethereum APIs exposed over the debugging namespace.
func NewDebugAPI ¶ added in v0.8.15
NewDebugAPI creates a new instance of DebugAPI.
func (*DebugAPI) GetBlockRlp ¶ added in v0.8.15
GetBlockRlp retrieves the RLP encoded for of a single block.
func (*DebugAPI) GetHeaderRlp ¶ added in v0.8.15
GetHeaderRlp retrieves the RLP encoded for of a single header.
func (*DebugAPI) GetRawReceipts ¶ added in v0.8.15
func (api *DebugAPI) GetRawReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]hexutil.Bytes, error)
GetRawReceipts retrieves the binary-encoded raw receipts of a single block.
type EthereumAPI ¶ added in v0.8.15
type EthereumAPI struct {
// contains filtered or unexported fields
}
EthereumAPI provides an API to access Ethereum related information.
func NewEthereumAPI ¶ added in v0.8.15
func NewEthereumAPI(b Backend) *EthereumAPI
NewEthereumAPI creates a new Ethereum protocol API.
func (*EthereumAPI) BaseFee ¶ added in v0.8.15
BaseFee returns an estimate for what the base fee will be on the next block if it is produced now.
func (*EthereumAPI) FeeHistory ¶ added in v0.8.15
func (s *EthereumAPI) FeeHistory(ctx context.Context, blockCount rpc.DecimalOrHex, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*feeHistoryResult, error)
FeeHistory returns the fee market history.
func (*EthereumAPI) GasPrice ¶ added in v0.8.15
GasPrice returns a suggestion for a gas price for legacy transactions.
func (*EthereumAPI) MaxPriorityFeePerGas ¶ added in v0.8.15
MaxPriorityFeePerGas returns a suggestion for a gas tip cap for dynamic fee transactions.
func (*EthereumAPI) Syncing ¶ added in v0.8.15
func (s *EthereumAPI) Syncing() (interface{}, error)
Syncing allows the caller to determine whether the chain is syncing or not. In geth, the response is either a map representing an ethereum.SyncProgress struct or "false" (indicating the chain is not syncing). In coreth, avalanchego prevents API calls unless bootstrapping is complete, so we always return false here for API compatibility.
type EthereumAccountAPI ¶ added in v0.8.15
type EthereumAccountAPI struct {
// contains filtered or unexported fields
}
EthereumAccountAPI provides an API to access accounts managed by this node. It offers only methods that can retrieve accounts.
func NewEthereumAccountAPI ¶ added in v0.8.15
func NewEthereumAccountAPI(am *accounts.Manager) *EthereumAccountAPI
NewEthereumAccountAPI creates a new EthereumAccountAPI.
func (*EthereumAccountAPI) Accounts ¶ added in v0.8.15
func (s *EthereumAccountAPI) Accounts() []common.Address
Accounts returns the collection of accounts this node manages.
type ExecutionResult ¶
type ExecutionResult struct { UsedGas uint64 `json:"gas"` // Total used gas but include the refunded gas ErrCode int `json:"errCode"` // EVM error code Err string `json:"err"` // Any error encountered during the execution(listed in core/vm/errors.go) ReturnData hexutil.Bytes `json:"returnData"` // Data from evm(function result or data supplied with revert opcode) }
type NetAPI ¶ added in v0.8.15
type NetAPI struct {
// contains filtered or unexported fields
}
NetAPI offers network related RPC methods
func (*NetAPI) Listening ¶ added in v0.8.15
Listening returns an indication if the node is listening for network connections.
type OverrideAccount ¶ added in v0.8.13
type OverrideAccount struct { Nonce *hexutil.Uint64 `json:"nonce"` Code *hexutil.Bytes `json:"code"` Balance **hexutil.Big `json:"balance"` State *map[common.Hash]common.Hash `json:"state"` StateDiff *map[common.Hash]common.Hash `json:"stateDiff"` }
OverrideAccount indicates the overriding fields of account during the execution of a message call. Note, state and stateDiff can't be specified at the same time. If state is set, message execution will only use the data in the given state. Otherwise if statDiff is set, all diff will be applied first and then execute the call message.
type PersonalAccountAPI ¶ added in v0.8.15
type PersonalAccountAPI struct {
// contains filtered or unexported fields
}
PersonalAccountAPI provides an API to access accounts managed by this node. It offers methods to create, (un)lock en list accounts. Some methods accept passwords and are therefore considered private by default.
func NewPersonalAccountAPI ¶ added in v0.8.15
func NewPersonalAccountAPI(b Backend, nonceLock *AddrLocker) *PersonalAccountAPI
NewPersonalAccountAPI create a new PersonalAccountAPI.
func (*PersonalAccountAPI) DeriveAccount ¶ added in v0.8.15
func (s *PersonalAccountAPI) DeriveAccount(url string, path string, pin *bool) (accounts.Account, error)
DeriveAccount requests a HD wallet to derive a new account, optionally pinning it for later reuse.
func (*PersonalAccountAPI) EcRecover ¶ added in v0.8.15
func (s *PersonalAccountAPI) EcRecover(ctx context.Context, data, sig hexutil.Bytes) (common.Address, error)
EcRecover returns the address for the account that was used to create the signature. Note, this function is compatible with eth_sign and personal_sign. As such it recovers the address of: hash = keccak256("\x19Ethereum Signed Message:\n"${message length}${message}) addr = ecrecover(hash, signature)
Note, the signature must conform to the secp256k1 curve R, S and V values, where the V value must be 27 or 28 for legacy reasons.
https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecRecover
func (*PersonalAccountAPI) ImportRawKey ¶ added in v0.8.15
ImportRawKey stores the given hex encoded ECDSA key into the key directory, encrypting it with the passphrase.
func (*PersonalAccountAPI) InitializeWallet ¶ added in v0.8.15
InitializeWallet initializes a new wallet at the provided URL, by generating and returning a new private key.
func (*PersonalAccountAPI) ListAccounts ¶ added in v0.8.15
func (s *PersonalAccountAPI) ListAccounts() []common.Address
ListAccounts will return a list of addresses for accounts this node manages.
func (*PersonalAccountAPI) ListWallets ¶ added in v0.8.15
func (s *PersonalAccountAPI) ListWallets() []rawWallet
ListWallets will return a list of wallets this node manages.
func (*PersonalAccountAPI) LockAccount ¶ added in v0.8.15
func (s *PersonalAccountAPI) LockAccount(addr common.Address) bool
LockAccount will lock the account associated with the given address when it's unlocked.
func (*PersonalAccountAPI) NewAccount ¶ added in v0.8.15
func (s *PersonalAccountAPI) NewAccount(password string) (common.Address, error)
NewAccount will create a new account and returns the address for the new account.
func (*PersonalAccountAPI) OpenWallet ¶ added in v0.8.15
func (s *PersonalAccountAPI) OpenWallet(url string, passphrase *string) error
OpenWallet initiates a hardware wallet opening procedure, establishing a USB connection and attempting to authenticate via the provided passphrase. Note, the method may return an extra challenge requiring a second open (e.g. the Trezor PIN matrix challenge).
func (*PersonalAccountAPI) SendTransaction ¶ added in v0.8.15
func (s *PersonalAccountAPI) SendTransaction(ctx context.Context, args TransactionArgs, passwd string) (common.Hash, error)
SendTransaction will create a transaction from the given arguments and tries to sign it with the key associated with args.From. If the given passwd isn't able to decrypt the key it fails.
func (*PersonalAccountAPI) Sign ¶ added in v0.8.15
func (s *PersonalAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr common.Address, passwd string) (hexutil.Bytes, error)
Sign calculates an Ethereum ECDSA signature for: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))
Note, the produced signature conforms to the secp256k1 curve R, S and V values, where the V value will be 27 or 28 for legacy reasons.
The key used to calculate the signature is decrypted with the given password.
https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
func (*PersonalAccountAPI) SignTransaction ¶ added in v0.8.15
func (s *PersonalAccountAPI) SignTransaction(ctx context.Context, args TransactionArgs, passwd string) (*SignTransactionResult, error)
SignTransaction will create a transaction from the given arguments and tries to sign it with the key associated with args.From. If the given passwd isn't able to decrypt the key it fails. The transaction is returned in RLP-form, not broadcast to other nodes
func (*PersonalAccountAPI) UnlockAccount ¶ added in v0.8.15
func (s *PersonalAccountAPI) UnlockAccount(ctx context.Context, addr common.Address, password string, duration *uint64) (bool, error)
UnlockAccount will unlock the account associated with the given address with the given password for duration seconds. If duration is nil it will use a default of 300 seconds. It returns an indication if the account was unlocked.
type RPCTransaction ¶
type RPCTransaction struct { BlockHash *common.Hash `json:"blockHash"` BlockNumber *hexutil.Big `json:"blockNumber"` From common.Address `json:"from"` Gas hexutil.Uint64 `json:"gas"` GasPrice *hexutil.Big `json:"gasPrice"` GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"` GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"` Hash common.Hash `json:"hash"` Input hexutil.Bytes `json:"input"` Nonce hexutil.Uint64 `json:"nonce"` To *common.Address `json:"to"` TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` Value *hexutil.Big `json:"value"` Type hexutil.Uint64 `json:"type"` Accesses *types.AccessList `json:"accessList,omitempty"` ChainID *hexutil.Big `json:"chainId,omitempty"` V *hexutil.Big `json:"v"` R *hexutil.Big `json:"r"` S *hexutil.Big `json:"s"` }
RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
type SignTransactionResult ¶
type SignTransactionResult struct { Raw hexutil.Bytes `json:"raw"` Tx *types.Transaction `json:"tx"` }
SignTransactionResult represents a RLP encoded signed transaction.
type StateOverride ¶ added in v0.8.13
type StateOverride map[common.Address]OverrideAccount
StateOverride is the collection of overridden accounts.
type StorageResult ¶
type TransactionAPI ¶ added in v0.8.15
type TransactionAPI struct {
// contains filtered or unexported fields
}
TransactionAPI exposes methods for reading and creating transaction data.
func NewTransactionAPI ¶ added in v0.8.15
func NewTransactionAPI(b Backend, nonceLock *AddrLocker) *TransactionAPI
NewTransactionAPI creates a new RPC service with methods for interacting with transactions.
func (*TransactionAPI) FillTransaction ¶ added in v0.8.15
func (s *TransactionAPI) FillTransaction(ctx context.Context, args TransactionArgs) (*SignTransactionResult, error)
FillTransaction fills the defaults (nonce, gas, gasPrice or 1559 fields) on a given unsigned transaction, and returns it to the caller for further processing (signing + broadcast).
func (*TransactionAPI) GetBlockTransactionCountByHash ¶ added in v0.8.15
func (s *TransactionAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint
GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash.
func (*TransactionAPI) GetBlockTransactionCountByNumber ¶ added in v0.8.15
func (s *TransactionAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint
GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number.
func (*TransactionAPI) GetRawTransactionByBlockHashAndIndex ¶ added in v0.8.15
func (s *TransactionAPI) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) hexutil.Bytes
GetRawTransactionByBlockHashAndIndex returns the bytes of the transaction for the given block hash and index.
func (*TransactionAPI) GetRawTransactionByBlockNumberAndIndex ¶ added in v0.8.15
func (s *TransactionAPI) GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) hexutil.Bytes
GetRawTransactionByBlockNumberAndIndex returns the bytes of the transaction for the given block number and index.
func (*TransactionAPI) GetRawTransactionByHash ¶ added in v0.8.15
func (s *TransactionAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error)
GetRawTransactionByHash returns the bytes of the transaction for the given hash.
func (*TransactionAPI) GetTransactionByBlockHashAndIndex ¶ added in v0.8.15
func (s *TransactionAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) *RPCTransaction
GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index.
func (*TransactionAPI) GetTransactionByBlockNumberAndIndex ¶ added in v0.8.15
func (s *TransactionAPI) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) *RPCTransaction
GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index.
func (*TransactionAPI) GetTransactionByHash ¶ added in v0.8.15
func (s *TransactionAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error)
GetTransactionByHash returns the transaction for the given hash
func (*TransactionAPI) GetTransactionCount ¶ added in v0.8.15
func (s *TransactionAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error)
GetTransactionCount returns the number of transactions the given address has sent for the given block number
func (*TransactionAPI) GetTransactionReceipt ¶ added in v0.8.15
func (s *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error)
GetTransactionReceipt returns the transaction receipt for the given transaction hash.
func (*TransactionAPI) PendingTransactions ¶ added in v0.8.15
func (s *TransactionAPI) PendingTransactions() ([]*RPCTransaction, error)
PendingTransactions returns the transactions that are in the transaction pool and have a from address that is one of the accounts this node manages.
func (*TransactionAPI) Resend ¶ added in v0.8.15
func (s *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error)
Resend accepts an existing transaction and a new gas price and limit. It will remove the given transaction from the pool and reinsert it with the new gas price and limit.
func (*TransactionAPI) SendRawTransaction ¶ added in v0.8.15
func (s *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error)
SendRawTransaction will add the signed transaction to the transaction pool. The sender is responsible for signing the transaction and using the correct nonce.
func (*TransactionAPI) SendTransaction ¶ added in v0.8.15
func (s *TransactionAPI) SendTransaction(ctx context.Context, args TransactionArgs) (common.Hash, error)
SendTransaction creates a transaction for the given argument, sign it and submit it to the transaction pool.
func (*TransactionAPI) Sign ¶ added in v0.8.15
Sign calculates an ECDSA signature for: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message).
Note, the produced signature conforms to the secp256k1 curve R, S and V values, where the V value will be 27 or 28 for legacy reasons.
The account associated with addr must be unlocked.
func (*TransactionAPI) SignTransaction ¶ added in v0.8.15
func (s *TransactionAPI) SignTransaction(ctx context.Context, args TransactionArgs) (*SignTransactionResult, error)
SignTransaction will sign the given transaction with the from account. The node needs to have the private key of the account corresponding with the given from address and it needs to be unlocked.
type TransactionArgs ¶ added in v0.8.13
type TransactionArgs struct { From *common.Address `json:"from"` To *common.Address `json:"to"` Gas *hexutil.Uint64 `json:"gas"` GasPrice *hexutil.Big `json:"gasPrice"` MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"` MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"` Value *hexutil.Big `json:"value"` Nonce *hexutil.Uint64 `json:"nonce"` // We accept "data" and "input" for backwards-compatibility reasons. // "input" is the newer name and should be preferred by clients. // Issue detail: https://github.com/ethereum/go-ethereum/issues/15628 Data *hexutil.Bytes `json:"data"` Input *hexutil.Bytes `json:"input"` // Introduced by AccessListTxType transaction. AccessList *types.AccessList `json:"accessList,omitempty"` ChainID *hexutil.Big `json:"chainId,omitempty"` }
TransactionArgs represents the arguments to construct a new transaction or a message call.
func (*TransactionArgs) ToMessage ¶ added in v0.8.13
func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (types.Message, error)
ToMessage converts the transaction arguments to the Message type used by the core evm. This method is used in calls and traces that do not require a real live transaction.
func (*TransactionArgs) ToTransaction ¶ added in v0.8.13
func (args *TransactionArgs) ToTransaction() *types.Transaction
ToTransaction converts the arguments to a transaction. This assumes that setDefaults has been called.
type TxPoolAPI ¶ added in v0.8.15
type TxPoolAPI struct {
// contains filtered or unexported fields
}
TxPoolAPI offers and API for the transaction pool. It only operates on data that is non confidential.
func NewTxPoolAPI ¶ added in v0.8.15
NewTxPoolAPI creates a new tx pool service that gives information about the transaction pool.
func (*TxPoolAPI) Content ¶ added in v0.8.15
func (s *TxPoolAPI) Content() map[string]map[string]map[string]*RPCTransaction
Content returns the transactions contained within the transaction pool.
func (*TxPoolAPI) ContentFrom ¶ added in v0.8.15
ContentFrom returns the transactions contained within the transaction pool.