eth

package
v1.1.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.

The Ethermint library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Ethermint library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EthereumAPI

type EthereumAPI interface {
	// Getting Blocks
	//
	// Retrieves information from a particular block in the blockchain.
	BlockNumber() (hexutil.Uint64, error)
	GetBlockByNumber(ethBlockNum types.BlockNumber, fullTx bool) (map[string]interface{}, error)
	GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)
	GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Uint
	GetBlockTransactionCountByNumber(blockNum types.BlockNumber) *hexutil.Uint

	// Reading Transactions
	//
	// Retrieves information on the state data for addresses regardless of whether
	// it is a user or a smart contract.
	GetTransactionByHash(hash common.Hash) (*types.RPCTransaction, error)
	GetTransactionCount(address common.Address, blockNrOrHash types.BlockNumberOrHash) (*hexutil.Uint64, error)
	GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error)
	GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) (*types.RPCTransaction, error)
	GetTransactionByBlockNumberAndIndex(blockNum types.BlockNumber, idx hexutil.Uint) (*types.RPCTransaction, error)

	// Writing Transactions
	//
	// Allows developers to both send ETH from one address to another, write data
	// on-chain, and interact with smart contracts.
	SendRawTransaction(data hexutil.Bytes) (common.Hash, error)
	SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error)

	// Account Information
	//
	// Returns information regarding an address's stored on-chain data.
	Accounts() ([]common.Address, error)
	GetBalance(address common.Address, blockNrOrHash types.BlockNumberOrHash) (*hexutil.Big, error)
	GetStorageAt(address common.Address, key string, blockNrOrHash types.BlockNumberOrHash) (hexutil.Bytes, error)
	GetCode(address common.Address, blockNrOrHash types.BlockNumberOrHash) (hexutil.Bytes, error)
	GetProof(address common.Address, storageKeys []string, blockNrOrHash types.BlockNumberOrHash) (*types.AccountResult, error)

	// EVM/Smart Contract Execution
	//
	// Allows developers to read data from the blockchain which includes executing
	// smart contracts. However, no data is published to the Ethereum network.
	Call(args evmtypes.TransactionArgs, blockNrOrHash types.BlockNumberOrHash, _ *types.StateOverride) (hexutil.Bytes, error)

	// Chain Information
	//
	// Returns information on the Ethereum network and internal settings.
	ProtocolVersion() hexutil.Uint
	GasPrice() (*hexutil.Big, error)
	EstimateGas(args evmtypes.TransactionArgs, blockNrOptional *types.BlockNumber) (hexutil.Uint64, error)
	FeeHistory(blockCount rpc.DecimalOrHex, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*types.FeeHistoryResult, error)
	MaxPriorityFeePerGas() (*hexutil.Big, error)
	ChainId() (*hexutil.Big, error)

	// Getting Uncles
	//
	// Returns information on uncle blocks are which are network rejected blocks and replaced by a canonical block instead.
	GetUncleByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) map[string]interface{}
	GetUncleByBlockNumberAndIndex(number, idx hexutil.Uint) map[string]interface{}
	GetUncleCountByBlockHash(hash common.Hash) hexutil.Uint
	GetUncleCountByBlockNumber(blockNum types.BlockNumber) hexutil.Uint

	// Proof of Work
	Hashrate() hexutil.Uint64
	Mining() bool

	// Other
	Syncing() (interface{}, error)
	Coinbase() (string, error)
	Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error)
	GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error)
	SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error)
	FillTransaction(args evmtypes.TransactionArgs) (*types.SignTransactionResult, error)
	Resend(ctx context.Context, args evmtypes.TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error)
	GetPendingTransactions() ([]*types.RPCTransaction, error)
}

The Ethereum API allows applications to connect to an Evmos node that is part of the Evmos blockchain. Developers can interact with on-chain EVM data and send different types of transactions to the network by utilizing the endpoints provided by the API. The API follows a JSON-RPC standard. If not otherwise specified, the interface is derived from the Alchemy Ethereum API: https://docs.alchemy.com/alchemy/apis/ethereum

