api

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: GPL-3.0 Imports: 40 Imported by: 30

Documentation

Overview

Package api implements the general Klaytn API functions.

Overview of api package

This package provides various APIs to access the data of the Klaytn node. Remote users can interact with Klyatn by calling these APIs instead of IPC. APIs are grouped by access modifiers (public or private) and namespaces (klay, txpool, debug and personal).

Source Files

  • addrlock.go : implements Addrlocker which prevents another tx getting the same nonce through API.
  • api_private_account.go : provides private APIs to access accounts managed by the node.
  • api_private_debug.go : provides private APIs exposed over the debugging node.
  • api_public_account.go : provides public APIs to access accounts managed by the node.
  • api_public_blockchain.go : provides public APIs to access the Klaytn blockchain.
  • api_public_cypress.go : provides public APIs to return specific information of Klaytn Cypress network.
  • api_public_debug.go : provides public APIs exposed over the debugging node.
  • api_public_klay.go : provides public APIs to access Klaytn related data.
  • api_public_net.go : provides public APIs to offer network related RPC methods.
  • api_public_transaction_pool.go : provides public APIs having "klay" namespace to access transaction pool data.
  • api_public_tx_pool.go : provides public APIs having "txpool" namespace to access transaction pool data.
  • backend.go : provides the common API services.
  • tx_args.go : provides API argument structures and functions.

Index

Constants

View Source
const (
	// EmptySha3Uncles always have value which is the result of
	// `crypto.Keccak256Hash(rlp.EncodeToBytes([]*types.Header(nil)).String())`
	// because there is no uncles in Klaytn.
	// Just use const value because we don't have to calculate it everytime which always be same result.
	EmptySha3Uncles = "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
	// ZeroHashrate exists for supporting Ethereum compatible data structure.
	// There is no POW mining mechanism in Klaytn.
	ZeroHashrate uint64 = 0
	// ZeroUncleCount is always zero because there is no uncle blocks in Klaytn.
	ZeroUncleCount uint = 0
)

Variables

This section is empty.

Functions

func AccessList added in v1.12.0

func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrHash, args EthTransactionArgs) (acl types.AccessList, gasUsed uint64, vmErr error, err error)

AccessList creates an access list for the given transaction. If the accesslist creation fails an error is returned. If the transaction itself fails, an vmErr is returned.

func DoCall added in v1.6.0

func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, vmCfg vm.Config, timeout time.Duration, globalGasCap *big.Int) (*blockchain.ExecutionResult, uint64, error)

func EthDoCall added in v1.8.0

func EthDoCall(ctx context.Context, b Backend, args EthTransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *EthStateOverride, timeout time.Duration, globalGasCap uint64) (*blockchain.ExecutionResult, error)

func EthDoEstimateGas added in v1.8.0

func EthDoEstimateGas(ctx context.Context, b Backend, args EthTransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap uint64) (hexutil.Uint64, error)

func NewRPCTransaction added in v1.12.1

func NewRPCTransaction(b *types.Block, tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) map[string]interface{}

func RpcOutputBlock

func RpcOutputBlock(b *types.Block, td *big.Int, inclTx bool, fullTx bool, rules params.Rules) (map[string]interface{}, error)

For klay_getBlockByNumber, klay_getBlockByHash, klay_getBlockWithconsensusInfoByNumber, klay_getBlockWithconsensusInfoByHash APIs and Kafka chaindatafetcher.

func RpcOutputReceipt

func RpcOutputReceipt(header *types.Header, tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64, receipt *types.Receipt) map[string]interface{}

RpcOutputReceipt converts a receipt to the RPC output with the associated information regarding to the block in which the receipt is included, the transaction that outputs the receipt, and the receipt itself.

Types

type AccessListResult added in v1.8.0

type AccessListResult struct {
	Accesslist *types.AccessList `json:"accessList"`
	Error      string            `json:"error,omitempty"`
	GasUsed    hexutil.Uint64    `json:"gasUsed"`
}

AccessListResult returns an optional accesslist Its the result of the `debug_createAccessList` RPC call. It contains an error if the transaction itself failed.

type AccountUpdateTxArgs

type AccountUpdateTxArgs struct {
	From     common.Address  `json:"from"`
	Gas      *hexutil.Uint64 `json:"gas"`
	GasPrice *hexutil.Big    `json:"gasPrice"`
	Nonce    *hexutil.Uint64 `json:"nonce"`
	Key      *hexutil.Bytes  `json:"key"`
}

type AddrLocker

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

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 {
	// General Klaytn API
	Progress() klaytn.SyncProgress
	ProtocolVersion() int
	SuggestPrice(ctx context.Context) (*big.Int, error)
	SuggestTipCap(ctx context.Context) (*big.Int, error)
	UpperBoundGasPrice(ctx context.Context) *big.Int
	LowerBoundGasPrice(ctx context.Context) *big.Int
	ChainDB() database.DBManager
	EventMux() *event.TypeMux
	AccountManager() accounts.AccountManager
	RPCEVMTimeout() time.Duration // global timeout for eth/klay_call/estimateGas/estimateComputationCost
	RPCGasCap() *big.Int          // global gas cap for eth/klay_call/estimateGas/estimateComputationCost
	RPCTxFeeCap() float64         // global tx fee cap in eth_signTransaction
	Engine() consensus.Engine
	FeeHistory(ctx context.Context, blockCount int, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error)

	// BlockChain API
	SetHead(number uint64) error
	HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error)
	HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
	HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Header, error)
	BlockByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Block, error)
	BlockByHash(ctx context.Context, blockHash common.Hash) (*types.Block, error)
	BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error)
	StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error)
	StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error)
	GetBlockReceipts(ctx context.Context, blockHash common.Hash) types.Receipts
	GetTxLookupInfoAndReceipt(ctx context.Context, hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, *types.Receipt)
	GetTxAndLookupInfo(hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64)
	GetTd(blockHash common.Hash) *big.Int
	GetEVM(ctx context.Context, msg blockchain.Message, state *state.StateDB, header *types.Header, vmCfg vm.Config) (*vm.EVM, func() error, error)
	SubscribeChainEvent(ch chan<- blockchain.ChainEvent) event.Subscription
	SubscribeChainHeadEvent(ch chan<- blockchain.ChainHeadEvent) event.Subscription
	SubscribeChainSideEvent(ch chan<- blockchain.ChainSideEvent) event.Subscription
	IsParallelDBWrite() bool

	IsSenderTxHashIndexingEnabled() bool

	// TxPool API
	SendTx(ctx context.Context, signedTx *types.Transaction) error
	GetPoolTransactions() (types.Transactions, error)
	GetPoolTransaction(txHash common.Hash) *types.Transaction
	GetPoolNonce(ctx context.Context, addr common.Address) uint64
	Stats() (pending int, queued int)
	TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
	SubscribeNewTxsEvent(chan<- blockchain.NewTxsEvent) event.Subscription

	ChainConfig() *params.ChainConfig
	CurrentBlock() *types.Block

	GetTxAndLookupInfoInCache(hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64)
	GetBlockReceiptsInCache(blockHash common.Hash) types.Receipts
	GetTxLookupInfoAndReceiptInCache(Hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, *types.Receipt)
}

