Documentation
¶
Overview ¶
Package rpc contains RPC handler methods and utilities to start Ethermint's Web3-compatibly JSON-RPC server.
Index ¶
- Constants
- func EmintServeCmd(cdc *codec.Codec) *cobra.Command
- func EthHeaderFromTendermint(header tmtypes.Header) *ethtypes.Header
- func GetRPCAPIs(cliCtx context.CLIContext, keys []emintcrypto.PrivKeySecp256k1) []rpc.API
- type AccountResult
- type AddrLocker
- type Backend
- type BlockNumber
- type CallArgs
- type ErrorMessageJSON
- type ErrorResponseJSON
- type EthermintBackend
- func (e *EthermintBackend) BlockNumber() (hexutil.Uint64, error)
- func (e *EthermintBackend) BloomStatus() (uint64, uint64)
- func (e *EthermintBackend) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)
- func (e *EthermintBackend) GetBlockByNumber(blockNum BlockNumber, fullTx bool) (map[string]interface{}, error)
- func (e *EthermintBackend) GetLogs(blockHash common.Hash) ([][]*ethtypes.Log, error)
- func (e *EthermintBackend) GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error)
- func (e *EthermintBackend) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error)
- func (e *EthermintBackend) HeaderByNumber(blockNum BlockNumber) (*ethtypes.Header, error)
- func (e *EthermintBackend) PendingTransactions() ([]*Transaction, error)
- type EventSystem
- func (es *EventSystem) SubscribeLogs(crit filters.FilterCriteria) (*Subscription, context.CancelFunc, error)
- func (es EventSystem) SubscribeNewHeads() (*Subscription, context.CancelFunc, error)
- func (es EventSystem) SubscribePendingTxs() (*Subscription, context.CancelFunc, error)
- func (es *EventSystem) WithContext(ctx context.Context)
- type Filter
- type FiltersBackend
- type PersonalEthAPI
- func (e *PersonalEthAPI) EcRecover(_ context.Context, data, sig hexutil.Bytes) (common.Address, error)
- func (e *PersonalEthAPI) ImportRawKey(privkey, password string) (common.Address, error)
- func (e *PersonalEthAPI) ListAccounts() ([]common.Address, error)
- func (e *PersonalEthAPI) LockAccount(address common.Address) bool
- func (e *PersonalEthAPI) NewAccount(password string) (common.Address, error)
- func (e *PersonalEthAPI) SendTransaction(_ context.Context, args params.SendTxArgs, _ string) (common.Hash, error)
- func (e *PersonalEthAPI) Sign(_ context.Context, data hexutil.Bytes, addr common.Address, _ string) (hexutil.Bytes, error)
- func (e *PersonalEthAPI) UnlockAccount(_ context.Context, addr common.Address, password string, _ *uint64) (bool, error)
- type PublicEthAPI
- func (e *PublicEthAPI) Accounts() ([]common.Address, error)
- func (e *PublicEthAPI) BlockNumber() (hexutil.Uint64, error)
- func (e *PublicEthAPI) Call(args CallArgs, blockNr BlockNumber, _ *map[common.Address]account) (hexutil.Bytes, error)
- func (e *PublicEthAPI) ChainId() (hexutil.Uint, error)
- func (e *PublicEthAPI) Coinbase() (common.Address, error)
- func (e *PublicEthAPI) EstimateGas(args CallArgs) (hexutil.Uint64, error)
- func (e *PublicEthAPI) ExportAccount(address common.Address, blockNumber BlockNumber) (string, error)
- func (e *PublicEthAPI) GasPrice() *hexutil.Big
- func (e *PublicEthAPI) GetBalance(address common.Address, blockNum BlockNumber) (*hexutil.Big, error)
- func (e *PublicEthAPI) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)
- func (e *PublicEthAPI) GetBlockByNumber(blockNum BlockNumber, fullTx bool) (map[string]interface{}, error)
- func (e *PublicEthAPI) GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Uint
- func (e *PublicEthAPI) GetBlockTransactionCountByNumber(blockNum BlockNumber) *hexutil.Uint
- func (e *PublicEthAPI) GetCode(address common.Address, blockNumber BlockNumber) (hexutil.Bytes, error)
- func (e *PublicEthAPI) GetProof(address common.Address, storageKeys []string, block BlockNumber) (*AccountResult, error)
- func (e *PublicEthAPI) GetStorageAt(address common.Address, key string, blockNum BlockNumber) (hexutil.Bytes, error)
- func (e *PublicEthAPI) GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) (*Transaction, error)
- func (e *PublicEthAPI) GetTransactionByBlockNumberAndIndex(blockNum BlockNumber, idx hexutil.Uint) (*Transaction, error)
- func (e *PublicEthAPI) GetTransactionByHash(hash common.Hash) (*Transaction, error)
- func (e *PublicEthAPI) GetTransactionCount(address common.Address, blockNum BlockNumber) (*hexutil.Uint64, error)
- func (e *PublicEthAPI) GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error)
- func (e *PublicEthAPI) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error)
- 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 BlockNumber) hexutil.Uint
- func (e *PublicEthAPI) Hashrate() hexutil.Uint64
- func (e *PublicEthAPI) Mining() bool
- func (e *PublicEthAPI) PendingTransactions() ([]*Transaction, error)
- func (e *PublicEthAPI) ProtocolVersion() hexutil.Uint
- func (e *PublicEthAPI) SendRawTransaction(data hexutil.Bytes) (common.Hash, error)
- func (e *PublicEthAPI) SendTransaction(args params.SendTxArgs) (common.Hash, error)
- func (e *PublicEthAPI) Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error)
- func (e *PublicEthAPI) Syncing() (interface{}, error)
- type PublicFilterAPI
- func (api *PublicFilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error)
- func (api *PublicFilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*ethtypes.Log, error)
- func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit filters.FilterCriteria) ([]*ethtypes.Log, error)
- func (api *PublicFilterAPI) Logs(ctx context.Context, crit filters.FilterCriteria) (*rpc.Subscription, error)
- func (api *PublicFilterAPI) NewBlockFilter() rpc.ID
- func (api *PublicFilterAPI) NewFilter(criteria filters.FilterCriteria) (rpc.ID, error)
- func (api *PublicFilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, error)
- func (api *PublicFilterAPI) NewPendingTransactionFilter() rpc.ID
- func (api *PublicFilterAPI) NewPendingTransactions(ctx context.Context) (*rpc.Subscription, error)
- func (api *PublicFilterAPI) UninstallFilter(id rpc.ID) bool
- type PublicNetAPI
- type PublicWeb3API
- type StorageResult
- type Subscription
- type SubscriptionNotification
- type SubscriptionResponseJSON
- type SubscriptionResult
- type Transaction
Constants ¶
const ( Web3Namespace = "web3" EthNamespace = "eth" PersonalNamespace = "personal" NetNamespace = "net" )
RPC namespaces and API version
const ( // LatestBlockNumber mapping from "latest" to 0 for tm query LatestBlockNumber = BlockNumber(0) // EarliestBlockNumber mapping from "earliest" to 1 for tm query (earliest query not supported) EarliestBlockNumber = BlockNumber(1) )
Variables ¶
This section is empty.
Functions ¶
func EmintServeCmd ¶
EmintServeCmd creates a CLI command to start Cosmos REST server with web3 RPC API and Cosmos rest-server endpoints
func EthHeaderFromTendermint ¶
EthHeaderFromTendermint is an util function that returns an Ethereum Header from a tendermint Header.
func GetRPCAPIs ¶
func GetRPCAPIs(cliCtx context.CLIContext, keys []emintcrypto.PrivKeySecp256k1) []rpc.API
GetRPCAPIs returns the list of all APIs
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 struct for account proof
type AddrLocker ¶
type AddrLocker struct {
// contains filtered or unexported fields
}
AddrLocker is a mutex structure used to avoid querying outdated account data
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 { // Used by block filter; also used for polling BlockNumber() (hexutil.Uint64, error) HeaderByNumber(blockNum BlockNumber) (*ethtypes.Header, error) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error) GetBlockByNumber(blockNum BlockNumber, fullTx bool) (map[string]interface{}, error) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error) // returns the logs of a given block GetLogs(blockHash common.Hash) ([][]*ethtypes.Log, error) // Used by pending transaction filter PendingTransactions() ([]*Transaction, error) // Used by log filter GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error) BloomStatus() (uint64, uint64) // contains filtered or unexported methods }
Backend implements the functionality needed to filter changes. Implemented by EthermintBackend.
type BlockNumber ¶
type BlockNumber int64
BlockNumber represents decoding hex string to block values
func NewBlockNumber ¶
func NewBlockNumber(n *big.Int) BlockNumber
NewBlockNumber creates a new BlockNumber instance.
func (BlockNumber) Int64 ¶
func (bn BlockNumber) Int64() int64
Int64 converts block number to primitive type
func (*BlockNumber) UnmarshalJSON ¶
func (bn *BlockNumber) UnmarshalJSON(data []byte) error
UnmarshalJSON parses the given JSON fragment into a BlockNumber. It supports: - "latest", "earliest" or "pending" as string arguments - the block number Returned errors: - an invalid block number error when the given argument isn't a known strings - an out of range error when the given block number is either too little or too large
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 the arguments for a call.
type ErrorMessageJSON ¶
type ErrorResponseJSON ¶
type ErrorResponseJSON struct { Jsonrpc string `json:"jsonrpc"` Error *ErrorMessageJSON `json:"error"` ID *big.Int `json:"id"` }
type EthermintBackend ¶
type EthermintBackend struct {
// contains filtered or unexported fields
}
EthermintBackend implements the Backend interface
func NewEthermintBackend ¶
func NewEthermintBackend(cliCtx context.CLIContext) *EthermintBackend
NewEthermintBackend creates a new EthermintBackend instance
func (*EthermintBackend) BlockNumber ¶
func (e *EthermintBackend) BlockNumber() (hexutil.Uint64, error)
BlockNumber returns the current block number.
func (*EthermintBackend) BloomStatus ¶
func (e *EthermintBackend) BloomStatus() (uint64, uint64)
BloomStatus returns the BloomBitsBlocks and the number of processed sections maintained by the chain indexer.
func (*EthermintBackend) GetBlockByHash ¶
func (e *EthermintBackend) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)
GetBlockByHash returns the block identified by hash.
func (*EthermintBackend) GetBlockByNumber ¶
func (e *EthermintBackend) GetBlockByNumber(blockNum BlockNumber, fullTx bool) (map[string]interface{}, error)
GetBlockByNumber returns the block identified by number.
func (*EthermintBackend) GetLogs ¶
GetLogs returns all the logs from all the ethreum transactions in a block.
func (*EthermintBackend) GetTransactionLogs ¶
GetTransactionLogs returns the logs given a transaction hash. It returns an error if there's an encoding error. If no logs are found for the tx hash, the error is nil.
func (*EthermintBackend) HeaderByHash ¶
HeaderByHash returns the block header identified by hash.
func (*EthermintBackend) HeaderByNumber ¶
func (e *EthermintBackend) HeaderByNumber(blockNum BlockNumber) (*ethtypes.Header, error)
HeaderByNumber returns the block header identified by height.
func (*EthermintBackend) PendingTransactions ¶
func (e *EthermintBackend) PendingTransactions() ([]*Transaction, 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.
type EventSystem ¶
type EventSystem struct {
// contains filtered or unexported fields
}
EventSystem creates subscriptions, processes events and broadcasts them to the subscription which match the subscription criteria using the Tendermint's RPC client.
func NewEventSystem ¶
func NewEventSystem(client rpcclient.Client) *EventSystem
NewEventSystem creates a new manager that listens for event on the given mux, parses and filters them. It uses the all map to retrieve filter changes. The work loop holds its own index that is used to forward events to filters.
The returned manager has a loop that needs to be stopped with the Stop function or by stopping the given mux.
func (*EventSystem) SubscribeLogs ¶
func (es *EventSystem) SubscribeLogs(crit filters.FilterCriteria) (*Subscription, context.CancelFunc, error)
SubscribeLogs creates a subscription that will write all logs matching the given criteria to the given logs channel. Default value for the from and to block is "latest". If the fromBlock > toBlock an error is returned.
func (EventSystem) SubscribeNewHeads ¶
func (es EventSystem) SubscribeNewHeads() (*Subscription, context.CancelFunc, error)
SubscribeNewHeads subscribes to new block headers events.
func (EventSystem) SubscribePendingTxs ¶
func (es EventSystem) SubscribePendingTxs() (*Subscription, context.CancelFunc, error)
SubscribePendingTxs subscribes to new pending transactions events from the mempool.
func (*EventSystem) WithContext ¶
func (es *EventSystem) WithContext(ctx context.Context)
WithContext sets a new context to the EventSystem. This is required to set a timeout context when a new filter is intantiated.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter can be used to retrieve and filter logs.
func NewBlockFilter ¶
func NewBlockFilter(backend FiltersBackend, criteria filters.FilterCriteria) *Filter
NewBlockFilter creates a new filter which directly inspects the contents of a block to figure out whether it is interesting or not.
func NewRangeFilter ¶
func NewRangeFilter(backend FiltersBackend, begin, end int64, addresses []common.Address, topics [][]common.Hash) *Filter
NewRangeFilter creates a new filter which uses a bloom filter on blocks to figure out whether a particular block is interesting or not.
type FiltersBackend ¶
type FiltersBackend interface { GetBlockByNumber(blockNum BlockNumber, fullTx bool) (map[string]interface{}, error) HeaderByNumber(blockNr BlockNumber) (*ethtypes.Header, error) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error) GetLogs(blockHash common.Hash) ([][]*ethtypes.Log, error) GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error) BloomStatus() (uint64, uint64) }
FiltersBackend defines the methods requided by the PublicFilterAPI backend
type PersonalEthAPI ¶
type PersonalEthAPI struct {
// contains filtered or unexported fields
}
PersonalEthAPI is the personal_ prefixed set of APIs in the Web3 JSON-RPC spec.
func NewPersonalEthAPI ¶
func NewPersonalEthAPI(ethAPI *PublicEthAPI) *PersonalEthAPI
NewPersonalEthAPI creates an instance of the public Personal Eth API.
func (*PersonalEthAPI) EcRecover ¶ added in v0.1.0
func (e *PersonalEthAPI) EcRecover(_ 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_ecRecove
func (*PersonalEthAPI) ImportRawKey ¶ added in v0.1.0
func (e *PersonalEthAPI) ImportRawKey(privkey, password string) (common.Address, error)
ImportRawKey armors and encrypts a given raw hex encoded ECDSA key and stores it into the key directory. The name of the key will have the format "personal_<length-keys>", where <length-keys> is the total number of keys stored on the keyring. NOTE: The key will be both armored and encrypted using the same passphrase.
func (*PersonalEthAPI) ListAccounts ¶ added in v0.1.0
func (e *PersonalEthAPI) ListAccounts() ([]common.Address, error)
ListAccounts will return a list of addresses for accounts this node manages.
func (*PersonalEthAPI) LockAccount ¶ added in v0.1.0
func (e *PersonalEthAPI) LockAccount(address common.Address) bool
LockAccount will lock the account associated with the given address when it's unlocked. It removes the key corresponding to the given address from the API's local keys.
func (*PersonalEthAPI) NewAccount ¶ added in v0.1.0
func (e *PersonalEthAPI) NewAccount(password string) (common.Address, error)
NewAccount will create a new account and returns the address for the new account.
func (*PersonalEthAPI) SendTransaction ¶ added in v0.1.0
func (e *PersonalEthAPI) SendTransaction(_ context.Context, args params.SendTxArgs, _ string) (common.Hash, error)
SendTransaction will create a transaction from the given arguments and tries to sign it with the key associated with args.To. If the given password isn't able to decrypt the key it fails.
func (*PersonalEthAPI) Sign ¶
func (e *PersonalEthAPI) Sign(_ context.Context, data hexutil.Bytes, addr common.Address, _ 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 (*PersonalEthAPI) UnlockAccount ¶ added in v0.1.0
func (e *PersonalEthAPI) UnlockAccount(_ context.Context, addr common.Address, password string, _ *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. It exports the private key corresponding to the given address from the keyring and stores it in the API's local keys.
type PublicEthAPI ¶
type PublicEthAPI struct {
// contains filtered or unexported fields
}
PublicEthAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.
func NewPublicEthAPI ¶
func NewPublicEthAPI(cliCtx context.CLIContext, backend Backend, nonceLock *AddrLocker, key []crypto.PrivKeySecp256k1) *PublicEthAPI
NewPublicEthAPI creates an instance of the public ETH Web3 API.
func (*PublicEthAPI) Accounts ¶
func (e *PublicEthAPI) Accounts() ([]common.Address, error)
Accounts returns the list of accounts available to this node.
func (*PublicEthAPI) BlockNumber ¶
func (e *PublicEthAPI) BlockNumber() (hexutil.Uint64, error)
BlockNumber returns the current block number.
func (*PublicEthAPI) Call ¶
func (e *PublicEthAPI) Call(args CallArgs, blockNr BlockNumber, _ *map[common.Address]account) (hexutil.Bytes, error)
Call performs a raw contract call.
func (*PublicEthAPI) ChainId ¶
func (e *PublicEthAPI) ChainId() (hexutil.Uint, error)
ChainId returns the chain's identifier in hex format
func (*PublicEthAPI) Coinbase ¶
func (e *PublicEthAPI) Coinbase() (common.Address, error)
Coinbase is the address that staking rewards will be send to (alias for Etherbase).
func (*PublicEthAPI) EstimateGas ¶
func (e *PublicEthAPI) EstimateGas(args CallArgs) (hexutil.Uint64, error)
EstimateGas returns an estimate of gas usage for the given smart contract call. It adds 1,000 gas to the returned value instead of using the gas adjustment param from the SDK.
func (*PublicEthAPI) ExportAccount ¶
func (e *PublicEthAPI) ExportAccount(address common.Address, blockNumber BlockNumber) (string, error)
ExportAccount exports an account's balance, code, and storage at the given block number TODO: deprecate this once the export genesis command works
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 BlockNumber) (*hexutil.Big, error)
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{}, error)
GetBlockByHash returns the block identified by hash.
func (*PublicEthAPI) GetBlockByNumber ¶
func (e *PublicEthAPI) GetBlockByNumber(blockNum BlockNumber, fullTx bool) (map[string]interface{}, error)
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 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 BlockNumber) (hexutil.Bytes, error)
GetCode returns the contract code at the given address and block number.
func (*PublicEthAPI) GetProof ¶
func (e *PublicEthAPI) GetProof(address common.Address, storageKeys []string, block BlockNumber) (*AccountResult, error)
GetProof returns an account object with proof and any storage proofs
func (*PublicEthAPI) GetStorageAt ¶
func (e *PublicEthAPI) GetStorageAt(address common.Address, key string, blockNum BlockNumber) (hexutil.Bytes, error)
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, error)
GetTransactionByBlockHashAndIndex returns the transaction identified by hash and index.
func (*PublicEthAPI) GetTransactionByBlockNumberAndIndex ¶
func (e *PublicEthAPI) GetTransactionByBlockNumberAndIndex(blockNum BlockNumber, idx hexutil.Uint) (*Transaction, error)
GetTransactionByBlockNumberAndIndex returns the transaction identified by number and index.
func (*PublicEthAPI) GetTransactionByHash ¶
func (e *PublicEthAPI) GetTransactionByHash(hash common.Hash) (*Transaction, error)
GetTransactionByHash returns the transaction identified by hash.
func (*PublicEthAPI) GetTransactionCount ¶
func (e *PublicEthAPI) GetTransactionCount(address common.Address, blockNum BlockNumber) (*hexutil.Uint64, error)
GetTransactionCount returns the number of transactions at the given address up to the given block number.
func (*PublicEthAPI) GetTransactionLogs ¶
GetTransactionLogs returns the logs given a transaction hash.
func (*PublicEthAPI) GetTransactionReceipt ¶
func (e *PublicEthAPI) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error)
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 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) PendingTransactions ¶
func (e *PublicEthAPI) PendingTransactions() ([]*Transaction, 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 (*PublicEthAPI) ProtocolVersion ¶
func (e *PublicEthAPI) ProtocolVersion() hexutil.Uint
ProtocolVersion returns the supported Ethereum protocol version.
func (*PublicEthAPI) SendRawTransaction ¶
SendRawTransaction send a raw Ethereum transaction.
func (*PublicEthAPI) SendTransaction ¶
func (e *PublicEthAPI) SendTransaction(args params.SendTxArgs) (common.Hash, error)
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{}, error)
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 PublicFilterAPI ¶
type PublicFilterAPI struct {
// contains filtered or unexported fields
}
PublicFilterAPI offers support to create and manage filters. This will allow external clients to retrieve various information related to the Ethereum protocol such as blocks, transactions and logs.
func NewPublicFilterAPI ¶
func NewPublicFilterAPI(cliCtx clientcontext.CLIContext, backend FiltersBackend) *PublicFilterAPI
NewPublicFilterAPI returns a new PublicFilterAPI instance.
func (*PublicFilterAPI) GetFilterChanges ¶
func (api *PublicFilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error)
GetFilterChanges returns the logs for the filter with the given id since last time it was called. This can be used for polling.
For pending transaction and block filters the result is []common.Hash. (pending)Log filters return []Log.
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges
func (*PublicFilterAPI) GetFilterLogs ¶
GetFilterLogs returns the logs for the filter with the given id. If the filter could not be found an empty array of logs is returned.
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterlogs
func (*PublicFilterAPI) GetLogs ¶
func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit filters.FilterCriteria) ([]*ethtypes.Log, error)
GetLogs returns logs matching the given argument that are stored within the state.
func (*PublicFilterAPI) Logs ¶
func (api *PublicFilterAPI) Logs(ctx context.Context, crit filters.FilterCriteria) (*rpc.Subscription, error)
Logs creates a subscription that fires for all new log that match the given filter criteria.
func (*PublicFilterAPI) NewBlockFilter ¶
func (api *PublicFilterAPI) NewBlockFilter() rpc.ID
NewBlockFilter creates a filter that fetches blocks that are imported into the chain. It is part of the filter package since polling goes with eth_getFilterChanges.
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newblockfilter
func (*PublicFilterAPI) NewFilter ¶
func (api *PublicFilterAPI) NewFilter(criteria filters.FilterCriteria) (rpc.ID, error)
NewFilter creates a new filter and returns the filter id. It can be used to retrieve logs when the state changes. This method cannot be used to fetch logs that are already stored in the state.
Default criteria for the from and to block are "latest". Using "latest" as block number will return logs for mined blocks. Using "pending" as block number returns logs for not yet mined (pending) blocks. In case logs are removed (chain reorg) previously returned logs are returned again but with the removed property set to true.
In case "fromBlock" > "toBlock" an error is returned.
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter
func (*PublicFilterAPI) NewHeads ¶
func (api *PublicFilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, error)
NewHeads send a notification each time a new (header) block is appended to the chain.
func (*PublicFilterAPI) NewPendingTransactionFilter ¶
func (api *PublicFilterAPI) NewPendingTransactionFilter() rpc.ID
NewPendingTransactionFilter creates a filter that fetches pending transaction hashes as transactions enter the pending state.
It is part of the filter package because this filter can be used through the `eth_getFilterChanges` polling method that is also used for log filters.
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newPendingTransactionFilter
func (*PublicFilterAPI) NewPendingTransactions ¶
func (api *PublicFilterAPI) NewPendingTransactions(ctx context.Context) (*rpc.Subscription, error)
NewPendingTransactions creates a subscription that is triggered each time a transaction enters the transaction pool and was signed from one of the transactions this nodes manages.
func (*PublicFilterAPI) UninstallFilter ¶
func (api *PublicFilterAPI) UninstallFilter(id rpc.ID) bool
UninstallFilter removes the filter with the given filter id.
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_uninstallfilter
type PublicNetAPI ¶
type PublicNetAPI struct {
// contains filtered or unexported fields
}
PublicNetAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.
func NewPublicNetAPI ¶
func NewPublicNetAPI(_ context.CLIContext) *PublicNetAPI
NewPublicNetAPI creates an instance of the public Net Web3 API.
func (*PublicNetAPI) Version ¶
func (s *PublicNetAPI) Version() string
Version returns the current ethereum protocol version.
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 StorageResult ¶
type StorageResult struct { Key string `json:"key"` Value *hexutil.Big `json:"value"` Proof []string `json:"proof"` }
StorageResult defines the format for storage proof return
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription defines a wrapper for the private subscription
func (Subscription) ID ¶
func (s Subscription) ID() rpc.ID
ID returns the underlying subscription RPC identifier.
func (*Subscription) Unsubscribe ¶
func (s *Subscription) Unsubscribe(es *EventSystem)
Unsubscribe to the current subscription from Tendermint Websocket. It sends an error to the subscription error channel if unsubscription fails.
type SubscriptionNotification ¶
type SubscriptionNotification struct { Jsonrpc string `json:"jsonrpc"` Method string `json:"method"` Params *SubscriptionResult `json:"params"` }
type SubscriptionResult ¶
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.Uint64 `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.