ethapi

package
v0.0.2-tenderly Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: GPL-3.0, LGPL-3.0 Imports: 47 Imported by: 0

Documentation

Overview

Package ethapi implements the general Ethereum API functions.

Index

Constants

View Source
const (
	// GetLatestLogMaxLogCount is the maximum number of logs that can be retrieved
	GetLatestLogMaxLogCount = 30000
	// GetLatestLogMaxBlockCount is the maximum number of blocks that can be scanned
	GetLatestLogMaxBlockCount = 1000
	// GetLatestLogMaxBlockScan caps blocks scanned in LogCount
	GetLatestLogMaxBlockScan = 100000
	// GetLogsMaxBlockRange is the maximum block range for bor_getLogs
	GetLogsMaxBlockRange = 1000
)
View Source
const ErrHeaderNotFound = "current header not found"

Variables

This section is empty.

Functions

func AccessList

func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrHash, args TransactionArgs, stateOverrides *override.StateOverride) (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, state *state.StateDB, overrides *override.StateOverride, blockOverrides *override.BlockOverrides, timeout time.Duration, globalGasCap uint64) (*core.ExecutionResult, error)

func DoEstimateGas

func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *override.StateOverride, blockOverrides *override.BlockOverrides, gasCap uint64) (hexutil.Uint64, error)

DoEstimateGas returns the lowest possible gas limit that allows the transaction to run successfully at block `blockNrOrHash`. It returns error if the transaction would revert, or if there are unexpected failures. The gas limit is capped by both `args.Gas` (if non-nil & non-zero) and `gasCap` (if non-zero).

func GetAPIs

func GetAPIs(apiBackend Backend) []rpc.API

func MarshalReceipt

func MarshalReceipt(receipt *types.Receipt, blockHash common.Hash, blockNumber uint64, signer types.Signer, tx *types.Transaction, txIndex int) map[string]interface{}

MarshalReceipt marshals a transaction receipt into a JSON object.

func RPCMarshalBlock

func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool, config *params.ChainConfig, db ethdb.Database) map[string]interface{}

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

func RPCMarshalHeader(head *types.Header) map[string]interface{}

RPCMarshalHeader converts the given header to the RPC output .

func RPCMarshalWitness

func RPCMarshalWitness(witness *stateless.Witness) map[string]interface{}

RPCMarshalWitness converts the given witness to the RPC output.

func SubmitTransaction

func SubmitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (common.Hash, error)

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"`
}

