sdk

package module
v1.5.9 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: LGPL-3.0 Imports: 32 Imported by: 67

README

Documentation Build Status GitHub go.mod Go version GitHub release (latest by date)

Conflux Golang API

The Conflux Golang API allows any Golang client to interact with a local or remote Conflux node based on JSON-RPC 2.0 protocol. With Conflux Golang API, users can easily manage accounts, send transactions, deploy smart contracts, and query blockchain information.

Please read the documentation for more.

And read the API documentation from here.

Install go-conflux-sdk

go get github.com/Conflux-Chain/go-conflux-sdk

You can also add the Conflux Golang API into the vendor folder.

govendor fetch github.com/Conflux-Chain/go-conflux-sdk

Use go-conflux-sdk

Create Client

usd sdk.NewClient to creat a client for interact with conflux-rust node, the sdk.ClientOption is for setting Account Manager keystore folder path and retry options.

client, err := sdk.NewClient("https://test.confluxrpc.com", sdk.ClientOption{
    KeystorePath: "../context/keystore",
})
Query RPC
epoch, err := client.GetEpochNumber()
Send Transaction
chainID, err := client.GetNetworkID()
if err!=nil {
    panic(err)
}

from, err :=client.AccountManger().GetDefault()
if err!=nil {
    panic(err)
}

utx, err := client.CreateUnsignedTransaction(*from, cfxaddress.MustNewFromHex("0x1cad0b19bb29d4674531d6f115237e16afce377d", chainID), types.NewBigInt(1), nil)
if err!=nil {
    panic(err)
}

txhash, err := client.SendTransaction(utx)
Interact With Smart Contract

The most simple way to interact with contract is generator contract binding by conflux-abigen, see details from here

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountManager

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

AccountManager manages Conflux accounts.

func NewAccountManager

func NewAccountManager(keydir string, networkID uint32) *AccountManager

NewAccountManager creates an instance of AccountManager based on the keystore directory "keydir".

func (*AccountManager) Create

func (m *AccountManager) Create(passphrase string) (address types.Address, err error)

Create creates a new account and puts the keystore file into keystore directory

func (*AccountManager) CreateEthCompatible added in v0.1.1

func (m *AccountManager) CreateEthCompatible(passphrase string) (address types.Address, err error)

CreateEthCompatible creates a new account compatible with eth and puts the keystore file into keystore directory

func (*AccountManager) Delete

func (m *AccountManager) Delete(address types.Address, passphrase string) error

Delete deletes the specified account and remove the keystore file from keystore directory.

func (*AccountManager) Exists added in v1.4.2

func (m *AccountManager) Exists(address types.Address) bool

func (*AccountManager) Export added in v0.1.1

func (m *AccountManager) Export(address types.Address, passphrase string) (string, error)

Export exports private key string of address

func (*AccountManager) GetDefault

func (m *AccountManager) GetDefault() (*types.Address, error)

GetDefault return first account in keystore directory

func (*AccountManager) Import

func (m *AccountManager) Import(keyFile, passphrase, newPassphrase string) (address types.Address, err error)

Import imports account from external key file to keystore directory. Returns error if the account already exists.

func (*AccountManager) ImportKey added in v0.1.1

func (m *AccountManager) ImportKey(keyString string, passphrase string) (address types.Address, err error)

ImportKey import account from private key hex string and save to keystore directory

func (*AccountManager) List

func (m *AccountManager) List() []types.Address

List lists all accounts in keystore directory.

func (*AccountManager) Lock

func (m *AccountManager) Lock(address types.Address) error

Lock locks the specified account.

func (*AccountManager) Sign

func (m *AccountManager) Sign(tx types.UnsignedTransaction, passphrase string) (v byte, r, s []byte, err error)

Sign signs tx by passphrase and returns the signature

func (*AccountManager) SignAndEcodeTransactionWithPassphrase

func (m *AccountManager) SignAndEcodeTransactionWithPassphrase(tx types.UnsignedTransaction, passphrase string) ([]byte, error)

SignAndEcodeTransactionWithPassphrase signs tx with given passphrase and return its RLP encoded data.

func (*AccountManager) SignTransaction

func (m *AccountManager) SignTransaction(tx types.UnsignedTransaction) ([]byte, error)

SignTransaction signs tx and returns its RLP encoded data.

func (*AccountManager) SignTransactionWithPassphrase

func (m *AccountManager) SignTransactionWithPassphrase(tx types.UnsignedTransaction, passphrase string) (types.SignedTransaction, error)

SignTransactionWithPassphrase signs tx with given passphrase and returns a transction with signature

func (*AccountManager) TimedUnlock

func (m *AccountManager) TimedUnlock(address types.Address, passphrase string, timeout time.Duration) error

TimedUnlock unlocks the specified account for a period of time.

func (*AccountManager) TimedUnlockDefault

func (m *AccountManager) TimedUnlockDefault(passphrase string, timeout time.Duration) error

TimedUnlockDefault unlocks the specified account for a period of time.

func (*AccountManager) Unlock

func (m *AccountManager) Unlock(address types.Address, passphrase string) error

Unlock unlocks the specified account indefinitely.

func (*AccountManager) UnlockDefault

func (m *AccountManager) UnlockDefault(passphrase string) error

UnlockDefault unlocks the default account indefinitely.

func (*AccountManager) Update

func (m *AccountManager) Update(address types.Address, passphrase, newPassphrase string) error

Update updates the passphrase of specified account.

type AccountManagerOperator added in v0.1.1

type AccountManagerOperator interface {
	Create(passphrase string) (types.Address, error)
	Import(keyFile, passphrase, newPassphrase string) (types.Address, error)
	ImportKey(keyString string, passphrase string) (types.Address, error)
	Export(address types.Address, passphrase string) (string, error)
	Delete(address types.Address, passphrase string) error
	Update(address types.Address, passphrase, newPassphrase string) error
	List() []types.Address
	GetDefault() (*types.Address, error)
	Unlock(address types.Address, passphrase string) error
	UnlockDefault(passphrase string) error
	TimedUnlock(address types.Address, passphrase string, timeout time.Duration) error
	TimedUnlockDefault(passphrase string, timeout time.Duration) error
	Lock(address types.Address) error
	SignTransaction(tx types.UnsignedTransaction) ([]byte, error)
	SignAndEcodeTransactionWithPassphrase(tx types.UnsignedTransaction, passphrase string) ([]byte, error)
	SignTransactionWithPassphrase(tx types.UnsignedTransaction, passphrase string) (types.SignedTransaction, error)
	Sign(tx types.UnsignedTransaction, passphrase string) (v byte, r, s []byte, err error)
}

AccountManagerOperator is interface of operate actions on account manager

type Client

type Client struct {
	*providers.MiddlewarableProvider
	AccountManager AccountManagerOperator

	RpcTraceClient
	// contains filtered or unexported fields
}

Client represents a client to interact with Conflux blockchain.

func MustNewClient added in v0.1.1

func MustNewClient(nodeURL string, option ...ClientOption) *Client

MustNewClient same to NewClient but panic if failed

func NewClient