Backend interface provides the common API services (that are provided by both full and light clients) with access to necessary functions.

type BlockNonce added in v1.8.0

type BlockNonce [8]byte

A BlockNonce is a 64-bit hash which proves (combined with the mix-hash) that a sufficient amount of computation has been carried out on a block.

func EncodeNonce added in v1.8.0

func EncodeNonce(i uint64) BlockNonce

EncodeNonce converts the given integer to a block nonce.

func (BlockNonce) MarshalText added in v1.8.0

func (n BlockNonce) MarshalText() ([]byte, error)

MarshalText encodes n as a hex string with 0x prefix.

func (BlockNonce) Uint64 added in v1.8.0

func (n BlockNonce) Uint64() uint64

Uint64 returns the integer value of a block nonce.

func (*BlockNonce) UnmarshalText added in v1.8.0

func (n *BlockNonce) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

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"`
	MaxFeePerGas         *hexutil.Big    `json:"maxFeePerGas"`
	MaxPriorityFeePerGas *hexutil.Big    `json:"maxPriorityFeePerGas"`
	Value                hexutil.Big     `json:"value"`
	Data                 hexutil.Bytes   `json:"data"`
	Input                hexutil.Bytes   `json:"input"`

	// Introduced by AccessListTxType transaction.
	AccessList *types.AccessList `json:"accessList,omitempty"`
	ChainID    *hexutil.Big      `json:"chainId,omitempty"`
}

CallArgs represents the arguments for a call.

func (*CallArgs) InputData added in v1.12.0

func (args *CallArgs) InputData() []byte

func (*CallArgs) ToMessage added in v1.9.0

func (args *CallArgs) ToMessage(globalGasCap uint64, baseFee *big.Int, intrinsicGas uint64) (*types.Transaction, error)

type CreditOutput

type CreditOutput struct {
	Photo string `json:"photo"`
	Names string `json:"names"`
}

type DecimalOrHex added in v1.8.0

type DecimalOrHex uint64

DecimalOrHex unmarshals a non-negative decimal or hex parameter into a uint64.

func (*DecimalOrHex) UnmarshalJSON added in v1.8.0

func (dh *DecimalOrHex) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type EthAccountResult added in v1.8.0

type EthAccountResult 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 []EthStorageResult `json:"storageProof"`
}

EthAccountResult structs for GetProof AccountResult in go-ethereum has been renamed to EthAccountResult. AccountResult is defined in go-ethereum's internal package, so AccountResult is redefined here as EthAccountResult.

type EthOverrideAccount added in v1.8.0

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

EthOverrideAccount 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. OverrideAccount in go-ethereum has been renamed to EthOverrideAccount. OverrideAccount is defined in go-ethereum's internal package, so OverrideAccount is redefined here as EthOverrideAccount.

type EthRPCTransaction added in v1.8.0

type EthRPCTransaction 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"`
	GasFeeCap        *hexutil.Big      `json:"maxFeePerGas,omitempty"`
	GasTipCap        *hexutil.Big      `json:"maxPriorityFeePerGas,omitempty"`
	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"`
	Type             hexutil.Uint64    `json:"type"`
	Accesses         *types.AccessList `json:"accessList,omitempty"`
	ChainID          *hexutil.Big      `json:"chainId,omitempty"`
	V                *hexutil.Big      `json:"v"`
	R                *hexutil.Big      `json:"r"`
	S                *hexutil.Big      `json:"s"`
}

EthRPCTransaction represents a transaction that will serialize to the RPC representation of a transaction RPCTransaction in go-ethereum has been renamed to EthRPCTransaction. RPCTransaction is defined in go-ethereum's internal package, so RPCTransaction is redefined here as EthRPCTransaction.

type EthSignTransactionResult added in v1.8.0

type EthSignTransactionResult struct {
	Raw hexutil.Bytes `json:"raw"`
	Tx  *ethTxJSON    `json:"tx"`
}

EthSignTransactionResult represents a RLP encoded signed transaction. SignTransactionResult in go-ethereum has been renamed to EthSignTransactionResult. SignTransactionResult is defined in go-ethereum's internal package, so SignTransactionResult is redefined here as EthSignTransactionResult.

type EthStateOverride added in v1.8.0

type EthStateOverride map[common.Address]EthOverrideAccount

EthStateOverride is the collection of overridden accounts. StateOverride in go-ethereum has been renamed to EthStateOverride. StateOverride is defined in go-ethereum's internal package, so StateOverride is redefined here as EthStateOverride.

func (*EthStateOverride) Apply added in v1.8.0

func (diff *EthStateOverride) Apply(state *state.StateDB) error

type EthStorageResult added in v1.8.0

type EthStorageResult struct {
	Key   string       `json:"key"`
	Value *hexutil.Big `json:"value"`
	Proof []string     `json:"proof"`
}

StorageResult in go-ethereum has been renamed to EthStorageResult. StorageResult is defined in go-ethereum's internal package, so StorageResult is redefined here as EthStorageResult.

type EthTransactionArgs added in v1.8.0

type EthTransactionArgs struct {
	From                 *common.Address `json:"from"`
	To                   *common.Address `json:"to"`
	Gas                  *hexutil.Uint64 `json:"gas"`
	GasPrice             *hexutil.Big    `json:"gasPrice"`
	MaxFeePerGas         *hexutil.Big    `json:"maxFeePerGas"`
	MaxPriorityFeePerGas *hexutil.Big    `json:"maxPriorityFeePerGas"`
	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.
	// Issue detail: https://github.com/ethereum/go-ethereum/issues/15628
	Data  *hexutil.Bytes `json:"data"`
	Input *hexutil.Bytes `json:"input"`

	// Introduced by AccessListTxType transaction.
	AccessList *types.AccessList `json:"accessList,omitempty"`
	ChainID    *hexutil.Big      `json:"chainId,omitempty"`
}

EthTransactionArgs represents the arguments to construct a new transaction or a message call. TransactionArgs in go-ethereum has been renamed to EthTransactionArgs. TransactionArgs is defined in go-ethereum's internal package, so TransactionArgs is redefined here as EthTransactionArgs.

func (*EthTransactionArgs) ToMessage added in v1.8.0

func (args *EthTransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int, intrinsicGas uint64) (*types.Transaction, error)

ToMessage change EthTransactionArgs to types.Transaction in Klaytn.

type EthereumAPI added in v1.8.0

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

EthereumAPI provides an API to access the Klaytn through the `eth` namespace. TODO-Klaytn: Removed unused variable

func GetAPIs

func GetAPIs(apiBackend Backend, disableUnsafeDebug bool) ([]rpc.API, *EthereumAPI)

func NewEthereumAPI added in v1.8.0

func NewEthereumAPI() *EthereumAPI

NewEthereumAPI creates a new ethereum API. EthereumAPI operates using Klaytn's API internally without overriding. Therefore, it is necessary to use APIs defined in two different packages(cn and api), so those apis will be defined through a setter.