AccountResult 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
	SyncProgress(ctx context.Context) ethereum.SyncProgress
	ProtocolVersion() uint

	SuggestGasTipCap(ctx context.Context) (*big.Int, error)
	FeeHistory(ctx context.Context, blockCount uint64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, []*big.Int, []float64, error)
	BlobBaseFee(ctx context.Context) *big.Int
	ChainDb() ethdb.Database
	AccountManager() *accounts.Manager
	ExtRPCEnabled() bool
	RPCGasCap() uint64             // global gas cap for eth_call over rpc: DoS protection
	RPCRpcReturnDataLimit() uint64 // Maximum size (in bytes) a result of an rpc request could have
	RPCEVMTimeout() time.Duration  // global timeout for eth_call over rpc: DoS protection
	RPCTxFeeCap() float64          // global tx fee cap for all transaction related APIs
	UnprotectedAllowed() bool      // allows only for EIP155 transactions.
	RPCTxSyncDefaultTimeout() time.Duration
	RPCTxSyncMaxTimeout() time.Duration

	// Preconf / Private tx related API for relay
	PreconfEnabled() bool
	SubmitTxForPreconf(tx *types.Transaction) error
	CheckPreconfStatus(hash common.Hash) (bool, error)
	PrivateTxEnabled() bool
	SubmitPrivateTx(tx *types.Transaction) error

	// Preconf / Private tx related API for block producers
	AcceptPreconfTxs() bool
	AcceptPrivateTxs() bool
	RecordPrivateTx(hash common.Hash)
	PurgePrivateTx(hash common.Hash)

	// Blockchain API
	SetHead(number uint64)
	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.Header
	CurrentSafeBlock() *types.Header
	GetFinalizedBlockNumber(ctx context.Context) (uint64, error)
	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)
	Pending() (*types.Block, types.Receipts, *state.StateDB)
	GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error)
	GetCanonicalReceipt(tx *types.Transaction, blockHash common.Hash, blockNumber, blockIndex uint64) (*types.Receipt, error)
	GetEVM(ctx context.Context, state *state.StateDB, header *types.Header, vmConfig *vm.Config, blockCtx *vm.BlockContext) *vm.EVM
	GetTd(ctx context.Context, hash common.Hash) *big.Int
	GetTdByNumber(ctx context.Context, blockNr rpc.BlockNumber) *big.Int
	SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription
	SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription

	// Transaction pool API
	SendTx(ctx context.Context, signedTx *types.Transaction) error
	GetCanonicalTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64)
	TxIndexDone() bool
	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.Transaction, map[common.Address][]*types.Transaction)
	TxPoolContentFrom(addr common.Address) ([]*types.Transaction, []*types.Transaction)
	TxStatus(hash common.Hash) txpool.TxStatus
	SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription

	ChainConfig() *params.ChainConfig
	Engine() consensus.Engine
	HistoryPruningCutoff() uint64

	// This is copied from filters.Backend
	// eth/filters needs to be initialized from this backend type, so methods needed by
	// it must also be included here.
	GetBody(ctx context.Context, hash common.Hash, number rpc.BlockNumber) (*types.Body, error)
	GetLogs(ctx context.Context, blockHash common.Hash, number uint64) ([][]*types.Log, error)
	SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription
	SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription
	SubscribePendingLogsEvent(ch chan<- []*types.Log) event.Subscription

	// Bor related APIs
	SubscribeStateSyncEvent(ch chan<- core.StateSyncEvent) event.Subscription
	GetRootHash(ctx context.Context, starBlockNr uint64, endBlockNr uint64) (string, error)
	GetVoteOnHash(ctx context.Context, startBlockNumber uint64, endBlockNumber uint64, hash string, milestoneID string) (bool, error)
	GetBorBlockReceipt(ctx context.Context, hash common.Hash) (*types.Receipt, error)
	GetBorBlockLogs(ctx context.Context, hash common.Hash) ([]*types.Log, error)
	GetBorBlockTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error)
	GetBorBlockTransactionWithBlockHash(ctx context.Context, txHash common.Hash, blockHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error)
	SubscribeChain2HeadEvent(ch chan<- core.Chain2HeadEvent) event.Subscription
	GetWhitelistedCheckpoint() (bool, uint64, common.Hash)
	PurgeWhitelistedCheckpoint()
	GetWhitelistedMilestone() (bool, uint64, common.Hash)
	PurgeWhitelistedMilestone()

	// Witness related APIs
	GetWitnesses(ctx context.Context, originBlock uint64, totalBlocks uint64) ([]*stateless.Witness, error)
	StoreWitness(ctx context.Context, blockHash common.Hash, witness *stateless.Witness) error
	WitnessByNumber(ctx context.Context, number rpc.BlockNumber) (*stateless.Witness, error)
	WitnessByHash(ctx context.Context, hash common.Hash) (*stateless.Witness, error)
	WitnessByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*stateless.Witness, error)

	// Networking related APIs
	PeerStats() interface{}

	CurrentView() *filtermaps.ChainView
	NewMatcherBackend() filtermaps.MatcherBackend

	// TODO: remove once we stop relying on previous headers for state sync
	// IsParallelImportActive returns true if parallel stateless import is currently active
	IsParallelImportActive() bool

	// Mining related APIs
	Etherbase() (common.Address, error)
	Hashrate() (uint64, error)
	Mining() (bool, error)
	GetWork() ([4]string, error)
	SubmitWork(nonce types.BlockNonce, hash, digest common.Hash) (bool, error)
	SubmitHashrate(rate hexutil.Uint64, id common.Hash) (bool, error)
}

Backend interface provides the common API services (that are provided by both full and light clients) with access to necessary functions.

type BlockChainAPI

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

BlockChainAPI provides an API to access Ethereum blockchain data.

func NewBlockChainAPI

func NewBlockChainAPI(b Backend) *BlockChainAPI

NewBlockChainAPI creates a new Ethereum blockchain API.

func (*BlockChainAPI) BlockNumber

func (api *BlockChainAPI) BlockNumber() hexutil.Uint64

BlockNumber returns the block number of the chain head.

func (*BlockChainAPI) Call

func (api *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, overrides *override.StateOverride, blockOverrides *override.BlockOverrides) (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) CallWithState

func (api *BlockChainAPI) CallWithState(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, state *state.StateDB, overrides *override.StateOverride, blockOverrides *override.BlockOverrides) (hexutil.Bytes, error)

CallWithState executes the given transaction on the given state for the given block number. Note that as it does an EVM call, fields in the underlying state will change. Make sure to handle it outside of this function (ideally by sending a copy of state).

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

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

func (api *BlockChainAPI) Config(ctx context.Context) (*configResponse, error)

func (*BlockChainAPI) CreateAccessList

func (api *BlockChainAPI) CreateAccessList(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, stateOverrides *override.StateOverride) (*accessListResult, error)

CreateAccessList creates an EIP-2930 type AccessList for the given transaction. Reexec and BlockNrOrHash can be specified to create the accessList on top of a certain state. StateOverrides can be used to create the accessList while taking into account state changes from previous transactions.

func (*BlockChainAPI) EstimateGas

func (api *BlockChainAPI) EstimateGas(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, overrides *override.StateOverride, blockOverrides *override.BlockOverrides) (hexutil.Uint64, error)

EstimateGas returns the lowest possible gas limit that allows the transaction to run successfully at block `blockNrOrHash`, or the latest block if `blockNrOrHash` is unspecified. It returns error if the transaction would revert or if there are unexpected failures. The returned value is capped by both `args.Gas` (if non-nil & non-zero) and the backend's RPCGasCap configuration (if non-zero). Note: Required blob gas is not computed in this method.

func (*BlockChainAPI) GetBalance