func NewClient(nodeURL string, option ...ClientOption) (*Client, error)

NewClient creates an instance of Client with specified conflux node url, it will creat account manager if option.KeystorePath not empty.

client, err := sdk.NewClient("https://test.confluxrpc.com", sdk.ClientOption{
    KeystorePath: "your keystore folder path",
	RetryCount	: 3,
})
// query rpc
epoch, err := client.GetEpochNumber()
if err != nil {
	panic(err)
}
// send transaction
chainID, err := client.GetNetworkID()
if err!=nil {
    panic(err)
}
from, err :=client.AccountManger().GetDefault()
if err!=nil {
    panic(err)
}
utx, err := client.CreateUnsignedTransaction(*from, cfxaddress.MustNewFromHex("0x1cad0b19bb29d4674531d6f115237e16afce377d", chainID), types.NewBigInt(1), nil)
if err!=nil {
    panic(err)
}
txhash, err := client.SendTransaction(utx)

func NewClientWithProvider added in v1.2.2

func NewClientWithProvider(provider interfaces.Provider) (*Client, error)

NewClientWithProvider creates an instance of Client with specified provider, and will wrap it to create a MiddlewarableProvider for be able to hooking CallContext/BatchCallContext/Subscribe

func NewClientWithRPCRequester added in v0.1.1

func NewClientWithRPCRequester(provider RpcRequester) (*Client, error)

@deperacated use NewClientWithProvider instead NewClientWithRPCRequester creates client with specified rpcRequester

func (*Client) ApplyUnsignedTransactionDefault

func (client *Client) ApplyUnsignedTransactionDefault(tx *types.UnsignedTransaction) error

ApplyUnsignedTransactionDefault set empty fields to value fetched from conflux node.

func (*Client) BatchCallRPC added in v0.1.1

func (client *Client) BatchCallRPC(b []rpc.BatchElem) error

BatchCallRPC sends all given requests as a single batch and waits for the server to return a response for all of them.

In contrast to Call, BatchCall only returns I/O errors. Any error specific to a request is reported through the Error field of the corresponding BatchElem.

Note that batch calls may not be executed atomically on the server side.

You could use UseBatchCallRpcMiddleware to add middleware for hooking BatchCallRPC

func (*Client) BatchGetBlockConfirmationRisk added in v0.1.1

func (client *Client) BatchGetBlockConfirmationRisk(blockhashes []types.Hash) (map[types.Hash]*big.Float, error)

BatchGetBlockConfirmationRisk acquires confirmation risk informations in bulk by blockhashes

func (*Client) BatchGetBlockSummarys added in v0.1.1

func (client *Client) BatchGetBlockSummarys(blockhashes []types.Hash) (map[types.Hash]*types.BlockSummary, error)

BatchGetBlockSummarys requests block summary informations in bulk by blockhashes

func (*Client) BatchGetBlockSummarysByNumber added in v0.1.1

func (client *Client) BatchGetBlockSummarysByNumber(blocknumbers []hexutil.Uint64) (map[hexutil.Uint64]*types.BlockSummary, error)

BatchGetBlockSummarysByNumber requests block summary informations in bulk by blocknumbers

func (*Client) BatchGetRawBlockConfirmationRisk added in v0.1.1

func (client *Client) BatchGetRawBlockConfirmationRisk(blockhashes []types.Hash) (map[types.Hash]*big.Int, error)

BatchGetRawBlockConfirmationRisk requests raw confirmation risk informations in bulk by blockhashes

func (*Client) BatchGetTxByHashes added in v0.1.1

func (client *Client) BatchGetTxByHashes(txhashes []types.Hash) (map[types.Hash]*types.Transaction, error)

BatchGetTxByHashes requests transaction informations in bulk by txhashes

func (*Client) Call

func (client *Client) Call(request types.CallRequest, epoch *types.EpochOrBlockHash) (result hexutil.Bytes, err error)

Call executes a message call transaction "request" at specified epoch, which is directly executed in the VM of the node, but never mined into the block chain and returns the contract execution result.

func (*Client) CallRPC

func (client *Client) CallRPC(result interface{}, method string, args ...interface{}) error

CallRPC performs a JSON-RPC call with the given arguments and unmarshals into result if no error occurred.

The result must be a pointer so that package json can unmarshal into it. You can also pass nil, in which case the result is ignored.

You could use UseCallRpcMiddleware to add middleware for hooking CallRPC

func (*Client) CheckBalanceAgainstTransaction added in v0.1.1

func (client *Client) CheckBalanceAgainstTransaction(accountAddress types.Address,
	contractAddress types.Address,
	gasLimit *hexutil.Big,
	gasPrice *hexutil.Big,
	storageLimit *hexutil.Big,
	epoch ...*types.Epoch) (response types.CheckBalanceAgainstTransactionResponse, err error)

CheckBalanceAgainstTransaction checks if user balance is enough for the transaction.

func (*Client) CreateUnsignedTransaction

func (client *Client) CreateUnsignedTransaction(from types.Address, to types.Address, amount *hexutil.Big, data []byte) (types.UnsignedTransaction, error)

CreateUnsignedTransaction creates an unsigned transaction by parameters, and the other fields will be set to values fetched from conflux node.

func (*Client) Debug

func (client *Client) Debug() RpcDebug

Debug returns RpcDebugClient for invoke rpc with debug namespace

func (*Client) DeployContract

func (client *Client) DeployContract(option *types.ContractDeployOption, abiJSON []byte,
	bytecode []byte, constroctorParams ...interface{}) *ContractDeployResult

DeployContract deploys a contract by abiJSON, bytecode and consturctor params. It returns a ContractDeployState instance which contains 3 channels for notifying when state changed.

func (*Client) EstimateGasAndCollateral

func (client *Client) EstimateGasAndCollateral(request types.CallRequest, epoch ...*types.Epoch) (estimat types.Estimate, err error)

EstimateGasAndCollateral excutes a message call "request" and returns the amount of the gas used and storage for collateral

func (*Client) Filter added in v1.5.4

func (client *Client) Filter() RpcFilter

func (*Client) GetAccountInfo added in v0.1.1

func (client *Client) GetAccountInfo(account types.Address, epoch ...*types.Epoch) (accountInfo types.AccountInfo, err error)

GetAccountInfo returns account related states of the given account

func (*Client) GetAccountManager added in v0.1.1

func (client *Client) GetAccountManager() AccountManagerOperator

GetAccountManager returns account manager of client

func (*Client) GetAccountPendingInfo added in v0.1.1

func (client *Client) GetAccountPendingInfo(address types.Address) (pendignInfo *types.AccountPendingInfo, err error)

GetAccountPendingInfo gets transaction pending info by account address

func (*Client) GetAccountPendingTransactions added in v0.1.1

func (client *Client) GetAccountPendingTransactions(address types.Address, startNonce *hexutil.Big, limit *hexutil.Uint64) (pendingTxs types.AccountPendingTransactions, err error)

GetAccountPendingTransactions get transaction pending info by account address

func (*Client) GetAccumulateInterestRate added in v0.1.1

