Documentation ¶
Overview ¶
Package rpc contains RPC handler methods and utilities to start Ethermint's Web3-compatibly JSON-RPC server.
Index ¶
- func GetRPCAPIs() []rpc.API
- func StartHTTPEndpoint(ctx context.Context, config *Config, apis []rpc.API, timeouts rpc.HTTPTimeouts) (*rpc.Server, error)
- type CallArgs
- type Config
- type PublicEthAPI
- func (e *PublicEthAPI) Accounts() []common.Address
- func (e *PublicEthAPI) BlockNumber() *big.Int
- func (e *PublicEthAPI) Call(args CallArgs, blockNum rpc.BlockNumber) hexutil.Bytes
- func (e *PublicEthAPI) Coinbase() (addr common.Address)
- func (e *PublicEthAPI) EstimateGas(args CallArgs, blockNum rpc.BlockNumber) hexutil.Uint64
- func (e *PublicEthAPI) GasPrice() *hexutil.Big
- func (e *PublicEthAPI) GetBalance(address common.Address, blockNum rpc.BlockNumber) *hexutil.Big
- func (e *PublicEthAPI) GetBlockByHash(hash common.Hash, fullTx bool) map[string]interface{}
- func (e *PublicEthAPI) GetBlockByNumber(blockNum rpc.BlockNumber, fullTx bool) map[string]interface{}
- func (e *PublicEthAPI) GetBlockTransactionCountByHash(hash common.Hash) hexutil.Uint
- func (e *PublicEthAPI) GetBlockTransactionCountByNumber(blockNum rpc.BlockNumber) hexutil.Uint
- func (e *PublicEthAPI) GetCode(address common.Address, blockNumber rpc.BlockNumber) hexutil.Bytes
- func (e *PublicEthAPI) GetStorageAt(address common.Address, key string, blockNum rpc.BlockNumber) hexutil.Bytes
- func (e *PublicEthAPI) GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) *Transaction
- func (e *PublicEthAPI) GetTransactionByBlockNumberAndIndex(blockNumber rpc.BlockNumber, idx hexutil.Uint) *Transaction
- func (e *PublicEthAPI) GetTransactionByHash(hash common.Hash) *Transaction
- func (e *PublicEthAPI) GetTransactionCount(address common.Address, blockNum rpc.BlockNumber) hexutil.Uint64
- func (e *PublicEthAPI) GetTransactionReceipt(hash common.Hash) map[string]interface{}
- func (e *PublicEthAPI) GetUncleByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) map[string]interface{}
- func (e *PublicEthAPI) GetUncleByBlockNumberAndIndex(number hexutil.Uint, idx hexutil.Uint) map[string]interface{}
- func (e *PublicEthAPI) GetUncleCountByBlockHash(hash common.Hash) hexutil.Uint
- func (e *PublicEthAPI) GetUncleCountByBlockNumber(blockNum rpc.BlockNumber) hexutil.Uint
- func (e *PublicEthAPI) Hashrate() hexutil.Uint64
- func (e *PublicEthAPI) Mining() bool
- func (e *PublicEthAPI) ProtocolVersion() string
- func (e *PublicEthAPI) SendRawTransaction(data hexutil.Bytes) common.Hash
- func (e *PublicEthAPI) SendTransaction(args core.SendTxArgs) common.Hash
- func (e *PublicEthAPI) Sign(address common.Address, data hexutil.Bytes) hexutil.Bytes
- func (e *PublicEthAPI) Syncing() interface{}
- type PublicWeb3API
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRPCAPIs ¶
GetRPCAPIs returns the master list of public APIs for use with StartHTTPEndpoint.
func StartHTTPEndpoint ¶
func StartHTTPEndpoint(ctx context.Context, config *Config, apis []rpc.API, timeouts rpc.HTTPTimeouts) (*rpc.Server, error)
StartHTTPEndpoint starts the Tendermint Web3-compatible RPC layer. Consumes a Context for cancellation, a config struct, and a list of rpc.API interfaces that will be automatically wired into a JSON-RPC webserver.
Types ¶
type CallArgs ¶
type CallArgs struct { From common.Address `json:"from"` To common.Address `json:"to"` Gas hexutil.Uint64 `json:"gas"` GasPrice hexutil.Big `json:"gasPrice"` Value hexutil.Big `json:"value"` Data hexutil.Bytes `json:"data"` }
CallArgs represents arguments to a smart contract call as provided by RPC clients.
type Config ¶
type Config struct { // EnableRPC defines whether or not to enable the RPC server EnableRPC bool // RPCAddr defines the IP address to listen on RPCAddr string // RPCPort defines the port to listen on RPCPort int // RPCCORSDomains defines list of domains to enable CORS headers for (used by browsers) RPCCORSDomains []string // RPCVhosts defines list of domains to listen on (useful if Tendermint is addressable via DNS) RPCVHosts []string }
Config contains configuration fields that determine the behavior of the RPC HTTP server.
type PublicEthAPI ¶
type PublicEthAPI struct{}
PublicEthAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.
func NewPublicEthAPI ¶
func NewPublicEthAPI() *PublicEthAPI
NewPublicEthAPI creates an instance of the public ETH Web3 API.
func (*PublicEthAPI) Accounts ¶
func (e *PublicEthAPI) Accounts() []common.Address
Accounts returns the list of accounts available to this node.
func (*PublicEthAPI) BlockNumber ¶
func (e *PublicEthAPI) BlockNumber() *big.Int
BlockNumber returns the current block number.
func (*PublicEthAPI) Call ¶
func (e *PublicEthAPI) Call(args CallArgs, blockNum rpc.BlockNumber) hexutil.Bytes
Call performs a raw contract call.
func (*PublicEthAPI) Coinbase ¶
func (e *PublicEthAPI) Coinbase() (addr common.Address)
Coinbase returns this node's coinbase address. Not used in Ethermint.
func (*PublicEthAPI) EstimateGas ¶
func (e *PublicEthAPI) EstimateGas(args CallArgs, blockNum rpc.BlockNumber) hexutil.Uint64
EstimateGas estimates gas usage for the given smart contract call.
func (*PublicEthAPI) GasPrice ¶
func (e *PublicEthAPI) GasPrice() *hexutil.Big
GasPrice returns the current gas price based on Ethermint's gas price oracle.
func (*PublicEthAPI) GetBalance ¶
func (e *PublicEthAPI) GetBalance(address common.Address, blockNum rpc.BlockNumber) *hexutil.Big
GetBalance returns the provided account's balance up to the provided block number.
func (*PublicEthAPI) GetBlockByHash ¶
func (e *PublicEthAPI) GetBlockByHash(hash common.Hash, fullTx bool) map[string]interface{}
GetBlockByHash returns the block identified by hash.
func (*PublicEthAPI) GetBlockByNumber ¶
func (e *PublicEthAPI) GetBlockByNumber(blockNum rpc.BlockNumber, fullTx bool) map[string]interface{}
GetBlockByNumber returns the block identified by number.
func (*PublicEthAPI) GetBlockTransactionCountByHash ¶
func (e *PublicEthAPI) GetBlockTransactionCountByHash(hash common.Hash) hexutil.Uint
GetBlockTransactionCountByHash returns the number of transactions in the block identified by hash.
func (*PublicEthAPI) GetBlockTransactionCountByNumber ¶
func (e *PublicEthAPI) GetBlockTransactionCountByNumber(blockNum rpc.BlockNumber) hexutil.Uint
GetBlockTransactionCountByNumber returns the number of transactions in the block identified by number.
func (*PublicEthAPI) GetCode ¶
func (e *PublicEthAPI) GetCode(address common.Address, blockNumber rpc.BlockNumber) hexutil.Bytes
GetCode returns the contract code at the given address and block number.
func (*PublicEthAPI) GetStorageAt ¶
func (e *PublicEthAPI) GetStorageAt(address common.Address, key string, blockNum rpc.BlockNumber) hexutil.Bytes
GetStorageAt returns the contract storage at the given address, block number, and key.
func (*PublicEthAPI) GetTransactionByBlockHashAndIndex ¶
func (e *PublicEthAPI) GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) *Transaction
GetTransactionByBlockHashAndIndex returns the transaction identified by hash and index.
func (*PublicEthAPI) GetTransactionByBlockNumberAndIndex ¶
func (e *PublicEthAPI) GetTransactionByBlockNumberAndIndex(blockNumber rpc.BlockNumber, idx hexutil.Uint) *Transaction
GetTransactionByBlockNumberAndIndex returns the transaction identified by number and index.
func (*PublicEthAPI) GetTransactionByHash ¶
func (e *PublicEthAPI) GetTransactionByHash(hash common.Hash) *Transaction
GetTransactionByHash returns the transaction identified by hash.
func (*PublicEthAPI) GetTransactionCount ¶
func (e *PublicEthAPI) GetTransactionCount(address common.Address, blockNum rpc.BlockNumber) hexutil.Uint64
GetTransactionCount returns the number of transactions at the given address up to the given block number.
func (*PublicEthAPI) GetTransactionReceipt ¶
func (e *PublicEthAPI) GetTransactionReceipt(hash common.Hash) map[string]interface{}
GetTransactionReceipt returns the transaction receipt identified by hash.
func (*PublicEthAPI) GetUncleByBlockHashAndIndex ¶
func (e *PublicEthAPI) GetUncleByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) map[string]interface{}
GetUncleByBlockHashAndIndex returns the uncle identified by hash and index. Always returns nil.
func (*PublicEthAPI) GetUncleByBlockNumberAndIndex ¶
func (e *PublicEthAPI) GetUncleByBlockNumberAndIndex(number hexutil.Uint, idx hexutil.Uint) map[string]interface{}
GetUncleByBlockNumberAndIndex returns the uncle identified by number and index. Always returns nil.
func (*PublicEthAPI) GetUncleCountByBlockHash ¶
func (e *PublicEthAPI) GetUncleCountByBlockHash(hash common.Hash) hexutil.Uint
GetUncleCountByBlockHash returns the number of uncles in the block idenfied by hash. Always zero.
func (*PublicEthAPI) GetUncleCountByBlockNumber ¶
func (e *PublicEthAPI) GetUncleCountByBlockNumber(blockNum rpc.BlockNumber) hexutil.Uint
GetUncleCountByBlockNumber returns the number of uncles in the block idenfied by number. Always zero.
func (*PublicEthAPI) Hashrate ¶
func (e *PublicEthAPI) Hashrate() hexutil.Uint64
Hashrate returns the current node's hashrate. Always 0.
func (*PublicEthAPI) Mining ¶
func (e *PublicEthAPI) Mining() bool
Mining returns whether or not this node is currently mining. Always false.
func (*PublicEthAPI) ProtocolVersion ¶
func (e *PublicEthAPI) ProtocolVersion() string
ProtocolVersion returns the supported Ethereum protocol version.
func (*PublicEthAPI) SendRawTransaction ¶
func (e *PublicEthAPI) SendRawTransaction(data hexutil.Bytes) common.Hash
SendRawTransaction send a raw Ethereum transaction.
func (*PublicEthAPI) SendTransaction ¶
func (e *PublicEthAPI) SendTransaction(args core.SendTxArgs) common.Hash
SendTransaction sends an Ethereum transaction.
func (*PublicEthAPI) Sign ¶
Sign signs the provided data using the private key of address via Geth's signature standard.
func (*PublicEthAPI) Syncing ¶
func (e *PublicEthAPI) Syncing() interface{}
Syncing returns whether or not the current node is syncing with other peers. Returns false if not, or a struct outlining the state of the sync if it is.
type PublicWeb3API ¶
type PublicWeb3API struct { }
PublicWeb3API is the web3_ prefixed set of APIs in the Web3 JSON-RPC spec.
func NewPublicWeb3API ¶
func NewPublicWeb3API() *PublicWeb3API
NewPublicWeb3API creates an instance of the Web3 API.
func (*PublicWeb3API) ClientVersion ¶
func (a *PublicWeb3API) ClientVersion() string
ClientVersion returns the client version in the Web3 user agent format.
type Transaction ¶
type Transaction 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"` Hash common.Hash `json:"hash"` Input hexutil.Bytes `json:"input"` Nonce hexutil.Uint64 `json:"nonce"` To *common.Address `json:"to"` TransactionIndex hexutil.Uint `json:"transactionIndex"` Value *hexutil.Big `json:"value"` V *hexutil.Big `json:"v"` R *hexutil.Big `json:"r"` S *hexutil.Big `json:"s"` }
Transaction represents a transaction returned to RPC clients.