func (api *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

func (api *BlockChainAPI) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool, borExtra *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. When borExtra is true, the response includes parsed block extra data. This parameter is optional.

func (*BlockChainAPI) GetBlockByNumber

func (api *BlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool, borExtra *bool) (map[string]interface{}, error)

GetBlockByNumber returns the requested canonical block.

  • When number is -1 the chain pending block is returned.
  • When number is -2 the chain latest block is returned.
  • When number is -3 the chain finalized block is returned.
  • When number is -4 the chain safe block is returned.
  • When fullTx is true all transactions in the block are returned, otherwise only the transaction hash is returned.
  • When borExtra is true, the response includes a "decodedExtra" object with parsed EIP-1559 gas parameters and transaction dependency metadata from the block header's Extra field. This parameter is optional.

func (*BlockChainAPI) GetBlockReceipts

func (api *BlockChainAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]map[string]interface{}, error)

GetBlockReceipts returns the block receipts for the given block hash or number or tag.

func (*BlockChainAPI) GetBorBlockReceipt

func (api *BlockChainAPI) GetBorBlockReceipt(ctx context.Context, hash common.Hash) (*types.Receipt, error)

func (*BlockChainAPI) GetCode

func (api *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

func (api *BlockChainAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) map[string]interface{}

GetHeaderByHash returns the requested header by hash.

func (*BlockChainAPI) GetHeaderByNumber

func (api *BlockChainAPI) GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (map[string]interface{}, error)

GetHeaderByNumber returns the requested canonical block header.

  • When number is -1 the chain pending header is returned.
  • When number is -2 the chain latest header is returned.
  • When number is -3 the chain finalized header is returned.
  • When number is -4 the chain safe header is returned.

func (*BlockChainAPI) GetProof

func (api *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) GetRootHash

func (api *BlockChainAPI) GetRootHash(ctx context.Context, starBlockNr uint64, endBlockNr uint64) (string, error)

GetRootHash returns root hash for a given start and end block

func (*BlockChainAPI) GetStorageAt

func (api *BlockChainAPI) GetStorageAt(ctx context.Context, address common.Address, hexKey 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) GetTdByHash

func (api *BlockChainAPI) GetTdByHash(ctx context.Context, hash common.Hash) map[string]interface{}

GetTdByHash returns a map containing the total difficulty (hex-encoded) for the given block hash.

func (*BlockChainAPI) GetTdByNumber

func (api *BlockChainAPI) GetTdByNumber(ctx context.Context, blockNr rpc.BlockNumber) map[string]interface{}

GetTdByNumber returns a map containing the total difficulty (hex-encoded) for the given block number.

func (*BlockChainAPI) GetUncleByBlockHashAndIndex

func (api *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

func (api *BlockChainAPI) GetUncleByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (map[string]interface{}, error)

GetUncleByBlockNumberAndIndex returns the uncle block for the given block hash and index.

func (*BlockChainAPI) GetUncleCountByBlockHash

func (api *BlockChainAPI) GetUncleCountByBlockHash(ctx context.Context, blockHash common.Hash) (*hexutil.Uint, error)

GetUncleCountByBlockHash returns number of uncles in the block for the given block hash

func (*BlockChainAPI) GetUncleCountByBlockNumber

func (api *BlockChainAPI) GetUncleCountByBlockNumber(ctx context.Context, blockNr rpc.BlockNumber) (*hexutil.Uint, error)

GetUncleCountByBlockNumber returns number of uncles in the block for the given block number

func (*BlockChainAPI) GetVoteOnHash

func (api *BlockChainAPI) GetVoteOnHash(ctx context.Context, starBlockNr uint64, endBlockNr uint64, hash string, milestoneId string) (bool, error)

func (*BlockChainAPI) SimulateV1

func (api *BlockChainAPI) SimulateV1(ctx context.Context, opts simOpts, blockNrOrHash *rpc.BlockNumberOrHash) ([]*simBlockResult, error)

SimulateV1 executes series of transactions on top of a base state. The transactions are packed into blocks. For each block, block header fields can be overridden. The state can also be overridden prior to execution of each block.

Note, this function doesn't make any changes in the state/blockchain and is useful to execute and retrieve values.

type BlockGasParamsResult

type BlockGasParamsResult struct {
	GasTarget                *hexutil.Uint64 `json:"gasTarget"`
	BaseFeeChangeDenominator *hexutil.Uint64 `json:"baseFeeChangeDenominator"`
}

BlockGasParamsResult contains the EIP-1559 gas parameters stored in a block header.

type BorAPI

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

BorAPI provides an API to access Bor related information.

func NewBorAPI

func NewBorAPI(b Backend) *BorAPI

NewBorAPI creates a new Bor protocol API.

func (*BorAPI) BlockNumber

func (api *BorAPI) BlockNumber(ctx context.Context, blockNrPtr *rpc.BlockNumber) (hexutil.Uint64, error)

BlockNumber returns the block number for the given block tag: - nil input → latest executed (CurrentBlock) - "latest" → the latest head (CurrentHeader) - "pending" → latest executed (CurrentBlock) - "earliest" → 0 - "safe" → safe block - "finalized" → finalized block - numeric (>=0) → that block number - unknown negative → latest executed (CurrentBlock)

Parameters:

  • blockNrPtr: Optional block number or tag If nil, returns the latest executed block number

Returns the block number as hexutil.Uint64

func (*BorAPI) Forks

func (api *BorAPI) Forks(ctx context.Context) (Forks, error)

Forks implements bor_forks. Returns the genesis block hash and a sorted list of all forks block numbers.

Returns:

  • GenesisHash: The hash of the genesis block
  • HeightForks: Sorted list of all block number forks
  • TimeForks: Sorted list of all timestamp forks

func (*BorAPI) GetBalanceChangesInBlock

func (api *BorAPI) GetBalanceChangesInBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (map[common.Address]*hexutil.Big, error)

GetBalanceChangesInBlock returns balance changes for accounts affected by the block. This method uses a heuristic approach to discover changed accounts by examining:

  • Transaction senders and recipients
  • Contract creation addresses
  • Miner/coinbase address
  • Addresses appearing in transaction logs

Unlike Erigon's temporal-database approach that scans account history changes for the block's transaction range, this may miss some accounts with balance changes from:

  • Internal CALL value transfers to addresses not emitting logs
  • SELFDESTRUCT operations to recipients not otherwise tracked
  • Other EVM operations that modify balances without explicit tracking

Parameters:

  • blockNrOrHash: Block number, hash, or tag (latest, earliest, pending, safe, finalized)

Returns a map of addresses to their post-block balances (only for discovered accounts).

func (*BorAPI) GetBlockByTimestamp

func (api *BorAPI) GetBlockByTimestamp(ctx context.Context, timestamp rpc.Timestamp, fullTx bool) (map[string]interface{}, error)

GetBlockByTimestamp returns the first block with a timestamp greater than or equal to the given timestamp.

Parameters:

  • timestamp: Unix timestamp in seconds (accepts both hex strings and decimal numbers)
  • fullTx: If true, returns full transaction objects; if false, only transaction hashes

Returns the block in RPC format, or nil if not found.

func (*BorAPI) GetBlockGasParams

func (api *BorAPI) GetBlockGasParams(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*BlockGasParamsResult, error)

GetBlockGasParams returns the EIP-1559 gas target and base fee change denominator stored in the block header's extra field. Only available for post-Giugliano blocks.

func (*BorAPI) GetBlockReceiptsByBlockHash

func (api *BorAPI) GetBlockReceiptsByBlockHash(ctx context.Context, blockHash common.Hash) ([]map[string]interface{}, error)

GetBlockReceiptsByBlockHash returns all transaction receipts for a block by hash.

Parameters:

  • blockHash: canonical block hash

Returns an array of marshaled receipts, or error if the block is not found

func (*BorAPI) GetHeaderByHash

func (api *BorAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

GetHeaderByHash returns a block's header by hash. It retrieves the header without transactions.

Parameters:

  • hash: Block hash

Returns the block header or error if not found

func (*BorAPI) GetHeaderByNumber

func (api *BorAPI) GetHeaderByNumber(ctx context.Context, blockNumber rpc.BlockNumber) (*types.Header, error)

GetHeaderByNumber returns a block's header by number. It retrieves the header, without transactions.

Parameters:

  • blockNumber: Block number tag (latest, earliest, pending, safe, finalized, or numeric)

Returns the block header or error if not found

func (*BorAPI) GetLatestLogs

func (api *BorAPI) GetLatestLogs(ctx context.Context, crit FilterCriteria, logOptions LogFilterOptions) ([]*types.Log, error)

GetLatestLogs returns the latest N logs matching the filter criteria in descending order.

Parameters:

  • crit: Standard log filter criteria (addresses, topics, from/to blocks)
  • logOptions: Pagination and filtering options
  • LogCount: Max number of logs to return
  • BlockCount: Max number of blocks to scan
  • IgnoreTopicsOrder: Match topics in any order instead of positional matching

Note: LogCount and BlockCount are mutually exclusive. If both are 0, defaults to BlockCount=1.

Returns logs in descending order (latest first) with BlockTimestamp populated.

func (*BorAPI) GetLogs

func (api *BorAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]*types.Log, error)

GetLogs returns all logs matching the filter criteria.

Parameters:

  • crit: Standard log filter criteria (addresses, topics, from/to blocks, or specific block hash)

Returns logs in ascending order (earliest first) with BlockTimestamp populated.

func (*BorAPI) GetLogsByHash

func (api *BorAPI) GetLogsByHash(ctx context.Context, hash common.Hash) ([][]*types.Log, error)

GetLogsByHash returns the logs generated by the transactions by the block's hash.

Parameters:

  • hash: Block hash

Returns an array where each element is the logs array for the corresponding transaction in the block. Returns nil if the block is not found.

func (*BorAPI) GetVoteOnHash

func (api *BorAPI) GetVoteOnHash(ctx context.Context, starBlockNr uint64, endBlockNr uint64, hash string, milestoneId string) (bool, error)

func (*BorAPI) GetWitnessByBlockNumberOrHash

func (api *BorAPI) GetWitnessByBlockNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (map[string]interface{}, error)

GetWitnessByBlockNumberOrHash returns the witness for the given block number or hash.

func (*BorAPI) GetWitnessByHash

func (api *BorAPI) GetWitnessByHash(ctx context.Context, hash common.Hash) (map[string]interface{}, error)

GetWitnessByHash returns the witness for the given block hash.

func (*BorAPI) GetWitnessByNumber

func (api *BorAPI) GetWitnessByNumber(ctx context.Context, number rpc.BlockNumber) (map[string]interface{}, error)

GetWitnessByNumber returns the witness for the given block number.

func (*BorAPI) SendRawTransactionConditional

func (api *BorAPI) SendRawTransactionConditional(ctx context.Context, input hexutil.Bytes, options types.OptionsPIP15) (common.Hash, error)

SendRawTransactionConditional will add the signed transaction to the transaction pool. The sender/bundler is responsible for signing the transaction

type ChainContext

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

ChainContext is an implementation of core.ChainContext. It's main use-case is instantiating a vm.BlockContext without having access to the BlockChain object.

func NewChainContext

func NewChainContext(ctx context.Context, backend ChainContextBackend) *ChainContext

NewChainContext creates a new ChainContext object.

func (*ChainContext) Config

func (context *ChainContext) Config() *params.ChainConfig

func (*ChainContext) CurrentHeader

func (context *ChainContext) CurrentHeader() *types.Header

func (*ChainContext) Engine

func (context *ChainContext) Engine() consensus.Engine

func (*ChainContext) GetHeader

func (context *ChainContext) GetHeader(hash common.Hash, number uint64) *types.Header

func (*ChainContext) GetHeaderByHash

func (context *ChainContext) GetHeaderByHash(hash common.Hash) *types.Header

func (*ChainContext) GetHeaderByNumber

func (context *ChainContext) GetHeaderByNumber(number uint64) *types.Header

func (*ChainContext) GetTd

func (context *ChainContext) GetTd(hash common.Hash, number uint64) *big.Int

TODO: Implement GetTd

type ChainContextBackend

type ChainContextBackend interface {
	Engine() consensus.Engine
	HeaderByNumber(context.Context, rpc.BlockNumber) (*types.Header, error)
	HeaderByHash(context.Context, common.Hash) (*types.Header, error)
	CurrentHeader() *types.Header
	ChainConfig() *params.ChainConfig
}

ChainContextBackend provides methods required to implement ChainContext.

type DebugAPI

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

DebugAPI is the collection of Ethereum APIs exposed over the debugging namespace.

func NewDebugAPI

func NewDebugAPI(b Backend) *DebugAPI

NewDebugAPI creates a new instance of DebugAPI.

func (*DebugAPI) AccountAt

func (api *DebugAPI) AccountAt(ctx context.Context, blockHash common.Hash, txIndex uint64, address common.Address) (*DebugAccountResult, error)

AccountAt returns the state of an account at a specific point during block execution, specifically after executing the transaction at the given index.

func (*DebugAPI) ChaindbCompact

func (api *DebugAPI) ChaindbCompact() error

ChaindbCompact flattens the entire key-value database into a single level, removing all unused slots and merging all keys.

func (*DebugAPI) ChaindbProperty

func (api *DebugAPI) ChaindbProperty() (string, error)

ChaindbProperty returns leveldb properties of the key-value database.

func (*DebugAPI) DbAncient

func (api *DebugAPI) DbAncient(kind string, number uint64) (hexutil.Bytes, error)

DbAncient retrieves an ancient binary blob from the append-only immutable files. It is a mapping to the `AncientReaderOp.Ancient` method

func (*DebugAPI) DbAncients

func (api *DebugAPI) DbAncients() (uint64, error)

DbAncients returns the ancient item numbers in the ancient store. It is a mapping to the `AncientReaderOp.Ancients` method

func (*DebugAPI) DbGet

func (api *DebugAPI) DbGet(key string) (hexutil.Bytes, error)

DbGet returns the raw value of a key stored in the database.

func (*DebugAPI) GetRawBlock

func (api *DebugAPI) GetRawBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetRawBlock retrieves the RLP encoded for a single block.

func (*DebugAPI) GetRawHeader

func (api *DebugAPI) GetRawHeader(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetRawHeader retrieves the RLP encoding for a single header.

func (*DebugAPI) GetRawReceipts

func (api *DebugAPI) GetRawReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]hexutil.Bytes, error)

GetRawReceipts retrieves the binary-encoded receipts of a single block.

func (*DebugAPI) GetRawTransaction

func (api *DebugAPI) GetRawTransaction(_ context.Context, hash common.Hash) (hexutil.Bytes, error)

GetRawTransaction returns the bytes of the transaction for the given hash.

func (*DebugAPI) GetTraceStack

func (api *DebugAPI) GetTraceStack() string

GetTraceStack returns the current trace stack

func (*DebugAPI) PeerStats

func (api *DebugAPI) PeerStats() interface{}

PeerStats returns the current head height and td of all the connected peers along with few additional identifiers.

func (*DebugAPI) PrintBlock

func (api *DebugAPI) PrintBlock(ctx context.Context, number uint64) (string, error)

PrintBlock retrieves a block and returns its pretty printed form.

func (*DebugAPI) SetHead

func (api *DebugAPI) SetHead(number hexutil.Uint64) error

SetHead rewinds the head of the blockchain to a previous block.

type DebugAccountResult

type DebugAccountResult struct {
	Balance  hexutil.Big    `json:"balance"`
	Nonce    hexutil.Uint64 `json:"nonce"`
	Code     hexutil.Bytes  `json:"code"`
	CodeHash common.Hash    `json:"codeHash"`
}

DebugAccountResult is the result struct for debug_accountAt

type EthereumAPI

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

EthereumAPI provides an API to access Ethereum related information.

func NewEthereumAPI

func NewEthereumAPI(b Backend) *EthereumAPI

NewEthereumAPI creates a new Ethereum protocol API.

func (*EthereumAPI) BlobBaseFee

func (api *EthereumAPI) BlobBaseFee(ctx context.Context) *hexutil.Big

BlobBaseFee returns the base fee for blob gas at the current head.

func (*EthereumAPI) Coinbase

func (api *EthereumAPI) Coinbase() (common.Address, error)

Coinbase returns the current client coinbase address.

func (*EthereumAPI) FeeHistory

func (api *EthereumAPI) FeeHistory(ctx context.Context, blockCount math.HexOrDecimal64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*feeHistoryResult, error)

FeeHistory returns the fee market history.

func (*EthereumAPI) GasPrice

func (api *EthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error)

GasPrice returns a suggestion for a gas price for legacy transactions.

func (*EthereumAPI) GetWork

func (api *EthereumAPI) GetWork() ([4]string, error)

GetWork returns a work package for external miners.

The work package consists of 3 strings:

result[0] - 32 bytes hex encoded current block header pow-hash
result[1] - 32 bytes hex encoded seed hash used for DAG
result[2] - 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty
result[3] - hex encoded block number

Returns JSON-RPC error -32000 if mining is not supported

func (*EthereumAPI) Hashrate

func (api *EthereumAPI) Hashrate() (hexutil.Uint64, error)

Hashrate returns the POW hashrate.

func (*EthereumAPI) MaxPriorityFeePerGas

func (api *EthereumAPI) MaxPriorityFeePerGas(ctx context.Context) (*hexutil.Big, error)

MaxPriorityFeePerGas returns a suggestion for a gas tip cap for dynamic fee transactions.

func (*EthereumAPI) Mining

func (api *EthereumAPI) Mining() (bool, error)

Mining returns an indication if this node is currently mining.

func (*EthereumAPI) ProtocolVersion

func (api *EthereumAPI) ProtocolVersion() hexutil.Uint

ProtocolVersion returns the current Ethereum protocol version.

func (*EthereumAPI) SubmitHashrate

func (api *EthereumAPI) SubmitHashrate(rate hexutil.Uint64, id common.Hash) (bool, error)

SubmitHashrate can be used for remote miners to submit their hash rate. Returns JSON-RPC error -32000 if mining not supported

func (*EthereumAPI) SubmitWork

func (api *EthereumAPI) SubmitWork(nonce types.BlockNonce, hash, digest common.Hash) (bool, error)

SubmitWork can be used by external miners to submit their POW solution. It returns an indication if the work was accepted. Returns JSON-RPC error -32000 if mining not supported

func (*EthereumAPI) Syncing

func (api *EthereumAPI) Syncing(ctx context.Context) (interface{}, error)

Syncing returns false in case the node is currently not syncing with the network. It can be up-to-date or has not yet received the latest block headers from its peers. In case it is synchronizing: - startingBlock: block number this node started to synchronize from - currentBlock: block number this node is currently importing - highestBlock: block number of the highest block header this node has received from peers - pulledStates: number of state entries processed until now - knownStates: number of known state entries that still need to be pulled

type EthereumAccountAPI

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

func NewEthereumAccountAPI(am *accounts.Manager) *EthereumAccountAPI

NewEthereumAccountAPI creates a new EthereumAccountAPI.

func (*EthereumAccountAPI) Accounts

func (api *EthereumAccountAPI) Accounts() []common.Address

Accounts returns the collection of accounts this node manages.

type FilterCriteria

type FilterCriteria ethereum.FilterQuery

FilterCriteria represents a request to filter logs. This is the same as ethereum.FilterQuery but with proper JSON unmarshaling that handles the RPC-standard "address" field (singular) and validates mutually exclusive fields.

func (*FilterCriteria) UnmarshalJSON

func (fc *FilterCriteria) UnmarshalJSON(data []byte) error

UnmarshalJSON parses JSON log filter criteria. Handles: - "address" field (singular) that accepts both single string and array - Validates blockHash is mutually exclusive with fromBlock/toBlock - Converts rpc.BlockNumber to *big.Int

type Forks

type Forks struct {
	GenesisHash common.Hash `json:"genesis"`
	HeightForks []uint64    `json:"heightForks"`
	TimeForks   []uint64    `json:"timeForks"`
}

Forks is a data type to record a list of forks

type LogFilterOptions

type LogFilterOptions struct {
	LogCount          *uint64 `json:"logCount,omitempty"`          // Max number of logs to return
	BlockCount        *uint64 `json:"blockCount,omitempty"`        // Max number of blocks to scan
	IgnoreTopicsOrder bool    `json:"ignoreTopicsOrder,omitempty"` // Match topics in any order
}

LogFilterOptions specifies options for GetLatestLogs

type NetAPI

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

NetAPI offers network related RPC methods

func NewNetAPI

func NewNetAPI(net *p2p.Server, networkVersion uint64) *NetAPI

NewNetAPI creates a new net API instance.

func (*NetAPI) Listening

func (api *NetAPI) Listening() bool

Listening returns an indication if the node is listening for network connections.

func (*NetAPI) PeerCount

func (api *NetAPI) PeerCount() hexutil.Uint

PeerCount returns the number of connected peers

func (*NetAPI) Version

func (api *NetAPI) Version() string

Version returns the current ethereum protocol version.

type OverrideAccount

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"`
	MovePrecompileTo *common.Address             `json:"movePrecompileToAddress"`
}

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 stateDiff is set, all diff will be applied first and then execute the call message.