func (*EthereumAPI) Accounts added in v1.8.0

func (api *EthereumAPI) Accounts() []common.Address

Accounts returns the collection of accounts this node manages.

func (*EthereumAPI) BlockNumber added in v1.8.0

func (api *EthereumAPI) BlockNumber() hexutil.Uint64

BlockNumber returns the block number of the chain head.

func (*EthereumAPI) Call added in v1.8.0

func (api *EthereumAPI) Call(ctx context.Context, args EthTransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *EthStateOverride) (hexutil.Bytes, error)

Call executes the given transaction on the state for the given block number.

Additionally, the caller can specify a batch of contract for fields overriding.

Note, this function doesn't make and changes in the state/blockchain and is useful to execute and retrieve values.

func (*EthereumAPI) ChainId added in v1.8.0

func (api *EthereumAPI) ChainId() (*hexutil.Big, error)

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

func (*EthereumAPI) Coinbase added in v1.8.0

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

Coinbase is the address of operating node (alias for Etherbase).

func (*EthereumAPI) CreateAccessList added in v1.8.0

func (api *EthereumAPI) CreateAccessList(ctx context.Context, args EthTransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (interface{}, error)

CreateAccessList creates an EIP-2930 type AccessList for the given transaction. Reexec and BlockNrOrHash can be specified to create the accessList on top of a certain state.

func (*EthereumAPI) EstimateGas added in v1.8.0

func (api *EthereumAPI) EstimateGas(ctx context.Context, args EthTransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error)

EstimateGas returns an estimate of the amount of gas needed to execute the given transaction against the current pending block.

func (*EthereumAPI) Etherbase added in v1.8.0

func (api *EthereumAPI) Etherbase() (common.Address, error)

Etherbase is the address of operating node. Unlike Ethereum, it only returns the node address because Klaytn does not have a POW mechanism.

func (*EthereumAPI) FeeHistory added in v1.8.0

func (api *EthereumAPI) FeeHistory(ctx context.Context, blockCount DecimalOrHex, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*FeeHistoryResult, error)

func (*EthereumAPI) FillTransaction added in v1.8.0

func (api *EthereumAPI) FillTransaction(ctx context.Context, args EthTransactionArgs) (*EthSignTransactionResult, 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 (*EthereumAPI) GasPrice added in v1.8.0

func (api *EthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error)

GasPrice returns a suggestion for a gas price.

func (*EthereumAPI) GetBalance added in v1.8.0

func (api *EthereumAPI) GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)

GetBalance returns the amount of wei for the given address in the state of the given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.

func (*EthereumAPI) GetBlockByHash added in v1.8.0

func (api *EthereumAPI) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (map[string]interface{}, error)

GetBlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*EthereumAPI) GetBlockByNumber added in v1.8.0

func (api *EthereumAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)

GetBlockByNumber returns the requested canonical block.

  • When blockNr is -1 the chain head is returned.
  • When blockNr is -2 the pending chain head is returned.
  • When fullTx is true all transactions in the block are returned, otherwise only the transaction hash is returned.

func (*EthereumAPI) GetBlockReceipts added in v1.12.0

func (api *EthereumAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]map[string]interface{}, error)

GetBlockReceipts returns the receipts of all transactions in the block identified by number or hash.

func (*EthereumAPI) GetBlockTransactionCountByHash added in v1.8.0

func (api *EthereumAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint

GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash.

func (*EthereumAPI) GetBlockTransactionCountByNumber added in v1.8.0

func (api *EthereumAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint

GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number.

func (*EthereumAPI) GetCode added in v1.8.0

func (api *EthereumAPI) GetCode(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetCode returns the code stored at the given address in the state for the given block number.

func (*EthereumAPI) GetFilterChanges added in v1.8.0

func (api *EthereumAPI) 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://eth.wiki/json-rpc/API#eth_getfilterchanges

func (*EthereumAPI) GetFilterLogs added in v1.8.0

func (api *EthereumAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*types.Log, error)

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://eth.wiki/json-rpc/API#eth_getfilterlogs

func (*EthereumAPI) GetHashrate added in v1.8.0

func (api *EthereumAPI) GetHashrate() uint64

GetHashrate returns ZeroHashrate because klaytn does not have a POW mechanism.

func (*EthereumAPI) GetHeaderByHash added in v1.8.0

func (api *EthereumAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) map[string]interface{}

GetHeaderByHash returns the requested header by hash.

func (*EthereumAPI) GetHeaderByNumber added in v1.8.0

func (api *EthereumAPI) GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (map[string]interface{}, error)

GetHeaderByNumber returns the requested canonical block header. * When blockNr is -1 the chain head is returned. * When blockNr is -2 the pending chain head is returned.

func (*EthereumAPI) GetLogs added in v1.8.0

func (api *EthereumAPI) GetLogs(ctx context.Context, crit filters.FilterCriteria) ([]*types.Log, error)

GetLogs returns logs matching the given argument that are stored within the state.

https://eth.wiki/json-rpc/API#eth_getlogs

func (*EthereumAPI) GetProof added in v1.8.0

func (api *EthereumAPI) GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNrOrHash rpc.BlockNumberOrHash) (*EthAccountResult, error)

GetProof returns the Merkle-proof for a given account and optionally some storage keys

func (*EthereumAPI) GetRawTransactionByBlockHashAndIndex added in v1.8.0

func (api *EthereumAPI) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) hexutil.Bytes

GetRawTransactionByBlockHashAndIndex returns the bytes of the transaction for the given block hash and index.

func (*EthereumAPI) GetRawTransactionByBlockNumberAndIndex added in v1.8.0

func (api *EthereumAPI) GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) hexutil.Bytes

GetRawTransactionByBlockNumberAndIndex returns the bytes of the transaction for the given block number and index.

func (*EthereumAPI) GetRawTransactionByHash added in v1.8.0

func (api *EthereumAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error)

GetRawTransactionByHash returns the bytes of the transaction for the given hash.

func (*EthereumAPI) GetStorageAt added in v1.8.0

func (api *EthereumAPI) GetStorageAt(ctx context.Context, address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetStorageAt returns the storage from the state at the given address, key and block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers are also allowed.

func (*EthereumAPI) GetTransactionByBlockHashAndIndex added in v1.8.0

func (api *EthereumAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) *EthRPCTransaction

GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index.

func (*EthereumAPI) GetTransactionByBlockNumberAndIndex added in v1.8.0

func (api *EthereumAPI) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) *EthRPCTransaction

GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index.

func (*EthereumAPI) GetTransactionByHash added in v1.8.0

func (api *EthereumAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*EthRPCTransaction, error)

GetTransactionByHash returns the transaction for the given hash.

func (*EthereumAPI) GetTransactionCount added in v1.8.0

func (api *EthereumAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error)

GetTransactionCount returns the number of transactions the given address has sent for the given block number.

func (*EthereumAPI) GetTransactionReceipt added in v1.8.0

func (api *EthereumAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error)