func (client *Client) GetAccumulateInterestRate(epoch ...*types.Epoch) (intersetRate *hexutil.Big, err error)

GetAccumulateInterestRate returns accumulate interest rate of the given epoch

func (*Client) GetAdmin added in v0.1.1

func (client *Client) GetAdmin(contractAddress types.Address, epoch ...*types.Epoch) (admin *types.Address, err error)

GetAdmin returns admin of the given contract, it will return nil if contract not exist

func (*Client) GetBalance

func (client *Client) GetBalance(address types.Address, epoch ...*types.EpochOrBlockHash) (balance *hexutil.Big, err error)

GetBalance returns the balance of specified address at epoch.

func (*Client) GetBestBlockHash

func (client *Client) GetBestBlockHash() (hash types.Hash, err error)

GetBestBlockHash returns the current best block hash.

func (*Client) GetBlockByBlockNumber added in v0.1.1

func (client *Client) GetBlockByBlockNumber(blockNumer hexutil.Uint64) (block *types.Block, err error)

GetBlockByHash returns the block of specified block number

func (*Client) GetBlockByEpoch

func (client *Client) GetBlockByEpoch(epoch *types.Epoch) (block *types.Block, err error)

GetBlockByEpoch returns the block of specified epoch. If the epoch is invalid, return the concrete error.

func (*Client) GetBlockByHash

func (client *Client) GetBlockByHash(blockHash types.Hash) (block *types.Block, err error)

GetBlockByHash returns the block of specified blockHash If the block is not found, return nil.

func (*Client) GetBlockByHashWithPivotAssumption added in v0.1.1

func (client *Client) GetBlockByHashWithPivotAssumption(blockHash types.Hash, pivotHash types.Hash, epoch hexutil.Uint64) (block types.Block, err error)

GetBlockByHashWithPivotAssumption returns block with given hash and pivot chain assumption.

func (*Client) GetBlockConfirmationRisk added in v0.1.1

func (client *Client) GetBlockConfirmationRisk(blockHash types.Hash) (*big.Float, error)

GetBlockConfirmationRisk indicates the probability that the pivot block of the epoch where the block is located becomes a normal block.

it's (raw confirmation risk coefficient/ (2^256-1))

func (*Client) GetBlockRewardInfo added in v0.1.1

func (client *Client) GetBlockRewardInfo(epoch types.Epoch) (rewardInfo []types.RewardInfo, err error)

GetBlockRewardInfo returns block reward information in an epoch

func (*Client) GetBlockSummaryByBlockNumber added in v0.1.1

func (client *Client) GetBlockSummaryByBlockNumber(blockNumer hexutil.Uint64) (block *types.BlockSummary, err error)

GetBlockSummaryByBlockNumber returns the block summary of specified block number.

func (*Client) GetBlockSummaryByEpoch

func (client *Client) GetBlockSummaryByEpoch(epoch *types.Epoch) (blockSummary *types.BlockSummary, err error)

GetBlockSummaryByEpoch returns the block summary of specified epoch. If the epoch is invalid, return the concrete error.

func (*Client) GetBlockSummaryByHash

func (client *Client) GetBlockSummaryByHash(blockHash types.Hash) (blockSummary *types.BlockSummary, err error)

GetBlockSummaryByHash returns the block summary of specified blockHash If the block is not found, return nil.

func (*Client) GetBlocksByEpoch

func (client *Client) GetBlocksByEpoch(epoch *types.Epoch) (blockHashes []types.Hash, err error)

GetBlocksByEpoch returns the blocks hash in the specified epoch.

func (*Client) GetChainID added in v0.1.1

func (client *Client) GetChainID() (uint32, error)

GetNetworkID returns networkID of connecting conflux node

func (*Client) GetChainIDCached added in v0.1.1

func (client *Client) GetChainIDCached() uint32

GetChainIDCached returns chached networkID created when new client

func (*Client) GetClientVersion added in v0.1.1

func (client *Client) GetClientVersion() (clientVersion string, err error)

GetClientVersion returns the client version as a string

func (*Client) GetCode

func (client *Client) GetCode(address types.Address, epoch ...*types.EpochOrBlockHash) (code hexutil.Bytes, err error)

GetCode returns the bytecode in HEX format of specified address at epoch.

func (*Client) GetCollateralForStorage added in v0.1.1

func (client *Client) GetCollateralForStorage(account types.Address, epoch ...*types.Epoch) (storage *hexutil.Big, err error)

GetCollateralForStorage returns balance of the given account.

func (*Client) GetCollateralInfo added in v1.5.7

func (client *Client) GetCollateralInfo(epoch ...*types.Epoch) (info types.StorageCollateralInfo, err error)

func (*Client) GetContract

func (client *Client) GetContract(abiJSON []byte, deployedAt *types.Address) (*Contract, error)

GetContract creates a contract instance according to abi json and it's deployed address

func (*Client) GetDepositList added in v0.1.1

func (client *Client) GetDepositList(address types.Address, epoch ...*types.Epoch) (depositInfos []types.DepositInfo, err error)

GetDepositList returns deposit list of the given account.

func (*Client) GetEpochNumber

func (client *Client) GetEpochNumber(epoch ...*types.Epoch) (epochNumber *hexutil.Big, err error)

GetEpochNumber returns the highest or specified epoch number.

func (*Client) GetEpochReceipts added in v0.1.1

func (client *Client) GetEpochReceipts(epoch types.EpochOrBlockHash, include_eth_recepits ...bool) (receipts [][]types.TransactionReceipt, err error)

func (*Client) GetEpochReceiptsByPivotBlockHash added in v0.1.1

func (client *Client) GetEpochReceiptsByPivotBlockHash(hash types.Hash) (receipts [][]types.TransactionReceipt, err error)

func (*Client) GetGasPrice

func (client *Client) GetGasPrice() (gasPrice *hexutil.Big, err error)

GetGasPrice returns the recent mean gas price.

func (*Client) GetInterestRate added in v0.1.1

func (client *Client) GetInterestRate(epoch ...*types.Epoch) (intersetRate *hexutil.Big, err error)

GetInterestRate returns interest rate of the given epoch

func (*Client) GetLogs

func (client *Client) GetLogs(filter types.LogFilter) (logs []types.Log, err error)

GetLogs returns logs that matching the specified filter.

func (*Client) GetNetworkID added in v0.1.1

func (client *Client) GetNetworkID() (uint32, error)

GetNetworkID returns networkID of connecting conflux node

func (*Client) GetNetworkIDCached added in v0.1.1

func (client *Client) GetNetworkIDCached() uint32

GetNetworkIDCached returns chached networkID created when new client

func (*Client) GetNextNonce

func (client *Client) GetNextNonce(address types.Address, epoch ...*types.EpochOrBlockHash) (nonce *hexutil.Big, err error)

GetNextNonce returns the next transaction nonce of address

func (*Client) GetNextUsableNonce added in v0.1.1

func (client *Client) GetNextUsableNonce(user types.Address) (nonce *hexutil.Big, err error)

func (*Client) GetNodeURL added in v0.1.1

