rpc

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAddress          = errors.New("err: input address is not valid! ")
	ErrInvalidAuthClientParams = errors.New("err: auth cli params is not valid! ")
	ErrInvalidParams           = errors.New("err: input params are not valid! ")
	ErrInvalidHashValue        = errors.New("err: input hash value is not valid! ")
	ErrInvalidPrivateKey       = errors.New("err: input private key is not valid! ")
	ErrGetBlockStatus          = errors.New("err: error when get status from chain! ")
	ErrAmountLessThanZero      = errors.New("err: input amount value can not less than 0! ")
)
View Source
var (
	RinkebyChainId = big.NewInt(4)
)

Functions

func CreateAuthentication

func CreateAuthentication(privateKey *ecdsa.PrivateKey, nonce *big.Int, value *big.Int, gasPrice *big.Int) *bind.TransactOpts

func PrivateKeyToAddress

func PrivateKeyToAddress(privateKey *ecdsa.PrivateKey) (address common.Address, err error)

func SignTx

func SignTx(authCli *AuthClient, tx *types.Transaction) (signedTx *types.Transaction, err error)

Types

type AuthClient

type AuthClient struct {
	PrivateKey *ecdsa.PrivateKey `json:"private_key"`
	PublicKey  *ecdsa.PublicKey  `json:"public_key"`
	Address    common.Address    `json:"address"`
	ChainId    *big.Int          `json:"chain_id"`
}

func NewAuthClient

func NewAuthClient(priKey string, chainId *big.Int) (authCli *AuthClient, err error)

type ProviderClient

type ProviderClient struct {
	*ethclient.Client
}

func NewClient

func NewClient(provider string) (cli *ProviderClient, err error)

func (*ProviderClient) DeployContract

func (cli *ProviderClient) DeployContract(authCli *AuthClient, gasPrice *big.Int, abiPath string, binPath string, params []interface{}) (contractAddress common.Address, txHash common.Hash, err error)

func (*ProviderClient) DeployContractUntil

func (cli *ProviderClient) DeployContractUntil(authCli *AuthClient, gasPrice *big.Int, abiPath string, binPath string, params []interface{}) (status bool, contractAddress common.Address, txHash common.Hash, err error)

func (*ProviderClient) GetBalance

func (cli *ProviderClient) GetBalance(address string) (balance *big.Int, err error)

func (*ProviderClient) GetBlockHeaderByHash

func (cli *ProviderClient) GetBlockHeaderByHash(blockHash string) (header *types.Header, err error)

func (*ProviderClient) GetBlockHeaderByNumber

func (cli *ProviderClient) GetBlockHeaderByNumber(height *big.Int) (header *types.Header, err error)

func (*ProviderClient) GetBlockInfoByHash

func (cli *ProviderClient) GetBlockInfoByHash(blockHash string) (blockInfo *types.Block, err error)

func (*ProviderClient) GetBlockInfoByNumber

func (cli *ProviderClient) GetBlockInfoByNumber(height *big.Int) (blockInfo *types.Block, err error)

func (*ProviderClient) GetHeight

func (cli *ProviderClient) GetHeight() (height uint64, err error)

func (*ProviderClient) GetLatestBlockHeader

func (cli *ProviderClient) GetLatestBlockHeader() (header *types.Header, err error)

func (*ProviderClient) GetLatestBlockInfo

func (cli *ProviderClient) GetLatestBlockInfo() (blockInfo *types.Block, err error)

func (*ProviderClient) GetPendingNonce

func (cli *ProviderClient) GetPendingNonce(address string) (nonce uint64, err error)

func (*ProviderClient) GetTransactionByHash

func (cli *ProviderClient) GetTransactionByHash(transactionHash string) (tx *types.Transaction, isPending bool, err error)

func (*ProviderClient) GetTransactionReceipt

func (cli *ProviderClient) GetTransactionReceipt(transactionHash string) (receipt *types.Receipt, err error)

func (*ProviderClient) IsContract

func (cli *ProviderClient) IsContract(address string) (isContract bool, err error)

func (*ProviderClient) Transfer

func (cli *ProviderClient) Transfer(authCli *AuthClient, to string, amount *big.Int, data []byte, gasLimit uint64) (txHash string, err error)

func (*ProviderClient) WaitingTransactionStatus

func (cli *ProviderClient) WaitingTransactionStatus(txHash string) (status bool, err error)

Jump to

Keyboard shortcuts

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