GetTransactionReceipt returns the transaction receipt for the given transaction hash.

func (*EthereumAPI) GetUncleByBlockHashAndIndex added in v1.8.0

func (api *EthereumAPI) GetUncleByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (map[string]interface{}, error)

GetUncleByBlockHashAndIndex returns nil because there is no uncle block in Klaytn.

func (*EthereumAPI) GetUncleByBlockNumberAndIndex added in v1.8.0

func (api *EthereumAPI) GetUncleByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (map[string]interface{}, error)

GetUncleByBlockNumberAndIndex returns nil because there is no uncle block in Klaytn.

func (*EthereumAPI) GetUncleCountByBlockHash added in v1.8.0

func (api *EthereumAPI) GetUncleCountByBlockHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint

GetUncleCountByBlockHash returns 0 when given blockHash exists because there is no uncle block in Klaytn.

func (*EthereumAPI) GetUncleCountByBlockNumber added in v1.8.0

func (api *EthereumAPI) GetUncleCountByBlockNumber(ctx context.Context, blockNr rpc.BlockNumber) *hexutil.Uint

GetUncleCountByBlockNumber returns 0 when given blockNr exists because there is no uncle block in Klaytn.

func (*EthereumAPI) GetWork added in v1.8.0

func (api *EthereumAPI) GetWork() ([4]string, error)

GetWork returns an errNoMiningWork because klaytn does not have a POW mechanism.

func (*EthereumAPI) Hashrate added in v1.8.0

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

Hashrate returns the POW hashrate. Unlike Ethereum, it always returns ZeroHashrate because Klaytn does not have a POW mechanism.

func (*EthereumAPI) Logs added in v1.8.0

Logs creates a subscription that fires for all new log that match the given filter criteria.

func (*EthereumAPI) LowerBoundGasPrice added in v1.9.0

func (api *EthereumAPI) LowerBoundGasPrice(ctx context.Context) *hexutil.Big

func (*EthereumAPI) MaxPriorityFeePerGas added in v1.8.0

func (api *EthereumAPI) MaxPriorityFeePerGas(ctx context.Context) (*hexutil.Big, error)

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

func (*EthereumAPI) Mining added in v1.8.0

func (api *EthereumAPI) Mining() bool

Mining returns an indication if this node is currently mining. Unlike Ethereum, it always returns false because Klaytn does not have a POW mechanism,

func (*EthereumAPI) NewBlockFilter added in v1.8.0

func (api *EthereumAPI) 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://eth.wiki/json-rpc/API#eth_newblockfilter

func (*EthereumAPI) NewFilter added in v1.8.0