func (client *Client) GetNodeURL() string

GetNodeURL returns node url

func (*Client) GetOpenedMethodGroups added in v0.1.1

func (client *Client) GetOpenedMethodGroups() (openedGroups []string, err error)

GetOpenedMethodGroups returns openning method groups

func (*Client) GetParamsFromVote added in v1.4.1

func (client *Client) GetParamsFromVote(epoch ...*types.Epoch) (info postypes.VoteParamsInfo, err error)

func (*Client) GetPoSEconomics added in v0.1.1

func (client *Client) GetPoSEconomics(epoch ...*types.Epoch) (posEconomics types.PoSEconomics, err error)

GetPoSEconomics returns accumulate interest rate of the given epoch

func (*Client) GetPoSRewardByEpoch added in v0.1.1

func (client *Client) GetPoSRewardByEpoch(epoch types.Epoch) (reward *postypes.EpochReward, err error)

GetPosRewardByEpoch returns pos rewarded in this epoch

func (*Client) GetRawBlockConfirmationRisk added in v0.1.1

func (client *Client) GetRawBlockConfirmationRisk(blockhash types.Hash) (risk *hexutil.Big, err error)

GetRawBlockConfirmationRisk indicates the risk coefficient that the pivot block of the epoch where the block is located becomes a normal block. It will return nil if block not exist

func (*Client) GetSkippedBlocksByEpoch added in v0.1.1

func (client *Client) GetSkippedBlocksByEpoch(epoch *types.Epoch) (blockHashs []types.Hash, err error)

GetSkippedBlocksByEpoch returns skipped block hashes of given epoch

func (*Client) GetSponsorInfo added in v0.1.1

func (client *Client) GetSponsorInfo(contractAddress types.Address, epoch ...*types.Epoch) (sponsor types.SponsorInfo, err error)

GetSponsorInfo returns sponsor information of the given contract

func (*Client) GetStakingBalance added in v0.1.1

func (client *Client) GetStakingBalance(account types.Address, epoch ...*types.Epoch) (balance *hexutil.Big, err error)

GetStakingBalance returns balance of the given account.

func (*Client) GetStatus added in v0.1.1

func (client *Client) GetStatus() (status types.Status, err error)

GetStatus returns status of connecting conflux node

func (*Client) GetStorageAt added in v0.1.1

func (client *Client) GetStorageAt(address types.Address, position *hexutil.Big, epoch ...*types.EpochOrBlockHash) (storageEntries hexutil.Bytes, err error)

GetStorageAt returns storage entries from a given contract.

func (*Client) GetStorageRoot added in v0.1.1

func (client *Client) GetStorageRoot(address types.Address, epoch ...*types.Epoch) (storageRoot *types.StorageRoot, err error)

GetStorageRoot returns storage root of given address

func (*Client) GetSupplyInfo added in v0.1.1

func (client *Client) GetSupplyInfo(epoch ...*types.Epoch) (info types.TokenSupplyInfo, err error)

GetSupplyInfo Return information about total token supply.

func (*Client) GetTransactionByHash

func (client *Client) GetTransactionByHash(txHash types.Hash) (tx *types.Transaction, err error)

GetTransactionByHash returns transaction for the specified txHash. If the transaction is not found, return nil.

func (*Client) GetTransactionReceipt

func (client *Client) GetTransactionReceipt(txHash types.Hash) (receipt *types.TransactionReceipt, err error)

GetTransactionReceipt returns the receipt of specified transaction hash. If no receipt is found, return nil.

func (*Client) GetVoteList added in v0.1.1

func (client *Client) GetVoteList(address types.Address, epoch ...*types.Epoch) (voteStakeInfos []types.VoteStakeInfo, err error)

GetVoteList returns vote list of the given account.

func (*Client) MustNewAddress added in v0.1.1

func (client *Client) MustNewAddress(base32OrHex string) types.Address

MustNewAddress create conflux address by base32 string or hex40 string, if base32OrHex is base32 and networkID is passed it will create cfx Address use networkID of current client. it will painc if error occured.

func (*Client) NewAddress added in v0.1.1

func (client *Client) NewAddress(base32OrHex string) (types.Address, error)

NewAddress create conflux address by base32 string or hex40 string, if base32OrHex is base32 and networkID is passed it will create cfx Address use networkID of current client.

func (*Client) Pos added in v0.1.1

func (client *Client) Pos() RpcPos

Pos returns RpcPosClient for invoke rpc with pos namespace

func (*Client) Provider added in v1.2.0

func (client *Client) Provider() *providers.MiddlewarableProvider

Provider returns the middlewarable provider

func (*Client) SendRawTransaction

func (client *Client) SendRawTransaction(rawData []byte) (hash types.Hash, err error)

SendRawTransaction sends signed transaction and returns its hash.

func (*Client) SendTransaction

func (client *Client) SendTransaction(tx types.UnsignedTransaction) (types.Hash, error)

SendTransaction signs and sends transaction to conflux node and returns the transaction hash.

func (*Client) SetAccountManager

func (client *Client) SetAccountManager(accountManager AccountManagerOperator)

SetAccountManager sets account manager for sign transaction

func (*Client) SetChainId added in v1.5.7

func (client *Client) SetChainId(chainId uint32)

func (*Client) SetNetworkId added in v1.5.7

func (client *Client) SetNetworkId(networkId uint32)

func (*Client) SignEncodedTransactionAndSend

func (client *Client) SignEncodedTransactionAndSend(encodedTx []byte, v byte, r, s []byte) (*types.Transaction, error)

SignEncodedTransactionAndSend signs RLP encoded transaction "encodedTx" by signature "r,s,v" and sends it to node, and returns responsed transaction.

func (*Client) SubscribeEpochs added in v0.1.1

func (client *Client) SubscribeEpochs(channel chan types.WebsocketEpochResponse, subscriptionEpochType ...types.Epoch) (*rpc.ClientSubscription, error)

SubscribeEpochs subscribes consensus results: the total order of blocks, as expressed by a sequence of epochs. Currently subscriptionEpochType only support "latest_mined" and "latest_state"

func (*Client) SubscribeEpochsWithReconn added in v1.4.3

func (client *Client) SubscribeEpochsWithReconn(channel chan types.WebsocketEpochResponse, subscriptionEpochType ...types.Epoch) *rpc.ReconnClientSubscription

SubscribeEpochsWithReconn subscribes consensus results: the total order of blocks, as expressed by a sequence of epochs. Currently subscriptionEpochType only support "latest_mined" and "latest_state" It will auto re-subscribe if lost connect.

func (*Client) SubscribeLogs added in v0.1.1

func (client *Client) SubscribeLogs(channel chan types.SubscriptionLog, filter types.LogFilter) (*rpc.ClientSubscription, error)

SubscribeLogs subscribes all logs matching a certain filter, in order.

func (*Client) SubscribeLogsWithReconn added in v1.4.3

func (client *Client) SubscribeLogsWithReconn(channel chan types.SubscriptionLog, filter types.LogFilter) *rpc.ReconnClientSubscription

