geth

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 13 Imported by: 0

README

INSTALL

go get github.com/jeffcail/geth

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InquireEthBlockNumberError               = "Inquire eth block number failed !!!"
	InquireEthBlockByNumberError             = "Inquire eth block by number failed !!!"
	InquireEthBlockTransactionCountHashError = "Inquire eth block transaction count by hash failed !!!"
)
View Source
var (
	EthSignatureHexToECDSAError = "signature hex to ECDSA failed !!!"
	EthSignatureSignError       = "sign private key failed !!!"
	EthSignError                = "Sign failed !!!"
	EthVerifySignEcrecoverError = "the uncompressed public key that created the given signature failed !!!"
)
View Source
var (
	EthNetworkError                      = "the network ID for this client failed !!!"
	EthBlockTransactionSenderError       = "eth block transaction sender failed !!!"
	EthBlockTransactionReceiptError      = "the receipt of a transaction by transaction hash failed !!!"
	EthBlockSingleTransactionByHashError = "the transaction with the given hash failed !!!"
)
View Source
var (
	GenerateEthAddressError = "Generate eth address failed !!!"
	CanNotType              = "cannot assert type: publicKey is not of type *ecdsa.PublicKey"
)
View Source
var (
	EthClientDialError = "Dial eth client error"
)
View Source
var (
	InquireEthBalanceErr = "Inquire eth balance failed !!!"
)
View Source
var (
	ValidateIsSmartContractErr = "The contract code of the given account is failed !!!"
)

Functions

func ValidaEthAddress

func ValidaEthAddress(address string) bool

ValidaEthAddress 校验地址是否有效

Types

type EthClient

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

func NewEthClient

func NewEthClient(network string) *EthClient

func (*EthClient) EthAccount

func (e *EthClient) EthAccount() (string, string)

EthAccount 生成地址和私钥

func (*EthClient) EthBalanceByAddress

func (e *EthClient) EthBalanceByAddress(address string) *big.Float

EthBalanceByAddress 获取账户余额

func (*EthClient) EthBalanceByBlockNumber

func (e *EthClient) EthBalanceByBlockNumber(address string, blockNumber int64) *big.Float

EthBalanceByBlockNumber 获取该区块时的账户余额

func (*EthClient) EthBlockContentByBlockNumber

func (e *EthClient) EthBlockContentByBlockNumber(blockNumber int64) *types.Block

EthBlockContentByBlockNumber 读取区块的所有内容和元数据

func (*EthClient) EthBlockNumber

func (e *EthClient) EthBlockNumber() string

EthBlockNumber 最新区块高度

func (*EthClient) EthBlockNumber2

func (e *EthClient) EthBlockNumber2() uint64

EthBlockNumber2 最新区块高度

func (*EthClient) EthBlockSingleTransactionByHash

func (e *EthClient) EthBlockSingleTransactionByHash(hash string) (*Transaction, bool)

EthBlockSingleTransactionByHash 单条交易

func (*EthClient) EthBlockTransaction

func (e *EthClient) EthBlockTransaction(blockNumber int64) []*Transaction

EthBlockTransaction 查询交易区块内交易记录

func (*EthClient) EthBlockTransactionCountByBlockNumber

func (e *EthClient) EthBlockTransactionCountByBlockNumber(hash common.Hash) uint

EthBlockTransactionCountByBlockNumber 块中的交易计数

func (*EthClient) EthSignature

func (e *EthClient) EthSignature(privateKey string, data []byte) string

EthSignature 签名

func (*EthClient) EthTransactionEth added in v0.0.7

func (e *EthClient) EthTransactionEth(fromPrivateKey, toAddress string, value *big.Int, gasLimit uint64, data []byte) (bool, error)

EthTransactionEth 交易eth

func (*EthClient) ValidateEthAddressIsSmartContract

func (e *EthClient) ValidateEthAddressIsSmartContract(address string) bool

ValidateEthAddressIsSmartContract 检查地址是否为账户或智能合约

func (*EthClient) VerifySignature

func (e *EthClient) VerifySignature(privateKey string, data []byte) bool

VerifySignature 验证签名

func (*EthClient) VerifySignatureOfEqual

func (e *EthClient) VerifySignatureOfEqual(privateKey string, data []byte) bool

VerifySignatureOfEqual 验证签名

func (*EthClient) VerifySignatureOfSigToPub

func (e *EthClient) VerifySignatureOfSigToPub(privateKey string, data []byte) bool

VerifySignatureOfSigToPub 验证签名

type Transaction

type Transaction struct {
	Hash     common.Hash     // 区块hash
	Value    *big.Int        // 传输的值,以 Wei 为单位
	Gas      uint64          // 发送者提供的燃料
	GasPrice *big.Int        // 发送者提供的燃料价格,以 Wei 为单位
	Nonce    uint64          // 交易顺序,防止重放攻击
	Data     []byte          // 数据
	To       *common.Address // 交易发送方
	From     common.Address  // 交易接收方
	Status   uint64          // 交易状态
}

Jump to

Keyboard shortcuts

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