type RPCBlockExtraData

type RPCBlockExtraData struct {
	GasTarget                *hexutil.Uint64 `json:"gasTarget"`
	BaseFeeChangeDenominator *hexutil.Uint64 `json:"baseFeeChangeDenominator"`
	TxDependency             [][]uint64      `json:"txDependency"`
}

RPCBlockExtraData contains the parsed fields from the block header's Extra field. Only populated for post-Cancun blocks that use RLP-encoded BlockExtraData.

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"`
	MaxFeePerBlobGas    *hexutil.Big                 `json:"maxFeePerBlobGas,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"`
	BlobVersionedHashes []common.Hash                `json:"blobVersionedHashes,omitempty"`
	AuthorizationList   []types.SetCodeAuthorization `json:"authorizationList,omitempty"`
	V                   *hexutil.Big                 `json:"v"`
	R                   *hexutil.Big                 `json:"r"`
	S                   *hexutil.Big                 `json:"s"`
	YParity             *hexutil.Uint64              `json:"yParity,omitempty"`
}

RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction

func NewRPCPendingTransaction

func NewRPCPendingTransaction(tx *types.Transaction, current *types.Header, config *params.ChainConfig) *RPCTransaction

NewRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation

type SignTransactionResult

type SignTransactionResult struct {
	Raw hexutil.Bytes      `json:"raw"`
	Tx  *types.Transaction `json:"tx"`
}