SubscribeLogs subscribes all logs matching a certain filter, in order. It will auto re-subscribe if lost connect.

func (*Client) SubscribeNewHeads added in v0.1.1

func (client *Client) SubscribeNewHeads(channel chan types.BlockHeader) (*rpc.ClientSubscription, error)

SubscribeNewHeads subscribes all new block headers participating in the consensus.

func (*Client) SubscribeNewHeadsWitReconn added in v1.4.3

func (client *Client) SubscribeNewHeadsWitReconn(channel chan types.BlockHeader) *rpc.ReconnClientSubscription

SubscribeNewHeadsWitReconn subscribes all new block headers participating in the consensus. It will auto re-subscribe if lost connect.

func (*Client) Trace added in v1.5.4

func (client *Client) Trace() RpcTrace

func (*Client) TxPool added in v0.1.1

func (client *Client) TxPool() RpcTxpool

TxPool returns RpcTxPoolClient for invoke rpc with txpool namespace

func (*Client) WaitForTransationBePacked added in v0.1.1

func (client *Client) WaitForTransationBePacked(txhash types.Hash, duration time.Duration) (*types.Transaction, error)

WaitForTransationBePacked returns transaction when it is packed

func (*Client) WaitForTransationReceipt added in v0.1.1

func (client *Client) WaitForTransationReceipt(txhash types.Hash, duration time.Duration) (*types.TransactionReceipt, error)

WaitForTransationReceipt waits for transaction receipt valid

func (*Client) WithContext added in v1.5.9

func (client *Client) WithContext(ctx context.Context) *Client

WithContext creates a new Client with specified context

type ClientOperator

type ClientOperator interface {
	GetNodeURL() string
	NewAddress(base32OrHex string) (types.Address, error)
	MustNewAddress(base32OrHex string) types.Address

	CallRPC(result interface{}, method string, args ...interface{}) error
	BatchCallRPC(b []rpc.BatchElem) error

	SetAccountManager(accountManager AccountManagerOperator)
	GetAccountManager() AccountManagerOperator

	SetNetworkId(networkId uint32)
	SetChainId(chainId uint32)

	Pos() RpcPos
	TxPool() RpcTxpool
	Debug() RpcDebug
	Filter() RpcFilter
	Trace() RpcTrace

	GetGasPrice() (*hexutil.Big, error)
	GetNextNonce(address types.Address, epoch ...*types.EpochOrBlockHash) (*hexutil.Big, error)
	GetStatus() (types.Status, error)
	GetNetworkID() (uint32, error)
	GetChainID() (uint32, error)
	GetEpochNumber(epoch ...*types.Epoch) (*hexutil.Big, error)
	GetBalance(address types.Address, epoch ...*types.EpochOrBlockHash) (*hexutil.Big, error)
	GetCode(address types.Address, epoch ...*types.EpochOrBlockHash) (hexutil.Bytes, error)
	GetBlockSummaryByHash(blockHash types.Hash) (*types.BlockSummary, error)
	GetBlockByHash(blockHash types.Hash) (*types.Block, error)
	GetBlockSummaryByEpoch(epoch *types.Epoch) (*types.BlockSummary, error)
	GetBlockByEpoch(epoch *types.Epoch) (*types.Block, error)
	GetBlockByBlockNumber(blockNumer hexutil.Uint64) (block *types.Block, err error)
	GetBlockSummaryByBlockNumber(blockNumer hexutil.Uint64) (block *types.BlockSummary, err error)
	GetBestBlockHash() (types.Hash, error)
	GetRawBlockConfirmationRisk(blockhash types.Hash) (*hexutil.Big, error)
	GetBlockConfirmationRisk(blockHash types.Hash) (*big.Float, error)

	SendTransaction(tx types.UnsignedTransaction) (types.Hash, error)
	SendRawTransaction(rawData []byte) (types.Hash, error)
	SignEncodedTransactionAndSend(encodedTx []byte, v byte, r, s []byte) (*types.Transaction, error)

	Call(request types.CallRequest, epoch *types.EpochOrBlockHash) (hexutil.Bytes, error)

	GetLogs(filter types.LogFilter) ([]types.Log, error)
	GetTransactionByHash(txHash types.Hash) (*types.Transaction, error)
	EstimateGasAndCollateral(request types.CallRequest, epoch ...*types.Epoch) (types.Estimate, error)
	GetBlocksByEpoch(epoch *types.Epoch) ([]types.Hash, error)
	GetTransactionReceipt(txHash types.Hash) (*types.TransactionReceipt, error)
	GetAdmin(contractAddress types.Address, epoch ...*types.Epoch) (admin *types.Address, err error)
	GetSponsorInfo(contractAddress types.Address, epoch ...*types.Epoch) (sponsor types.SponsorInfo, err error)
	GetStakingBalance(account types.Address, epoch ...*types.Epoch) (balance *hexutil.Big, err error)
	GetCollateralForStorage(account types.Address, epoch ...*types.Epoch) (storage *hexutil.Big, err error)
	GetStorageAt(address types.Address, position *hexutil.Big, epoch ...*types.EpochOrBlockHash) (storageEntries hexutil.Bytes, err error)
	GetStorageRoot(address types.Address, epoch ...*types.Epoch) (storageRoot *types.StorageRoot, err error)
	GetBlockByHashWithPivotAssumption(blockHash types.Hash, pivotHash types.Hash, epoch hexutil.Uint64) (block types.Block, err error)
	CheckBalanceAgainstTransaction(accountAddress types.Address,
		contractAddress types.Address,
		gasLimit *hexutil.Big,
		gasPrice *hexutil.Big,
		storageLimit *hexutil.Big,
		epoch ...*types.Epoch) (response types.CheckBalanceAgainstTransactionResponse, err error)
	GetSkippedBlocksByEpoch(epoch *types.Epoch) (blockHashs []types.Hash, err error)
	GetAccountInfo(account types.Address, epoch ...*types.Epoch) (accountInfo types.AccountInfo, err error)
	GetInterestRate(epoch ...*types.Epoch) (intersetRate *hexutil.Big, err error)
	GetAccumulateInterestRate(epoch ...*types.Epoch) (intersetRate *hexutil.Big, err error)
	GetBlockRewardInfo(epoch types.Epoch) (rewardInfo []types.RewardInfo, err error)

	GetClientVersion() (clientVersion string, err error)
	GetDepositList(address types.Address, epoch ...*types.Epoch) ([]types.DepositInfo, error)
	GetVoteList(address types.Address, epoch ...*types.Epoch) ([]types.VoteStakeInfo, error)
	GetSupplyInfo(epoch ...*types.Epoch) (info types.TokenSupplyInfo, err error)

	CreateUnsignedTransaction(from types.Address, to types.Address, amount *hexutil.Big, data []byte) (types.UnsignedTransaction, error)
	ApplyUnsignedTransactionDefault(tx *types.UnsignedTransaction) error

	DeployContract(option *types.ContractDeployOption, abiJSON []byte,
		bytecode []byte, constroctorParams ...interface{}) *ContractDeployResult
	GetContract(abiJSON []byte, deployedAt *types.Address) (*Contract, error)
	GetAccountPendingInfo(address types.Address) (pendignInfo *types.AccountPendingInfo, err error)
	GetAccountPendingTransactions(address types.Address, startNonce *hexutil.Big, limit *hexutil.Uint64) (pendingTxs types.AccountPendingTransactions, err error)
	GetPoSEconomics(epoch ...*types.Epoch) (posEconomics types.PoSEconomics, err error)
	GetOpenedMethodGroups() (openedGroups []string, err error)
	GetPoSRewardByEpoch(epoch types.Epoch) (reward *postypes.EpochReward, err error)

	GetEpochReceipts(epoch types.EpochOrBlockHash, include_eth_recepits ...bool) (receipts [][]types.TransactionReceipt, err error)
	GetEpochReceiptsByPivotBlockHash(hash types.Hash) (receipts [][]types.TransactionReceipt, err error)

	GetParamsFromVote(epoch ...*types.Epoch) (info postypes.VoteParamsInfo, err error)
	GetCollateralInfo(epoch ...*types.Epoch) (info types.StorageCollateralInfo, err error)

	BatchGetTxByHashes(txhashes []types.Hash) (map[types.Hash]*types.Transaction, error)
	BatchGetBlockSummarys(blockhashes []types.Hash) (map[types.Hash]*types.BlockSummary, error)
	BatchGetBlockSummarysByNumber(blocknumbers []hexutil.Uint64) (map[hexutil.Uint64]*types.BlockSummary, error)
	BatchGetRawBlockConfirmationRisk(blockhashes []types.Hash) (map[types.Hash]*big.Int, error)
	BatchGetBlockConfirmationRisk(blockhashes []types.Hash) (map[types.Hash]*big.Float, error)

	Close()

	SubscribeNewHeads(channel chan types.BlockHeader) (*rpc.ClientSubscription, error)
	SubscribeEpochs(channel chan types.WebsocketEpochResponse, subscriptionEpochType ...types.Epoch) (*rpc.ClientSubscription, error)
	SubscribeLogs(channel chan types.SubscriptionLog, filter types.LogFilter) (*rpc.ClientSubscription, error)

	WaitForTransationBePacked(txhash types.Hash, duration time.Duration) (*types.Transaction, error)
	WaitForTransationReceipt(txhash types.Hash, duration time.Duration) (*types.TransactionReceipt, error)
	GetNextUsableNonce(user types.Address) (nonce *hexutil.Big, err error)

	GetChainIDCached() uint32
	GetNetworkIDCached() uint32
}