func (api *EthereumAPI) NewFilter(crit 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://eth.wiki/json-rpc/API#eth_newfilter

func (*EthereumAPI) NewHeads added in v1.8.0

func (api *EthereumAPI) NewHeads(ctx context.Context) (*rpc.Subscription, error)

NewHeads send a notification each time a new (header) block is appended to the chain.

func (*EthereumAPI) NewPendingTransactionFilter added in v1.8.0

func (api *EthereumAPI) 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://eth.wiki/json-rpc/API#eth_newpendingtransactionfilter

func (*EthereumAPI) NewPendingTransactions added in v1.8.0

func (api *EthereumAPI) 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 (*EthereumAPI) PendingTransactions added in v1.8.0

func (api *EthereumAPI) PendingTransactions() ([]*EthRPCTransaction, 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 (*EthereumAPI) Resend added in v1.8.0

func (api *EthereumAPI) Resend(ctx context.Context, sendArgs EthTransactionArgs, 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 (*EthereumAPI) SendRawTransaction added in v1.8.0

func (api *EthereumAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error)

SendRawTransaction will add the signed transaction to the transaction pool. The sender is responsible for signing the transaction and using the correct nonce.

func (*EthereumAPI) SendTransaction added in v1.8.0

func (api *EthereumAPI) SendTransaction(ctx context.Context, args EthTransactionArgs) (common.Hash, error)

SendTransaction creates a transaction for the given argument, sign it and submit it to the transaction pool.

func (*EthereumAPI) SetGovernanceAPI added in v1.11.0

func (api *EthereumAPI) SetGovernanceAPI(governanceAPI *governance.GovernanceAPI)

SetGovernanceAPI sets governanceAPI

func (*EthereumAPI) SetGovernanceKlayAPI added in v1.8.0

func (api *EthereumAPI) SetGovernanceKlayAPI(governanceKlayAPI *governance.GovernanceKlayAPI)

SetGovernanceKlayAPI sets governanceKlayAPI

func (*EthereumAPI) SetPublicAccountAPI added in v1.8.0

func (api *EthereumAPI) SetPublicAccountAPI(publicAccountAPI *PublicAccountAPI)

SetPublicAccountAPI sets publicAccountAPI

func (*EthereumAPI) SetPublicBlockChainAPI added in v1.8.0

func (api *EthereumAPI) SetPublicBlockChainAPI(publicBlockChainAPI *PublicBlockChainAPI)

SetPublicBlockChainAPI sets publicBlockChainAPI

func (*EthereumAPI) SetPublicFilterAPI added in v1.8.0

func (api *EthereumAPI) SetPublicFilterAPI(publicFilterAPI *filters.PublicFilterAPI)

SetPublicFilterAPI sets publicFilterAPI

func (*EthereumAPI) SetPublicKlayAPI added in v1.8.0

func (api *EthereumAPI) SetPublicKlayAPI(publicKlayAPI *PublicKlayAPI)

SetPublicKlayAPI sets publicKlayAPI

func (*EthereumAPI) SetPublicTransactionPoolAPI added in v1.8.0

func (api *EthereumAPI) SetPublicTransactionPoolAPI(publicTransactionPoolAPI *PublicTransactionPoolAPI)

SetPublicTransactionPoolAPI sets publicTransactionPoolAPI

func (*EthereumAPI) Sign added in v1.8.0

func (api *EthereumAPI) Sign(addr common.Address, data hexutil.Bytes) (hexutil.Bytes, error)

Sign calculates an ECDSA signature for: keccack256("\x19Klaytn 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 account associated with addr must be unlocked.

https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign

func (*EthereumAPI) SignTransaction added in v1.8.0

func (api *EthereumAPI) SignTransaction(ctx context.Context, args EthTransactionArgs) (*EthSignTransactionResult, error)

SignTransaction will sign the given transaction with the from account. The node needs to have the private key of the account corresponding with the given from address and it needs to be unlocked.

func (*EthereumAPI) SubmitHashrate added in v1.8.0

func (api *EthereumAPI) SubmitHashrate(rate hexutil.Uint64, id common.Hash) bool

SubmitHashrate returns false because klaytn does not have a POW mechanism.

func (*EthereumAPI) SubmitWork added in v1.8.0

func (api *EthereumAPI) SubmitWork(nonce BlockNonce, hash, digest common.Hash) bool

SubmitWork returns false because klaytn does not have a POW mechanism.

func (*EthereumAPI) Syncing added in v1.8.0

func (api *EthereumAPI) 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 synchronise 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

func (*EthereumAPI) UninstallFilter added in v1.8.0

func (api *EthereumAPI) UninstallFilter(id rpc.ID) bool

UninstallFilter removes the filter with the given filter id.

https://eth.wiki/json-rpc/API#eth_uninstallfilter

func (*EthereumAPI) UpperBoundGasPrice added in v1.9.0

func (api *EthereumAPI) UpperBoundGasPrice(ctx context.Context) *hexutil.Big

type ExecutionResult

type ExecutionResult struct {
	Gas         uint64         `json:"gas"`
	Failed      bool           `json:"failed"`
	ReturnValue string         `json:"returnValue"`
	StructLogs  []StructLogRes `json:"structLogs"`
}

ExecutionResult groups all structured logs emitted by the EVM while replaying a transaction in debug mode as well as transaction execution status, the amount of gas used and the return value

type FeeHistoryResult added in v1.8.0

type FeeHistoryResult struct {
	OldestBlock  *hexutil.Big     `json:"oldestBlock"`
	Reward       [][]*hexutil.Big `json:"reward,omitempty"`
	BaseFee      []*hexutil.Big   `json:"baseFeePerGas,omitempty"`
	GasUsedRatio []float64        `json:"gasUsedRatio"`
}

type NewTxArgs

type NewTxArgs interface {
	// contains filtered or unexported methods
}

type PrivateAccountAPI

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

PrivateAccountAPI provides an API to access accounts managed by this node. It offers methods to create, (un)lock en list accounts. Some methods accept passwords and are therefore considered private by default.

func NewPrivateAccountAPI

func NewPrivateAccountAPI(b Backend, nonceLock *AddrLocker) *PrivateAccountAPI

NewPrivateAccountAPI create a new PrivateAccountAPI.

func (*PrivateAccountAPI) DeriveAccount

func (s *PrivateAccountAPI) DeriveAccount(url string, path string, pin *bool) (accounts.Account, error)

DeriveAccount requests a HD wallet to derive a new account, optionally pinning it for later reuse.

func (*PrivateAccountAPI) EcRecover

func (s *PrivateAccountAPI) EcRecover(ctx 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("\x19Klaytn 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_ecRecover

func (*PrivateAccountAPI) ImportRawKey

func (s *PrivateAccountAPI) ImportRawKey(privkey string, password string) (common.Address, error)

ImportRawKey stores the given hex encoded ECDSA key into the key directory, encrypting it with the passphrase.

func (*PrivateAccountAPI) ListAccounts

func (s *PrivateAccountAPI) ListAccounts() []common.Address

ListAccounts will return a list of addresses for accounts this node manages.

func (*PrivateAccountAPI) ListWallets

func (s *PrivateAccountAPI) ListWallets() []rawWallet

ListWallets will return a list of wallets this node manages.

func (*PrivateAccountAPI) LockAccount

func (s *PrivateAccountAPI) LockAccount(addr common.Address) bool

LockAccount will lock the account associated with the given address when it's unlocked.

func (*PrivateAccountAPI) NewAccount

func (s *PrivateAccountAPI) NewAccount(password string) (common.Address, error)

NewAccount will create a new account and returns the address for the new account.

func (*PrivateAccountAPI) OpenWallet

func (s *PrivateAccountAPI) OpenWallet(url string, passphrase *string) error

OpenWallet initiates a hardware wallet opening procedure, establishing a USB connection and attempting to authenticate via the provided passphrase. Note, the method may return an extra challenge requiring a second open (e.g. the Trezor PIN matrix challenge).

func (*PrivateAccountAPI) ReplaceRawKey

func (s *PrivateAccountAPI) ReplaceRawKey(privkey string, passphrase string, newPassphrase string) (common.Address, error)

ReplaceRawKey stores the given hex encoded ECDSA key into the key directory, encrypting it with the passphrase.

func (*PrivateAccountAPI) SendAccountUpdate

func (s *PrivateAccountAPI) SendAccountUpdate(ctx context.Context, args AccountUpdateTxArgs, passwd string) (common.Hash, error)

SendAccountUpdate will create a TxTypeAccountUpdate transaction from the given arguments and try to sign it with the key associated with args.From. If the given password isn't able to decrypt the key it fails.

func (*PrivateAccountAPI) SendTransaction

func (s *PrivateAccountAPI) SendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error)

SendTransaction will create a transaction from the given arguments and try to sign it with the key associated with args.From. If the given password isn't able to decrypt the key it fails.

func (*PrivateAccountAPI) SendTransactionAsFeePayer added in v1.3.0

func (s *PrivateAccountAPI) SendTransactionAsFeePayer(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error)

SendTransactionAsFeePayer will create a transaction from the given arguments and try to sign it as a fee payer with the key associated with args.From. If the given password isn't able to decrypt the key it fails.

func (*PrivateAccountAPI) SendValueTransfer

func (s *PrivateAccountAPI) SendValueTransfer(ctx context.Context, args ValueTransferTxArgs, passwd string) (common.Hash, error)

SendValueTransfer will create a TxTypeValueTransfer transaction from the given arguments and try to sign it with the key associated with args.From. If the given password isn't able to decrypt the key it fails.

func (*PrivateAccountAPI) Sign

func (s *PrivateAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr common.Address, passwd string) (hexutil.Bytes, error)

Sign calculates a Klaytn ECDSA signature for: keccack256("\x19Klaytn 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 (*PrivateAccountAPI) SignAndSendTransaction

func (s *PrivateAccountAPI) SignAndSendTransaction(ctx context.Context, args SendTxArgs, passwd string) (common.Hash, error)

SignAndSendTransaction was renamed to SendTransaction. This method is deprecated and will be removed in the future. It primary goal is to give clients time to update.

func (*PrivateAccountAPI) SignTransaction

func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args SendTxArgs, passwd string) (*SignTransactionResult, error)

SignTransaction will create a transaction from the given arguments and try to sign it with the key associated with args.From. If the given password isn't able to decrypt the key, it fails. The transaction is returned in RLP-form, not broadcast to other nodes

func (*PrivateAccountAPI) SignTransactionAsFeePayer added in v1.3.0

func (s *PrivateAccountAPI) SignTransactionAsFeePayer(ctx context.Context, args SendTxArgs, passwd string) (*SignTransactionResult, error)

SignTransactionAsFeePayer will create a transaction from the given arguments and try to sign it as a fee payer with the key associated with args.From. If the given password isn't able to decrypt the key, it fails. The transaction is returned in RLP-form, not broadcast to other nodes

func (*PrivateAccountAPI) UnlockAccount

func (s *PrivateAccountAPI) UnlockAccount(addr common.Address, password string, duration *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.

type PrivateDebugAPI

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

PrivateDebugAPI is the collection of Klaytn APIs exposed over the private debugging endpoint.

func NewPrivateDebugAPI

func NewPrivateDebugAPI(b Backend) *PrivateDebugAPI

NewPrivateDebugAPI creates a new API definition for the private debug methods of the Klaytn service.

func (*PrivateDebugAPI) ChaindbCompact

func (api *PrivateDebugAPI) ChaindbCompact() error

ChaindbCompact flattens the entire key-value database into a single level, removing all unused slots and merging all keys.

func (*PrivateDebugAPI) ChaindbProperty

func (api *PrivateDebugAPI) ChaindbProperty(property string) (string, error)

ChaindbProperty returns leveldb properties of the chain database.

func (*PrivateDebugAPI) PrintBlock added in v1.10.0

func (api *PrivateDebugAPI) PrintBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (string, error)

PrintBlock retrieves a block and returns its pretty printed form.

func (*PrivateDebugAPI) SetHead

func (api *PrivateDebugAPI) SetHead(number rpc.BlockNumber) error

SetHead rewinds the head of the blockchain to a previous block.

type PublicAccountAPI

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

PublicAccountAPI provides an API to access accounts managed by this node. It offers only methods that can retrieve accounts.

func NewPublicAccountAPI

func NewPublicAccountAPI(am accounts.AccountManager) *PublicAccountAPI

NewPublicAccountAPI creates a new PublicAccountAPI.

func (*PublicAccountAPI) Accounts

func (s *PublicAccountAPI) Accounts() []common.Address

Accounts returns the collection of accounts this node manages

type PublicBlockChainAPI

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

PublicBlockChainAPI provides an API to access the Klaytn blockchain. It offers only methods that operate on public data that is freely available to anyone.

func NewPublicBlockChainAPI

func NewPublicBlockChainAPI(b Backend) *PublicBlockChainAPI

NewPublicBlockChainAPI creates a new Klaytn blockchain API.

func (*PublicBlockChainAPI) AccountCreated

func (s *PublicBlockChainAPI) AccountCreated(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (bool, error)

AccountCreated returns true if the account associated with the address is created. It returns false otherwise.

func (*PublicBlockChainAPI) BlockNumber

func (s *PublicBlockChainAPI) BlockNumber() hexutil.Uint64

BlockNumber returns the block number of the chain head.

func (*PublicBlockChainAPI) Call

func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

Call executes the given transaction on the state for the given block number or hash. It doesn't make and changes in the state/blockchain and is useful to execute and retrieve values.

func (*PublicBlockChainAPI) ChainID

func (s *PublicBlockChainAPI) ChainID() *hexutil.Big

ChainID returns the chain ID of the chain from genesis file.

func (*PublicBlockChainAPI) ChainId added in v1.6.0

func (s *PublicBlockChainAPI) ChainId() *hexutil.Big

ChainId returns the chain ID of the chain from genesis file. This is for compatibility with ethereum client

func (*PublicBlockChainAPI) CreateAccessList added in v1.8.0

func (s *PublicBlockChainAPI) CreateAccessList(ctx context.Context, args EthTransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (interface{}, error)

CreateAccessList creates a EIP-2930 type AccessList for the given transaction. Reexec and BlockNrOrHash can be specified to create the accessList on top of a certain state.

func (*PublicBlockChainAPI) DoEstimateGas added in v1.6.0

func (s *PublicBlockChainAPI) DoEstimateGas(ctx context.Context, b Backend, args CallArgs, gasCap *big.Int) (hexutil.Uint64, error)

func (*PublicBlockChainAPI) EstimateComputationCost

func (s *PublicBlockChainAPI) EstimateComputationCost(ctx context.Context, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Uint64, error)

func (*PublicBlockChainAPI) EstimateGas

func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (hexutil.Uint64, error)

EstimateGas returns an estimate of the amount of gas needed to execute the given transaction against the latest block.

func (*PublicBlockChainAPI) GetAccount

func (s *PublicBlockChainAPI) GetAccount(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*account.AccountSerializer, error)

GetAccount returns account information of an input address.

func (*PublicBlockChainAPI) GetAccountKey

func (s *PublicBlockChainAPI) GetAccountKey(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*accountkey.AccountKeySerializer, error)

GetAccountKey returns the account key of EOA at a given address. If the account of the given address is a Legacy Account or a Smart Contract Account, it will return nil.

func (*PublicBlockChainAPI) GetBalance

func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)

GetBalance returns the amount of peb for the given address in the state of the given block number or hash. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers and hash are also allowed.

func (*PublicBlockChainAPI) GetBlockByHash

func (s *PublicBlockChainAPI) GetBlockByHash(ctx context.Context, blockHash common.Hash, fullTx bool) (map[string]interface{}, error)

GetBlockByHash returns the requested block. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicBlockChainAPI) GetBlockByNumber

func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, blockNr rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)

GetBlockByNumber returns the requested block. When blockNr is -1 the chain head is returned. When fullTx is true all transactions in the block are returned in full detail, otherwise only the transaction hash is returned.

func (*PublicBlockChainAPI) GetBlockReceipts

func (s *PublicBlockChainAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]map[string]interface{}, error)

GetBlockReceipts returns the receipts of all transactions in the block identified by number or hash.

func (*PublicBlockChainAPI) GetCode

func (s *PublicBlockChainAPI) GetCode(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetCode returns the code stored at the given address in the state for the given block number or hash.

func (*PublicBlockChainAPI) GetCypressCredit

func (s *PublicBlockChainAPI) GetCypressCredit(ctx context.Context) (*CreditOutput, error)

GetCypressCredit calls getPhoto and getNames in the CypressCredit contract and returns all the results as a struct.

func (*PublicBlockChainAPI) GetHeaderByHash added in v1.7.0

func (s *PublicBlockChainAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) (map[string]interface{}, error)

GetHeaderByHash returns the requested header by hash.

func (*PublicBlockChainAPI) GetHeaderByNumber added in v1.7.0

func (s *PublicBlockChainAPI) GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (map[string]interface{}, error)

GetHeaderByNumber returns the requested canonical block header.

func (*PublicBlockChainAPI) GetProof added in v1.12.1

func (s *PublicBlockChainAPI) GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNrOrHash rpc.BlockNumberOrHash) (*EthAccountResult, error)

func (*PublicBlockChainAPI) GetStorageAt

func (s *PublicBlockChainAPI) GetStorageAt(ctx context.Context, address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetStorageAt returns the storage from the state at the given address, key and block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta block numbers and hash are also allowed.

func (*PublicBlockChainAPI) IsContractAccount

func (s *PublicBlockChainAPI) IsContractAccount(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (bool, error)

IsContractAccount returns true if the account associated with addr has a non-empty codeHash. It returns false otherwise.

func (*PublicBlockChainAPI) IsParallelDBWrite

func (s *PublicBlockChainAPI) IsParallelDBWrite() bool

IsParallelDBWrite returns if parallel write is enabled or not. If enabled, data written in WriteBlockWithState is being written in parallel manner.

func (*PublicBlockChainAPI) IsSenderTxHashIndexingEnabled

func (s *PublicBlockChainAPI) IsSenderTxHashIndexingEnabled() bool

IsSenderTxHashIndexingEnabled returns if senderTxHash to txHash mapping information indexing is enabled or not.

type PublicDebugAPI

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

PublicDebugAPI is the collection of Klaytn APIs exposed over the public debugging endpoint.

func NewPublicDebugAPI

func NewPublicDebugAPI(b Backend) *PublicDebugAPI

NewPublicDebugAPI creates a new API definition for the public debug methods of the Klaytn service.

func (*PublicDebugAPI) GetBlockRlp

func (api *PublicDebugAPI) GetBlockRlp(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (string, error)

GetBlockRlp retrieves the RLP encoded for of a single block.

type PublicKlayAPI

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

PublicKlayAPI provides an API to access Klaytn related information. It offers only methods that operate on public data that is freely available to anyone.

func NewPublicKlayAPI

func NewPublicKlayAPI(b Backend) *PublicKlayAPI

NewPublicKlayAPI creates a new Klaytn protocol API.

func (*PublicKlayAPI) DecodeAccountKey added in v1.3.0

func (s *PublicKlayAPI) DecodeAccountKey(encodedAccKey hexutil.Bytes) (*accountkey.AccountKeySerializer, error)

DecodeAccountKey gets an RLP encoded bytes of an account key and returns the decoded account key.

func (*PublicKlayAPI) EncodeAccountKey added in v1.3.0

func (s *PublicKlayAPI) EncodeAccountKey(accKey accountkey.AccountKeyJSON) (hexutil.Bytes, error)

EncodeAccountKey gets an account key of JSON format and returns RLP encoded bytes of the key.

func (*PublicKlayAPI) FeeHistory added in v1.8.0

func (s *PublicKlayAPI) FeeHistory(ctx context.Context, blockCount DecimalOrHex, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*FeeHistoryResult, error)

FeeHistory returns data relevant for fee estimation based on the specified range of blocks.

func (*PublicKlayAPI) ForkStatus added in v1.11.0

func (s *PublicKlayAPI) ForkStatus(ctx context.Context, number rpc.BlockNumber) (map[string]interface{}, error)

func (*PublicKlayAPI) GasPrice

func (s *PublicKlayAPI) GasPrice(ctx context.Context) (*hexutil.Big, error)

GasPrice returns a suggestion for a gas price (baseFee * 2).

func (*PublicKlayAPI) LowerBoundGasPrice added in v1.9.0

func (s *PublicKlayAPI) LowerBoundGasPrice(ctx context.Context) *hexutil.Big

func (*PublicKlayAPI) MaxPriorityFeePerGas added in v1.8.0

func (s *PublicKlayAPI) MaxPriorityFeePerGas(ctx context.Context) (*hexutil.Big, error)

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

func (*PublicKlayAPI) ProtocolVersion

func (s *PublicKlayAPI) ProtocolVersion() hexutil.Uint

ProtocolVersion returns the current Klaytn protocol version this node supports.

func (*PublicKlayAPI) Syncing

func (s *PublicKlayAPI) 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 synchronise 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

func (*PublicKlayAPI) UpperBoundGasPrice added in v1.9.0

func (s *PublicKlayAPI) UpperBoundGasPrice(ctx context.Context) *hexutil.Big

type PublicNetAPI

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

PublicNetAPI offers network related RPC methods

func NewPublicNetAPI

func NewPublicNetAPI(net p2p.Server, networkVersion uint64) *PublicNetAPI

NewPublicNetAPI creates a new net API instance.

func (*PublicNetAPI) Listening

func (s *PublicNetAPI) Listening() bool

Listening returns an indication if the node is listening for network connections.

func (*PublicNetAPI) NetworkID

func (s *PublicNetAPI) NetworkID() uint64

NetworkID returns the network identifier set by the command-line option --networkid.

func (*PublicNetAPI) PeerCount

func (s *PublicNetAPI) PeerCount() hexutil.Uint

PeerCount returns the number of connected peers.

func (*PublicNetAPI) PeerCountByType

func (s *PublicNetAPI) PeerCountByType() map[string]uint

PeerCountByType returns the number of connected specific types of nodes.

func (*PublicNetAPI) Version

func (s *PublicNetAPI) Version() string

Version returns the current klaytn protocol version.

type PublicTransactionPoolAPI

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

PublicTransactionPoolAPI exposes methods for the RPC interface

func NewPublicTransactionPoolAPI

func NewPublicTransactionPoolAPI(b Backend, nonceLock *AddrLocker) *PublicTransactionPoolAPI

NewPublicTransactionPoolAPI creates a new RPC service with methods specific for the transaction pool.

func (*PublicTransactionPoolAPI) GetBlockTransactionCountByHash

func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) (*hexutil.Uint, error)

GetBlockTransactionCountByHash returns the number of transactions in the block with the given hash.

func (*PublicTransactionPoolAPI) GetBlockTransactionCountByNumber

func (s *PublicTransactionPoolAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*hexutil.Uint, error)

GetBlockTransactionCountByNumber returns the number of transactions in the block with the given block number.

func (*PublicTransactionPoolAPI) GetDecodedAnchoringTransactionByHash added in v1.2.0

func (s *PublicTransactionPoolAPI) GetDecodedAnchoringTransactionByHash(ctx context.Context, hash common.Hash) (map[string]interface{}, error)

GetDecodedAnchoringTransactionByHash returns the decoded anchoring data of anchoring transaction for the given hash

func (*PublicTransactionPoolAPI) GetRawTransactionByBlockHashAndIndex

func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (hexutil.Bytes, error)

GetRawTransactionByBlockHashAndIndex returns the bytes of the transaction for the given block hash and index.

func (*PublicTransactionPoolAPI) GetRawTransactionByBlockNumberAndIndex

func (s *PublicTransactionPoolAPI) GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (hexutil.Bytes, error)

GetRawTransactionByBlockNumberAndIndex returns the bytes of the transaction for the given block number and index.

func (*PublicTransactionPoolAPI) GetRawTransactionByHash

func (s *PublicTransactionPoolAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error)

GetRawTransactionByHash returns the bytes of the transaction for the given hash.

func (*PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex

func (s *PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) (map[string]interface{}, error)

GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index.

func (*PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex

func (s *PublicTransactionPoolAPI) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) (map[string]interface{}, error)

GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index.

func (*PublicTransactionPoolAPI) GetTransactionByHash

func (s *PublicTransactionPoolAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) map[string]interface{}

GetTransactionByHash returns the transaction for the given hash

func (*PublicTransactionPoolAPI) GetTransactionBySenderTxHash

func (s *PublicTransactionPoolAPI) GetTransactionBySenderTxHash(ctx context.Context, senderTxHash common.Hash) map[string]interface{}

func (*PublicTransactionPoolAPI) GetTransactionCount

func (s *PublicTransactionPoolAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error)

GetTransactionCount returns the number of transactions the given address has sent for the given block number or hash

func (*PublicTransactionPoolAPI) GetTransactionReceipt

func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error)

GetTransactionReceipt returns the transaction receipt for the given transaction hash.

func (*PublicTransactionPoolAPI) GetTransactionReceiptBySenderTxHash

func (s *PublicTransactionPoolAPI) GetTransactionReceiptBySenderTxHash(ctx context.Context, senderTxHash common.Hash) (map[string]interface{}, error)

func (*PublicTransactionPoolAPI) GetTransactionReceiptInCache

func (s *PublicTransactionPoolAPI) GetTransactionReceiptInCache(ctx context.Context, hash common.Hash) (map[string]interface{}, error)

GetTransactionReceiptInCache returns the transaction receipt for the given transaction hash.

func (*PublicTransactionPoolAPI) PendingTransactions

func (s *PublicTransactionPoolAPI) PendingTransactions() ([]map[string]interface{}, 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 (*PublicTransactionPoolAPI) RecoverFromMessage added in v1.11.0

func (s *PublicTransactionPoolAPI) RecoverFromMessage(
	ctx context.Context, address common.Address, data, sig hexutil.Bytes, blockNumber rpc.BlockNumber,
) (common.Address, error)

RecoverFromMessage validates that the message is signed by one of the keys in the given account. Returns the recovered signer address, which may be different from the account address.

func (*PublicTransactionPoolAPI) RecoverFromTransaction added in v1.11.0

func (s *PublicTransactionPoolAPI) RecoverFromTransaction(ctx context.Context, encodedTx hexutil.Bytes, blockNumber rpc.BlockNumber) (common.Address, error)

RecoverFromTransaction recovers the sender address from a signed raw transaction. The signature is validated against the sender account's key configuration at the given block number.

func (*PublicTransactionPoolAPI) Resend

func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, sendArgs SendTxArgs, 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 (*PublicTransactionPoolAPI) SendRawTransaction

func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error)

SendRawTransaction will add the signed transaction to the transaction pool. The sender is responsible for signing the transaction and using the correct nonce.

func (*PublicTransactionPoolAPI) SendTransaction

func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args SendTxArgs) (common.Hash, error)

SendTransaction creates a transaction for the given argument, sign it and submit it to the transaction pool.

func (*PublicTransactionPoolAPI) SendTransactionAsFeePayer added in v1.3.0

func (s *PublicTransactionPoolAPI) SendTransactionAsFeePayer(ctx context.Context, args SendTxArgs) (common.Hash, error)

SendTransactionAsFeePayer creates a transaction for the given argument, sign it as a fee payer and submit it to the transaction pool.

func (*PublicTransactionPoolAPI) Sign

Sign calculates an ECDSA signature for: keccack256("\x19Klaytn 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 account associated with addr must be unlocked.

https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign

func (*PublicTransactionPoolAPI) SignTransaction

SignTransaction will sign the given transaction with the from account. The node needs to have the private key of the account corresponding with the given from address and it needs to be unlocked.

func (*PublicTransactionPoolAPI) SignTransactionAsFeePayer added in v1.3.0

func (s *PublicTransactionPoolAPI) SignTransactionAsFeePayer(ctx context.Context, args SendTxArgs) (*SignTransactionResult, error)

SignTransactionAsFeePayer will sign the given transaction as a fee payer with the from account. The node needs to have the private key of the account corresponding with the given from address and it needs to be unlocked.

type PublicTxPoolAPI

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

PublicTxPoolAPI offers and API for the transaction pool. It only operates on data that is non confidential.

func NewPublicTxPoolAPI

func NewPublicTxPoolAPI(b Backend) *PublicTxPoolAPI

NewPublicTxPoolAPI creates a new tx pool service that gives information about the transaction pool.

func (*PublicTxPoolAPI) Content

func (s *PublicTxPoolAPI) Content() map[string]map[string]map[string]map[string]interface{}

Content returns the transactions contained within the transaction pool.

func (*PublicTxPoolAPI) Inspect

func (s *PublicTxPoolAPI) Inspect() map[string]map[string]map[string]string

Inspect retrieves the content of the transaction pool and flattens it into an easily inspectable list.

func (*PublicTxPoolAPI) Status

func (s *PublicTxPoolAPI) Status() map[string]hexutil.Uint

Status returns the number of pending and queued transaction in the pool.

type SendTxArgs

type SendTxArgs struct {
	TypeInt              *types.TxType   `json:"typeInt"`
	From                 common.Address  `json:"from"`
	Recipient            *common.Address `json:"to"`
	GasLimit             *hexutil.Uint64 `json:"gas"`
	Price                *hexutil.Big    `json:"gasPrice"`
	MaxPriorityFeePerGas *hexutil.Big    `json:"maxPriorityFeePerGas"`
	MaxFeePerGas         *hexutil.Big    `json:"maxFeePerGas"`
	Amount               *hexutil.Big    `json:"value"`
	AccountNonce         *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"`
	Payload *hexutil.Bytes `json:"input"`

	CodeFormat    *params.CodeFormat `json:"codeFormat"`
	HumanReadable *bool              `json:"humanReadable"`

	Key *hexutil.Bytes `json:"key"`

	AccessList *types.AccessList `json:"accessList,omitempty"`
	ChainID    *hexutil.Big      `json:"chainId,omitempty"`

	FeePayer *common.Address `json:"feePayer"`
	FeeRatio *types.FeeRatio `json:"feeRatio"`

	TxSignatures types.TxSignaturesJSON `json:"signatures"`
}

SendTxArgs represents the arguments to submit a new transaction into the transaction pool.

type SignTransactionResult

type SignTransactionResult struct {
	Raw hexutil.Bytes      `json:"raw"`
	Tx  *types.Transaction `json:"tx"`
}

SignTransactionResult represents a RLP encoded signed transaction.

type StructLogRes

type StructLogRes struct {
	Pc              uint64             `json:"pc"`
	Op              string             `json:"op"`
	Gas             uint64             `json:"gas"`
	GasCost         uint64             `json:"gasCost"`
	Depth           int                `json:"depth"`
	Error           error              `json:"error,omitempty"`
	Stack           *[]string          `json:"stack,omitempty"`
	Memory          *[]string          `json:"memory,omitempty"`
	Storage         *map[string]string `json:"storage,omitempty"`
	Computation     uint64             `json:"computation"`
	ComputationCost uint64             `json:"computationCost"`
}

StructLogRes stores a structured log emitted by the EVM while replaying a transaction in debug mode

func FormatLogs

func FormatLogs(timeout time.Duration, logs []vm.StructLog) ([]StructLogRes, error)

formatLogs formats EVM returned structured logs for json output

type ValueTransferTxArgs

type ValueTransferTxArgs struct {
	From     common.Address  `json:"from"`
	Gas      *hexutil.Uint64 `json:"gas"`
	GasPrice *hexutil.Big    `json:"gasPrice"`
	Nonce    *hexutil.Uint64 `json:"nonce"`
	To       common.Address  `json:"to"`
	Value    *hexutil.Big    `json:"value"`
}

Directories

Path Synopsis
Package debug provides interfaces for Go runtime debugging facilities.
Package debug provides interfaces for Go runtime debugging facilities.
Package mock_api is a generated GoMock package.
Package mock_api is a generated GoMock package.

Jump to

Keyboard shortcuts

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