rpc

package
v0.10.33 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnvilContainer

type AnvilContainer struct {
	testcontainers.Container
	URL string
}

func StartAnvil

func StartAnvil(params []string) (*AnvilContainer, error)

type BlockResponse

type BlockResponse struct {
	Jsonrpc string        `json:"jsonrpc"`
	ID      int           `json:"id"`
	Result  *types.Header `json:"result"`
}

type CurrentBlockResponse

type CurrentBlockResponse struct {
	Result string `json:"result"`
}

type GethContainer

type GethContainer struct {
	testcontainers.Container
	URL string
}

type RPCClient

type RPCClient struct {
	URL string
	// contains filtered or unexported fields
}

RPCClient is an RPC client for various node simulators API Reference https://book.getfoundry.sh/reference/anvil/ TODO: fix in next PRs nolint

func New

func New(url string, headers http.Header) *RPCClient

New creates new RPC client that can be used with Geth or Anvil this is a high level wrapper for common calls we use

func (*RPCClient) AnvilAutoImpersonate

func (m *RPCClient) AnvilAutoImpersonate(b bool) error

AnvilAutoImpersonate sets auto impersonification to true or false

func (*RPCClient) AnvilDropTransaction

func (m *RPCClient) AnvilDropTransaction(params []interface{}) error

AnvilDropTransaction removes transaction from tx pool API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilMine

func (m *RPCClient) AnvilMine(params []interface{}) error

AnvilMine calls "evm_mine", mines one or more blocks, see the reference on RPCClient API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilSetAutoMine

func (m *RPCClient) AnvilSetAutoMine(flag bool) error

AnvilSetAutoMine calls "evm_setAutomine", turns automatic mining on, see the reference on RPCClient API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilSetBlockGasLimit

func (m *RPCClient) AnvilSetBlockGasLimit(params []interface{}) error

AnvilSetBlockGasLimit sets next block gas limit API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilSetMinGasPrice

func (m *RPCClient) AnvilSetMinGasPrice(gas uint64) error

AnvilSetMinGasPrice sets min gas price (pre-EIP-1559 anvil is required) API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilSetNextBlockBaseFeePerGas

func (m *RPCClient) AnvilSetNextBlockBaseFeePerGas(gas *big.Int) error

AnvilSetNextBlockBaseFeePerGas sets next block base fee per gas value API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilSetStorageAt

func (m *RPCClient) AnvilSetStorageAt(params []interface{}) error

AnvilSetStorageAt sets storage at address API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilTxPoolStatus

func (m *RPCClient) AnvilTxPoolStatus(params []interface{}) (*TxStatusResponse, error)

AnvilTxPoolStatus calls "txpool_status", returns txpool status, see the reference on RPCClient API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) BlockNumber

func (m *RPCClient) BlockNumber() (int64, error)

Call "eth_blockNumber" to get the current block number

func (*RPCClient) EVMIncreaseTime

func (m *RPCClient) EVMIncreaseTime(seconds uint64) error

EVMIncreaseTime jumps forward in time by `seconds`. The parameter is a JSON number (in seconds)

func (*RPCClient) GetHeaderByNumber

func (m *RPCClient) GetHeaderByNumber(blockNumber int64) (*types.Header, error)

GetHeaderByNumber retrieves block details by block number this is purely debug method to verify the gas chaos is applied

func (*RPCClient) GethSetHead

func (m *RPCClient) GethSetHead(blocksBack int) error

func (*RPCClient) PrintBlockBaseFee

func (m *RPCClient) PrintBlockBaseFee() error

PrintBlockBaseFee prints block base fee this is purely debug method to verify gas chaos is applied

type RemoteAnvilMiner

type RemoteAnvilMiner struct {
	Client *RPCClient
	// contains filtered or unexported fields
}

RemoteAnvilMiner is a remote miner for Anvil node Allows to control blocks emission more precisely to mimic real networks workload

func NewRemoteAnvilMiner

func NewRemoteAnvilMiner(url string, headers http.Header) *RemoteAnvilMiner

NewRemoteAnvilMiner creates a new remote miner client

func (*RemoteAnvilMiner) MineBatch

func (m *RemoteAnvilMiner) MineBatch(capacity int64, checkInterval time.Duration, sendInterval time.Duration)

MineBatch checks the pending transactions in the pool, if threshold is reached mines the block and repeat the process

func (*RemoteAnvilMiner) MinePeriodically

func (m *RemoteAnvilMiner) MinePeriodically(interval time.Duration)

MinePeriodically mines blocks with a specified interval should be used when Anvil mining is off

func (*RemoteAnvilMiner) Stop

func (m *RemoteAnvilMiner) Stop()

Stop stops the miner

type TxStatusResponse

type TxStatusResponse struct {
	Result struct {
		Pending string `json:"pending"`
	} `json:"result"`
}

TxStatusResponse common RPC response body

Jump to

Keyboard shortcuts

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