ClientOperator is interface of operate actions on client

type ClientOption added in v0.1.1

type ClientOption struct {
	KeystorePath string
	// retry
	RetryCount    int
	RetryInterval time.Duration `default:"1s"`
	// timeout of request
	RequestTimeout time.Duration `default:"30s"`
	// Maximum number of connections may be established. The default value is 512. It's only useful for http(s) prococal
	MaxConnectionPerHost int

	Logger io.Writer

	CircuitBreakerOption *providers.DefaultCircuitBreakerOption
}

ClientOption for set keystore path and flags for retry and timeout

The simplest way to set logger is to use the types.DefaultCallRpcLog and types.DefaultBatchCallRPCLog

type Contract

type Contract struct {
	ABI     abi.ABI
	Client  ClientOperator
	Address *types.Address
}

Contract represents a smart contract. You can conveniently create contract by Client.GetContract or Client.DeployContract.

func NewContract added in v0.1.1

func NewContract(abiJSON []byte, client ClientOperator, address *types.Address) (*Contract, error)

NewContract creates contract by abi and deployed address

func (*Contract) Call

func (contract *Contract) Call(option *types.ContractMethodCallOption, resultPtr interface{}, method string, args ...interface{}) error

Call calls to the contract method with args and fills the excuted result to the "resultPtr".

the resultPtr should be a pointer of the method output struct type.

please refer https://github.com/Conflux-Chain/go-conflux-sdk/blob/master/README.md to get the mappings of solidity types to go types

func (*Contract) DecodeEvent added in v0.1.1

func (contract *Contract) DecodeEvent(out interface{}, event string, log types.Log) error

DecodeEvent unpacks a retrieved log into the provided output structure.

please refer https://github.com/Conflux-Chain/go-conflux-sdk/blob/master/README.md to get the mappings of solidity types to go types

func (*Contract) GetData

func (contract *Contract) GetData(method string, args ...interface{}) ([]byte, error)

GetData packs the given method name to conform the ABI of the contract. Method call's data will consist of method_id, args0, arg1, ... argN. Method id consists of 4 bytes and arguments are all 32 bytes. Method ids are created from the first 4 bytes of the hash of the methods string signature. (signature = baz(uint32,string32))

please refer https://github.com/Conflux-Chain/go-conflux-sdk/blob/master/README.md to get the mappings of solidity types to go types

func (*Contract) SendTransaction

func (contract *Contract) SendTransaction(option *types.ContractMethodSendOption, method string, args ...interface{}) (types.Hash, error)

SendTransaction sends a transaction to the contract method with args and returns its transaction hash

please refer https://github.com/Conflux-Chain/go-conflux-sdk/blob/master/README.md to get the mappings of solidity types to go types

type ContractDeployResult added in v0.1.1

type ContractDeployResult struct {
	//DoneChannel channel for notifying when contract deployed done
	DoneChannel      <-chan struct{}
	TransactionHash  *types.Hash
	Error            error
	DeployedContract *Contract
}

ContractDeployResult for state change notification when deploying contract

type Contractor

type Contractor interface {
	GetData(method string, args ...interface{}) ([]byte, error)
	Call(option *types.ContractMethodCallOption, resultPtr interface{}, method string, args ...interface{}) error
	SendTransaction(option *types.ContractMethodSendOption, method string, args ...interface{}) (types.Hash, error)
	DecodeEvent(out interface{}, event string, log types.Log) error
}

Contractor is interface of contract operator

type HTTPRequester

type HTTPRequester interface {
	Get(url string) (resp *http.Response, err error)
}

HTTPRequester is interface for emitting a http requester

type RpcDebug added in v0.1.1

type RpcDebug interface {
	TxpoolGetAccountTransactions(address types.Address) (val []types.Transaction, err error)
	GetEpochReceipts(epoch types.EpochOrBlockHash, include_eth_recepits ...bool) ([][]types.TransactionReceipt, error)
	GetEpochReceiptsByPivotBlockHash(hash types.Hash) (receipts [][]types.TransactionReceipt, err error)
	GetEpochReceiptProofByTransaction(hash types.Hash) (proof *types.EpochReceiptProof, err error)
	GetTransactionsByEpoch(epoch types.Epoch) (wrapTransactions []types.WrapTransaction, err error)
	GetTransactionsByBlock(hash types.Hash) (wrapTransactions []types.WrapTransaction, err error)
}

type RpcDebugClient added in v0.1.1

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

RpcDebugClient used to access debug namespace RPC of Conflux blockchain.

func NewRpcDebugClient added in v0.1.1

func NewRpcDebugClient(core *Client) RpcDebugClient