SignTransactionResult represents a RLP encoded signed transaction.

type StorageResult

type StorageResult struct {
	Key   string       `json:"key"`
	Value *hexutil.Big `json:"value"`
	Proof []string     `json:"proof"`
}

type StructLogRes

type StructLogRes struct {
	Pc      uint64             `json:"pc"`
	Op      string             `json:"op"`
	Gas     uint64             `json:"gas"`
	GasCost uint64             `json:"gasCost"`
	Depth   int                `json:"depth"`
	Error   string             `json:"error,omitempty"`
	Stack   *[]string          `json:"stack,omitempty"`
	Memory  *[]string          `json:"memory,omitempty"`
	Storage *map[string]string `json:"storage,omitempty"`
}

StructLogRes stores a structured log emitted by the EVM while replaying a transaction in debug mode

func FormatLogs

func FormatLogs(logs []logger.StructLog) []StructLogRes

FormatLogs formats EVM returned structured logs for json output

type TransactionAPI

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

TransactionAPI exposes methods for reading and creating transaction data.

func NewTransactionAPI

func NewTransactionAPI(b Backend, nonceLock *AddrLocker) *TransactionAPI

NewTransactionAPI creates a new RPC service with methods for interacting with transactions.

func (*TransactionAPI) CheckPreconfStatus