type PublicAPI

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

PublicAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.

func NewPublicAPI

func NewPublicAPI(logger log.Logger, backend backend2.EVMBackend) *PublicAPI

NewPublicAPI creates an instance of the public ETH Web3 API.

func (*PublicAPI) Accounts

func (e *PublicAPI) Accounts() ([]common.Address, error)

Accounts returns the list of accounts available to this node.

func (*PublicAPI) BlockNumber

func (e *PublicAPI) BlockNumber() (hexutil.Uint64, error)

BlockNumber returns the current block number.

func (*PublicAPI) Call

Call performs a raw contract call.

func (*PublicAPI) ChainId

func (e *PublicAPI) ChainId() (*hexutil.Big, error)

ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.

func (*PublicAPI) Coinbase

func (e *PublicAPI) Coinbase() (string, error)

Coinbase is the address that staking rewards will be send to (alias for Etherbase).

func (*PublicAPI) EstimateGas

func (e *PublicAPI) EstimateGas(args evmtypes.TransactionArgs, blockNrOptional *types.BlockNumber) (hexutil.Uint64, error)

EstimateGas returns an estimate of gas usage for the given smart contract call.

func (*PublicAPI) FeeHistory

func (e *PublicAPI) FeeHistory(blockCount rpc.DecimalOrHex,
	lastBlock rpc.BlockNumber,
	rewardPercentiles []float64,
) (*types.FeeHistoryResult, error)

func (*PublicAPI) FillTransaction

func (e *PublicAPI) FillTransaction(args evmtypes.TransactionArgs) (*types.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 (*PublicAPI) GasPrice

func (e *PublicAPI) GasPrice() (*hexutil.Big, error)

GasPrice returns the current gas price based on Ethermint's gas price oracle.

func (*PublicAPI) GetBalance

func (e *PublicAPI) GetBalance(address common.Address, blockNrOrHash types.BlockNumberOrHash) (*hexutil.Big, error)

GetBalance returns the provided account's balance up to the provided block number.

func (*PublicAPI) GetBlockByHash

func (e *PublicAPI) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)

GetBlockByHash returns the block identified by hash.

func (*PublicAPI) GetBlockByNumber

func (e *PublicAPI) GetBlockByNumber(ethBlockNum types.BlockNumber, fullTx bool) (map[string]interface{}, error)

GetBlockByNumber returns the block identified by number.

func (*PublicAPI) GetBlockTransactionCountByHash

func (e *PublicAPI) GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Uint

GetBlockTransactionCountByHash returns the number of transactions in the block identified by hash.

func (*PublicAPI) GetBlockTransactionCountByNumber

func (e *PublicAPI) GetBlockTransactionCountByNumber(blockNum types.BlockNumber) *hexutil.Uint

GetBlockTransactionCountByNumber returns the number of transactions in the block identified by number.

func (*PublicAPI) GetCode

func (e *PublicAPI) GetCode(address common.Address, blockNrOrHash types.BlockNumberOrHash) (hexutil.Bytes, error)

GetCode returns the contract code at the given address and block number.

func (*PublicAPI) GetPendingTransactions

func (e *PublicAPI) GetPendingTransactions() ([]*types.RPCTransaction, error)

GetPendingTransactions returns the transactions that are in the transaction pool and have a from address that is one of the accounts this node manages.

func (*PublicAPI) GetProof

func (e *PublicAPI) GetProof(address common.Address,
	storageKeys []string,
	blockNrOrHash types.BlockNumberOrHash,
) (*types.AccountResult, error)

GetProof returns an account object with proof and any storage proofs

func (*PublicAPI) GetStorageAt

func (e *PublicAPI) GetStorageAt(address common.Address, key string, blockNrOrHash types.BlockNumberOrHash) (hexutil.Bytes, error)

GetStorageAt returns the contract storage at the given address, block number, and key.

func (*PublicAPI) GetTransactionByBlockHashAndIndex

func (e *PublicAPI) GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) (*types.RPCTransaction, error)