NewRpcDebugClient creates a new RpcDebugClient instance.

func (*RpcDebugClient) GetEpochReceiptProofByTransaction added in v1.5.4

func (c *RpcDebugClient) GetEpochReceiptProofByTransaction(hash types.Hash) (proof *types.EpochReceiptProof, err error)

func (*RpcDebugClient) GetEpochReceipts added in v0.1.1

func (c *RpcDebugClient) GetEpochReceipts(epoch types.EpochOrBlockHash, include_eth_recepits ...bool) (receipts [][]types.TransactionReceipt, err error)

GetEpochReceiptsByEpochNumber returns epoch receipts by epoch number

func (*RpcDebugClient) GetEpochReceiptsByPivotBlockHash added in v0.1.1

func (c *RpcDebugClient) GetEpochReceiptsByPivotBlockHash(hash types.Hash) (receipts [][]types.TransactionReceipt, err error)

GetEpochReceiptsByPivotBlockHash returns epoch receipts by pivot block hash

func (*RpcDebugClient) GetTransactionsByBlock added in v1.5.4

func (c *RpcDebugClient) GetTransactionsByBlock(hash types.Hash) (wrapTransactions []types.WrapTransaction, err error)

func (*RpcDebugClient) GetTransactionsByEpoch added in v1.5.4

func (c *RpcDebugClient) GetTransactionsByEpoch(epoch types.Epoch) (wrapTransactions []types.WrapTransaction, err error)

func (*RpcDebugClient) TxpoolGetAccountTransactions added in v0.1.1

func (c *RpcDebugClient) TxpoolGetAccountTransactions(address types.Address) (val []types.Transaction, err error)

TxpoolGetAccountTransactions returns account ready + deferred transactions

type RpcFilter added in v1.5.4

type RpcFilter interface {
	NewFilter(logFilter types.LogFilter) (filterId *rpc.ID, err error)
	NewBlockFilter() (filterId *rpc.ID, err error)
	NewPendingTransactionFilter() (filterId *rpc.ID, err error)
	GetFilterChanges(filterId rpc.ID) (cfxFilterChanges *types.CfxFilterChanges, err error)
	GetFilterLogs(filterID rpc.ID) (logs []types.Log, err error)
	UninstallFilter(filterId rpc.ID) (isUninstalled bool, err error)
}

type RpcFilterClient added in v1.5.4

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

func (*RpcFilterClient) GetFilterChanges added in v1.5.4

func (c *RpcFilterClient) GetFilterChanges(filterId rpc.ID) (cfxFilterChanges *types.CfxFilterChanges, err error)

func (*RpcFilterClient) GetFilterLogs added in v1.5.4

func (c *RpcFilterClient) GetFilterLogs(filterID rpc.ID) (logs []types.Log, err error)

func (*RpcFilterClient) NewBlockFilter added in v1.5.4

func (c *RpcFilterClient) NewBlockFilter() (filterId *rpc.ID, err error)

func (*RpcFilterClient) NewFilter added in v1.5.4

func (c *RpcFilterClient) NewFilter(logFilter types.LogFilter) (filterId *rpc.ID, err error)

func (*RpcFilterClient) NewPendingTransactionFilter added in v1.5.4

func (c *RpcFilterClient) NewPendingTransactionFilter() (filterId *rpc.ID, err error)

func (*RpcFilterClient) UninstallFilter added in v1.5.4

func (c *RpcFilterClient) UninstallFilter(filterId rpc.ID) (isUninstalled bool, err error)

type RpcPos added in v0.1.1

type RpcPos interface {
	GetStatus() (postypes.Status, error)
	GetAccount(address postypes.Address, blockNumber ...hexutil.Uint64) (postypes.Account, error)
	GetAccountByPowAddress(address cfxaddress.Address, blockNumber ...hexutil.Uint64) (account postypes.Account, err error)
	GetCommittee(blockNumber ...hexutil.Uint64) (postypes.CommitteeState, error)
	GetBlockByHash(types.Hash) (*postypes.Block, error)
	GetBlockByNumber(blockNumber postypes.BlockNumber) (*postypes.Block, error)
	GetTransactionByNumber(txNumber hexutil.Uint64) (*postypes.Transaction, error)
	GetRewardsByEpoch(epochNumber hexutil.Uint64) (postypes.EpochReward, error)
	GetConsensusBlocks() (blocks []*postypes.Block, err error)
	GetEpochState(epochNumber ...hexutil.Uint64) (epochState *postypes.EpochState, err error)
	GetLedgerInfoByBlockNumber(blockNumber postypes.BlockNumber) (ledgerInfoWithSigs *postypes.LedgerInfoWithSignatures, err error)
	GetLedgerInfoByEpochAndRound(epochNumber hexutil.Uint64, round hexutil.Uint64) (ledgerInfoWithSigs *postypes.LedgerInfoWithSignatures, err error)
	GetLedgerInfoByEpoch(epochNumber ...hexutil.Uint64) (ledgerInfoWithSigs *postypes.LedgerInfoWithSignatures, err error)
	GetLedgerInfosByEpoch(startEpoch hexutil.Uint64, endEpoch hexutil.Uint64) (ledgerInfoWithSigs []*postypes.LedgerInfoWithSignatures, err error)
}

type RpcPosClient added in v0.1.1

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

RpcPosClient used to access pos namespace RPC of Conflux blockchain.

func NewRpcFilterClient added in v1.5.4

func NewRpcFilterClient(core *Client) RpcPosClient

func NewRpcPosClient added in v0.1.1

func NewRpcPosClient(core *Client) RpcPosClient

NewRpcPosClient creates a new RpcPosClient instance.

func NewRpcTraceClient added in v1.5.4

func NewRpcTraceClient(core *Client) RpcPosClient

NewRpcPosClient creates a new RpcPosClient instance.

func (*RpcPosClient) GetAccount added in v0.1.1

func (c *RpcPosClient) GetAccount(address postypes.Address, blockNumber ...hexutil.Uint64) (account postypes.Account, err error)

GetAccount returns account info at block

func (*RpcPosClient) GetAccountByPowAddress added in v1.5.4

func (c *RpcPosClient) GetAccountByPowAddress(address cfxaddress.Address, blockNumber ...hexutil.Uint64) (account postypes.Account, err error)

GetAccount returns pos account of pow address info at block

func (*RpcPosClient) GetBlockByHash added in v0.1.1

func (c *RpcPosClient) GetBlockByHash(hash types.Hash) (block *postypes.Block, err error)

GetBlockByHash returns block info of block hash

func (*RpcPosClient) GetBlockByNumber added in v0.1.1

func (c *RpcPosClient) GetBlockByNumber(blockNumber postypes.BlockNumber) (block *postypes.Block, err error)

GetBlockByHash returns block at block number

func (*RpcPosClient) GetCommittee added in v0.1.1

func (c *RpcPosClient) GetCommittee(blockNumber ...hexutil.Uint64) (committee postypes.CommitteeState, err error)

GetCommittee returns committee info at block

func (*RpcPosClient) GetConsensusBlocks added in v1.5.4