func (api *TransactionAPI) CheckPreconfStatus(ctx context.Context, hash common.Hash) (bool, error)

func (*TransactionAPI) FillTransaction

func (api *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

func (api *TransactionAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) (*hexutil.Uint, error)

GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash.

func (*TransactionAPI) GetBlockTransactionCountByNumber

func (api *TransactionAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*hexutil.Uint, error)

GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number.

func (*TransactionAPI) GetRawTransactionByBlockHashAndIndex

func (api *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

func (api *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

func (api *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

func (api *TransactionAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (*RPCTransaction, error)

GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index.

func (*TransactionAPI) GetTransactionByBlockNumberAndIndex

func (api *TransactionAPI) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (*RPCTransaction, error)

GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index.

func (*TransactionAPI) GetTransactionByHash

func (api *TransactionAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error)

GetTransactionByHash returns the transaction for the given hash

func (*TransactionAPI) GetTransactionCount

func (api *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

func (api *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

func (api *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

func (api *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.

This API is not capable for submitting blob transaction with sidecar.

func (*TransactionAPI) SendRawTransaction

func (api *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) SendRawTransactionForPreconf

func (api *TransactionAPI) SendRawTransactionForPreconf(ctx context.Context, input hexutil.Bytes) (map[string]interface{}, error)

SendRawTransactionForPreconf will accept a preconf transaction from relay if enabled. It will offer a soft inclusion confirmation if the transaction is accepted into the pending pool.

func (*TransactionAPI) SendRawTransactionPrivate

func (api *TransactionAPI) SendRawTransactionPrivate(ctx context.Context, input hexutil.Bytes) (common.Hash, error)

SendRawTransactionForPreconf will accept a private transaction from relay if enabled. It will ensure that the transaction is not gossiped over public network.

func (*TransactionAPI) SendRawTransactionSync

func (api *TransactionAPI) SendRawTransactionSync(ctx context.Context, input hexutil.Bytes, timeoutMs *hexutil.Uint64) (map[string]interface{}, error)

SendRawTransactionSync will add the signed transaction to the transaction pool and wait until the transaction has been included in a block and return the receipt, or the timeout.

func (*TransactionAPI) SendTransaction

func (api *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.

This API is not capable for submitting blob transaction with sidecar.

func (*TransactionAPI) Sign

func (api *TransactionAPI) Sign(addr common.Address, data hexutil.Bytes) (hexutil.Bytes, error)

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.

https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign

func (*TransactionAPI) SignTransaction

func (api *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

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/tenderly/polygon-bor/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"`

	// For BlobTxType
	BlobFeeCap *hexutil.Big  `json:"maxFeePerBlobGas"`
	BlobHashes []common.Hash `json:"blobVersionedHashes,omitempty"`

	// For BlobTxType transactions with blob sidecar
	Blobs       []kzg4844.Blob       `json:"blobs"`
	Commitments []kzg4844.Commitment `json:"commitments"`
	Proofs      []kzg4844.Proof      `json:"proofs"`

	// For SetCodeTxType
	AuthorizationList []types.SetCodeAuthorization `json:"authorizationList"`
}

TransactionArgs represents the arguments to construct a new transaction or a message call.

func (*TransactionArgs) CallDefaults

func (args *TransactionArgs) CallDefaults(globalGasCap uint64, baseFee *big.Int, chainID *big.Int) error

CallDefaults sanitizes the transaction arguments, often filling in zero values, for the purpose of eth_call class of RPC methods.

func (*TransactionArgs) IsEIP4844

func (args *TransactionArgs) IsEIP4844() bool

IsEIP4844 returns an indicator if the args contains EIP4844 fields.

func (*TransactionArgs) ToMessage

func (args *TransactionArgs) ToMessage(baseFee *big.Int, skipNonceCheck bool) *core.Message

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. Assumes that fields are not nil, i.e. setDefaults or CallDefaults has been called.

func (*TransactionArgs) ToTransaction

func (args *TransactionArgs) ToTransaction(defaultType int) *types.Transaction

ToTransaction converts the arguments to a transaction. This assumes that setDefaults has been called.

type TxIndexingError

type TxIndexingError struct{}

TxIndexingError is an API error that indicates the transaction indexing is not fully finished yet with JSON error code and a binary data blob.

func NewTxIndexingError

func NewTxIndexingError() *TxIndexingError

NewTxIndexingError creates a TxIndexingError instance.

func (*TxIndexingError) Error

func (e *TxIndexingError) Error() string

Error implement error interface, returning the error message.

func (*TxIndexingError) ErrorCode

func (e *TxIndexingError) ErrorCode() int

ErrorCode returns the JSON error code for a revert. See: https://ethereum.org/en/developers/docs/apis/json-rpc/#error-codes

func (*TxIndexingError) ErrorData

func (e *TxIndexingError) ErrorData() interface{}

ErrorData returns the hex encoded revert reason.

type TxPoolAPI

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

func NewTxPoolAPI(b Backend) *TxPoolAPI

NewTxPoolAPI creates a new tx pool service that gives information about the transaction pool.

func (*TxPoolAPI) Content

func (api *TxPoolAPI) Content() map[string]map[string]map[string]*RPCTransaction

Content returns the transactions contained within the transaction pool.

func (*TxPoolAPI) ContentFrom

func (api *TxPoolAPI) ContentFrom(addr common.Address) map[string]map[string]*RPCTransaction

ContentFrom returns the transactions contained within the transaction pool.

func (*TxPoolAPI) Inspect

func (api *TxPoolAPI) Inspect() map[string]map[string]map[string]string

Inspect retrieves the content of the transaction pool and flattens it into an easily inspectable list.

func (*TxPoolAPI) Status

func (api *TxPoolAPI) Status() map[string]hexutil.Uint

Status returns the number of pending and queued transaction in the pool.

func (*TxPoolAPI) TxStatus

func (api *TxPoolAPI) TxStatus(hash common.Hash) txpool.TxStatus

TxStatus returns the current status of a transaction in the pool given transaction hash. Returns - 0 if status is unknown. - 1 if status is queued. - 2 if status is pending. Note that because it only checks in txpool, it doesn't return 'included' status.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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