GetTransactionByBlockHashAndIndex returns the transaction identified by hash and index.

func (*PublicAPI) GetTransactionByBlockNumberAndIndex

func (e *PublicAPI) GetTransactionByBlockNumberAndIndex(blockNum types.BlockNumber, idx hexutil.Uint) (*types.RPCTransaction, error)

GetTransactionByBlockNumberAndIndex returns the transaction identified by number and index.

func (*PublicAPI) GetTransactionByHash

func (e *PublicAPI) GetTransactionByHash(hash common.Hash) (*types.RPCTransaction, error)

GetTransactionByHash returns the transaction identified by hash.

func (*PublicAPI) GetTransactionCount

func (e *PublicAPI) GetTransactionCount(address common.Address, blockNrOrHash types.BlockNumberOrHash) (*hexutil.Uint64, error)

GetTransactionCount returns the number of transactions at the given address up to the given block number.

func (*PublicAPI) GetTransactionLogs

func (e *PublicAPI) GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error)

GetTransactionLogs returns the logs given a transaction hash.

func (*PublicAPI) GetTransactionReceipt

func (e *PublicAPI) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error)

GetTransactionReceipt returns the transaction receipt identified by hash.

func (*PublicAPI) GetUncleByBlockHashAndIndex

func (e *PublicAPI) GetUncleByBlockHashAndIndex(_ common.Hash, _ hexutil.Uint) map[string]interface{}

GetUncleByBlockHashAndIndex returns the uncle identified by hash and index. Always returns nil.

func (*PublicAPI) GetUncleByBlockNumberAndIndex

func (e *PublicAPI) GetUncleByBlockNumberAndIndex(_, _ hexutil.Uint) map[string]interface{}

GetUncleByBlockNumberAndIndex returns the uncle identified by number and index. Always returns nil.

func (*PublicAPI) GetUncleCountByBlockHash

func (e *PublicAPI) GetUncleCountByBlockHash(_ common.Hash) hexutil.Uint

GetUncleCountByBlockHash returns the number of uncles in the block identified by hash. Always zero.

func (*PublicAPI) GetUncleCountByBlockNumber

func (e *PublicAPI) GetUncleCountByBlockNumber(_ types.BlockNumber) hexutil.Uint

GetUncleCountByBlockNumber returns the number of uncles in the block identified by number. Always zero.

func (*PublicAPI) Hashrate

func (e *PublicAPI) Hashrate() hexutil.Uint64

Hashrate returns the current node's hashrate. Always 0.

func (*PublicAPI) MaxPriorityFeePerGas

func (e *PublicAPI) MaxPriorityFeePerGas() (*hexutil.Big, error)

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

func (*PublicAPI) Mining

func (e *PublicAPI) Mining() bool

Mining returns whether or not this node is currently mining. Always false.

func (*PublicAPI) ProtocolVersion

func (e *PublicAPI) ProtocolVersion() hexutil.Uint

ProtocolVersion returns the supported Ethereum protocol version.

func (*PublicAPI) Resend

func (e *PublicAPI) Resend(_ context.Context,
	args evmtypes.TransactionArgs,
	gasPrice *hexutil.Big,
	gasLimit *hexutil.Uint64,
) (common.Hash, error)

Resend accepts an existing transaction and a new gas price and limit. It will remove the given transaction from the pool and reinsert it with the new gas price and limit.

func (*PublicAPI) SendRawTransaction

func (e *PublicAPI) SendRawTransaction(data hexutil.Bytes) (common.Hash, error)

SendRawTransaction send a raw Ethereum transaction.

func (*PublicAPI) SendTransaction

func (e *PublicAPI) SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error)

SendTransaction sends an Ethereum transaction.

func (*PublicAPI) Sign

func (e *PublicAPI) Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error)

Sign signs the provided data using the private key of address via Geth's signature standard.

func (*PublicAPI) SignTypedData

func (e *PublicAPI) SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error)

SignTypedData signs EIP-712 conformant typed data

func (*PublicAPI) Syncing

func (e *PublicAPI) Syncing() (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 pears. 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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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