func (c *RpcPosClient) GetConsensusBlocks() (blocks []*postypes.Block, err error)

========================================== debug rpcs =======================================================

func (*RpcPosClient) GetEpochState added in v1.5.4

func (c *RpcPosClient) GetEpochState(epochNumber ...hexutil.Uint64) (epochState *postypes.EpochState, err error)

func (*RpcPosClient) GetLedgerInfoByBlockNumber added in v1.5.4

func (c *RpcPosClient) GetLedgerInfoByBlockNumber(blockNumber postypes.BlockNumber) (ledgerInfoWithSigs *postypes.LedgerInfoWithSignatures, err error)

func (*RpcPosClient) GetLedgerInfoByEpoch added in v1.5.4

func (c *RpcPosClient) GetLedgerInfoByEpoch(epochNumber ...hexutil.Uint64) (ledgerInfoWithSigs *postypes.LedgerInfoWithSignatures, err error)

func (*RpcPosClient) GetLedgerInfoByEpochAndRound added in v1.5.7

func (c *RpcPosClient) GetLedgerInfoByEpochAndRound(epochNumber hexutil.Uint64, round hexutil.Uint64) (ledgerInfoWithSigs *postypes.LedgerInfoWithSignatures, err error)

func (*RpcPosClient) GetLedgerInfosByEpoch added in v1.5.4

func (c *RpcPosClient) GetLedgerInfosByEpoch(startEpoch hexutil.Uint64, endEpoch hexutil.Uint64) (ledgerInfoWithSigs []*postypes.LedgerInfoWithSignatures, err error)

func (*RpcPosClient) GetRewardsByEpoch added in v0.1.1

func (c *RpcPosClient) GetRewardsByEpoch(epochNumber hexutil.Uint64) (reward postypes.EpochReward, err error)

GetRewardsByEpoch returns rewards of epoch

func (*RpcPosClient) GetStatus added in v0.1.1

func (c *RpcPosClient) GetStatus() (status postypes.Status, err error)

GetStatus returns pos chain status

func (*RpcPosClient) GetTransactionByNumber added in v0.1.1

func (c *RpcPosClient) GetTransactionByNumber(txNumber hexutil.Uint64) (transaction *postypes.Transaction, err error)

GetTransactionByNumber returns transaction info of transaction number

type RpcRequester added in v0.1.1

type RpcRequester = interfaces.Provider

reserve for forward compatbility

type RpcTrace added in v1.5.4

type RpcTrace interface {
	GetBlockTraces(blockHash types.Hash) (*types.LocalizedBlockTrace, error)
	FilterTraces(traceFilter types.TraceFilter) (traces []types.LocalizedTrace, err error)
	GetTransactionTraces(txHash types.Hash) (traces []types.LocalizedTrace, err error)
	GetEpochTraces(epoch types.Epoch) (traces types.EpochTrace, err error)
}

type RpcTraceClient added in v1.5.4

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

func (*RpcTraceClient) FilterTraces added in v1.5.4

func (c *RpcTraceClient) FilterTraces(traceFilter types.TraceFilter) (traces []types.LocalizedTrace, err error)

GetFilterTraces returns all traces matching the provided filter.

func (*RpcTraceClient) GetBlockTraces added in v1.5.4

func (c *RpcTraceClient) GetBlockTraces(blockHash types.Hash) (traces *types.LocalizedBlockTrace, err error)

GetBlockTrace returns all traces produced at given block.

func (*RpcTraceClient) GetEpochTraces added in v1.5.4

func (c *RpcTraceClient) GetEpochTraces(epoch types.Epoch) (traces types.EpochTrace, err error)

func (*RpcTraceClient) GetTransactionTraces added in v1.5.4

func (c *RpcTraceClient) GetTransactionTraces(txHash types.Hash) (traces []types.LocalizedTrace, err error)

GetTransactionTraces returns all traces produced at the given transaction.

type RpcTxpool added in v0.1.1

type RpcTxpool interface {
	Status() (val types.TxPoolStatus, err error)
	NextNonce(address types.Address) (val *hexutil.Big, err error)
	TransactionByAddressAndNonce(address types.Address, nonce *hexutil.Big) (val *types.Transaction, err error)
	PendingNonceRange(address types.Address) (val types.TxPoolPendingNonceRange, err error)
	TxWithPoolInfo(hash types.Hash) (val types.TxWithPoolInfo, err error)
	AccountPendingInfo(address types.Address) (val *types.AccountPendingInfo, err error)
	AccountPendingTransactions(address types.Address, maybeStartNonce *hexutil.Big, maybeLimit *hexutil.Uint64) (val types.AccountPendingTransactions, err error)
}

type RpcTxpoolClient added in v0.1.1

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

RpcTxpoolClient used to access txpool namespace RPC of Conflux blockchain.

func NewRpcTxpoolClient added in v0.1.1

func NewRpcTxpoolClient(core *Client) RpcTxpoolClient

NewRpcTxpoolClient creates a new RpcTxpoolClient instance.

func (*RpcTxpoolClient) AccountPendingInfo added in v0.1.1

func (c *RpcTxpoolClient) AccountPendingInfo(address types.Address) (val *types.AccountPendingInfo, err error)

/ Get transaction pending info by account address

func (*RpcTxpoolClient) AccountPendingTransactions added in v0.1.1

func (c *RpcTxpoolClient) AccountPendingTransactions(address types.Address, maybeStartNonce *hexutil.Big, maybeLimit *hexutil.Uint64) (val types.AccountPendingTransactions, err error)

/ Get transaction pending info by account address

func (*RpcTxpoolClient) NextNonce added in v0.1.1

func (c *RpcTxpoolClient) NextNonce(address types.Address) (val *hexutil.Big, err error)

NextNonce returns next nonce of account, including pending transactions

func (*RpcTxpoolClient) PendingNonceRange added in v0.1.1

func (c *RpcTxpoolClient) PendingNonceRange(address types.Address) (val types.TxPoolPendingNonceRange, err error)

PendingNonceRange returns pending nonce range in txpool of account

func (*RpcTxpoolClient) Status added in v0.1.1

func (c *RpcTxpoolClient) Status() (val types.TxPoolStatus, err error)

Status returns txpool status

func (*RpcTxpoolClient) TransactionByAddressAndNonce added in v0.1.1

func (c *RpcTxpoolClient) TransactionByAddressAndNonce(address types.Address, nonce *hexutil.Big) (val *types.Transaction, err error)

TransactionByAddressAndNonce returns transaction info in txpool by account address and nonce

func (*RpcTxpoolClient) TxWithPoolInfo added in v0.1.1

func (c *RpcTxpoolClient) TxWithPoolInfo(hash types.Hash) (val types.TxWithPoolInfo, err error)

TxWithPoolInfo returns transaction with txpool info by transaction hash

Directories

Path Synopsis
Package bind generates Ethereum contract Go bindings.
Package bind generates Ethereum contract Go bindings.
cfxclient
cmd
contract_meta
internal
bcs
mpt
pos

Jump to

Keyboard shortcuts

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