eth

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRPCGasLimit = 20000000
	ETHMinGas          = 21000
)
View Source
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 EthBlockFromTendermint

func EthBlockFromTendermint(clientCtx clientcontext.Context, block *tmtypes.Block, gasUsedI *big.Int, transactions interface{}) (map[string]interface{}, error)

EthBlockFromTendermint returns a JSON-RPC compatible Ethereum blockfrom a given Tendermint block.

func EthHeaderFromTendermint

func EthHeaderFromTendermint(header tmtypes.Header) *ethtypes.Header

EthHeaderFromTendermint is an util function that returns an Ethereum Header from a tendermint Header.

func RawTxToEthTx added in v1.6.48

func RawTxToEthTx(clientCtx clientcontext.Context, bz []byte) (*types.MsgEthereumTx, error)

RawTxToEthTx returns a evm MsgEthereum transaction from raw tx bytes.

Types

type Account

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

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

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 types

func (BlockNumber) TmHeight

func (bn BlockNumber) TmHeight() *int64

TmHeight is a util function used for the Tendermint RPC clients. It returns nil if the block number is "latest". Otherwise, it returns the pointer of the int64 value of the height.

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.Uint64 `json:"gas_price"`
	Nonce    *hexutil.Uint64 `json:"nonce"`
	Value    *hexutil.Big    `json:"value"`
	Data     *hexutil.Bytes  `json:"data"`
}

CallArgs represents the arguments for a call.

type PublicEthereumAPI

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

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

func NewAPI

NewAPI creates an instance of the public ETH Web3 API.

func (*PublicEthereumAPI) Accounts

func (api *PublicEthereumAPI) Accounts() ([]common.Address, error)

Accounts returns the list of accounts available to this node.

func (*PublicEthereumAPI) BlockNumber

func (api *PublicEthereumAPI) BlockNumber() (hexutil.Uint64, error)

func (*PublicEthereumAPI) Call

Call performs a raw contract call.

func (*PublicEthereumAPI) ChainId

func (api *PublicEthereumAPI) ChainId() (hexutil.Uint, error)

ChainId returns the chain's identifier in hex format

func (*PublicEthereumAPI) ClientCtx

func (api *PublicEthereumAPI) ClientCtx() clientcontext.Context

ClientCtx returns the Cosmos SDK clients context.

func (*PublicEthereumAPI) Coinbase

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

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

func (*PublicEthereumAPI) EstimateGas

func (api *PublicEthereumAPI) EstimateGas(args CallArgs) (hexutil.Uint64, error)

func (*PublicEthereumAPI) GasPrice

func (api *PublicEthereumAPI) GasPrice() *hexutil.Big

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

func (*PublicEthereumAPI) GetBalance

func (api *PublicEthereumAPI) GetBalance(address common.Address, blockNum BlockNumber) (*hexutil.Big, error)

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

func (*PublicEthereumAPI) GetBlockByHash added in v1.6.3

func (api *PublicEthereumAPI) GetBlockByHash(hash common.Hash, fullTx bool) (interface{}, error)

GetBlockByHash returns the block identified by hash.

func (*PublicEthereumAPI) GetBlockByNumber

func (api *PublicEthereumAPI) GetBlockByNumber(blockNum BlockNumber, fullTx bool) (map[string]interface{}, error)

func (*PublicEthereumAPI) GetCode

func (api *PublicEthereumAPI) GetCode(address common.Address, blockNumber BlockNumber) (hexutil.Bytes, error)

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

func (*PublicEthereumAPI) GetStorageAt

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

func (api *PublicEthereumAPI) GetTransactionByHash(hash common.Hash) (*Transaction, error)

func (*PublicEthereumAPI) GetTransactionCount

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

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

GetTransactionReceipt returns the transaction receipt identified by hash.

func (*PublicEthereumAPI) Hashrate

func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64

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

func (*PublicEthereumAPI) Mining

func (api *PublicEthereumAPI) Mining() bool

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

func (*PublicEthereumAPI) SendRawTransaction

func (api *PublicEthereumAPI) SendRawTransaction(data hexutil.Bytes) (common.Hash, error)

SendRawTransaction send a raw Ethereum transaction.

func (*PublicEthereumAPI) SendTransaction

func (api *PublicEthereumAPI) SendTransaction(args SendTxArgs) (common.Hash, error)

SendTransaction sends an Ethereum transaction.

func (*PublicEthereumAPI) Sign

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

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

type SendTxArgs 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"`
	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.
	Data  *hexutil.Bytes `json:"data"`
	Input *hexutil.Bytes `json:"input"`
}

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

	// Receipt data
	ContractAddress common.Address `json:"contractAddress"`
	Status          int            `json:"status"`
	//LogsBloom 		 ethtypes.Bloom `json:"logsBloom"`
	Logs []*ethtypes.Log `json:"logs"`
}

Transaction represents a transaction returned to RPC clients.

func EthTransactionsFromTendermint added in v1.6.48

func EthTransactionsFromTendermint(clientCtx clientcontext.Context, txs []tmtypes.Tx, blockHash common.Hash, blockNumber uint64) ([]common.Hash, *big.Int, []*Transaction, error)

EthTransactionsFromTendermint returns a slice of ethereum transaction hashes and the total gas usage from a set of tendermint block transactions.

func NewTransaction

func NewTransaction(tx *types.MsgEthereumTx, txHash, blockHash common.Hash, blockNumber, index uint64) (*Transaction, error)

func NewTransactionFromWeelinkTx added in v1.6.50

func NewTransactionFromWeelinkTx(tx *types.CommonTx, txHash, blockHash common.Hash, blockNumber, index uint64) *Transaction

func NewTransactionWithReceipt added in v1.6.50

func NewTransactionWithReceipt(tx *types.MsgEthereumTx, txHash, blockHash common.Hash, blockNumber, index uint64, resultData []byte) (*Transaction, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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