Documentation
¶
Index ¶
- Variables
- func ConvHexToBigInt(raw any) (bi *big.Int, err error)
- func ConvHexToUint64(raw any) (uint64, error)
- func MustConvHexToBigInt(raw any) *big.Int
- func MustConvHexToUint64(raw any) uint64
- type ChainClient
- type Client
- func (c *Client) BuildRequest(method string, params []any) *RPCReq
- func (c *Client) Inc() uint64
- func (c *Client) MakeRequest(url, method string, params []any) (*RPCResp, error)
- func (c *Client) MakeRequestBatch(url string, methods []string, params [][]any) ([]RPCResp, error)
- func (c *Client) MakeRequestBatchGenric(url string, methods []string, params [][]any, r any) error
- func (c *Client) SendTx(url string, txdata ethtypes.TxData, privateKey *ecdsa.PrivateKey, ...) (*RPCResp, error)
- func (c *Client) SendTxSimple(pk string, value *big.Int, gasPrice *big.Int, toAddress string, nonce uint64, ...) error
- func (c *Client) SetAuth(auth string)
- func (c *Client) SetKeepAlive(shouldKeepAlive bool)
- func (c *Client) SetProxy(proxy, proxyAuth string)
- func (c *Client) SetTimeout(duration time.Duration)
- type RPCBase
- type RPCBlockResp
- type RPCError
- type RPCReceiptResp
- type RPCReq
- type RPCResp
- type RawBlockResponse
- type RawData8Response
- type RawData20Response
- type RawData32Response
- type RawData256Response
- type RawDataResponse
- type RawQuantityResponse
- type RawTransactionResponse
- type RawTxReceipt
Constants ¶
This section is empty.
Variables ¶
View Source
var ( UnitWei = big.NewInt(1) // | 1 | 1 | wei | Wei UnitBabbage = new(big.Int).Mul(UnitWei, big.NewInt(1000)) // | 1,000 | 10^3^ | Babbage | Kilowei or femtoether UnitLovelace = new(big.Int).Mul(UnitBabbage, big.NewInt(1000)) // | 1,000,000 | 10^6^ | Lovelace | Megawei or picoether UnitShannon = new(big.Int).Mul(UnitLovelace, big.NewInt(1000)) // | 1,000,000,000 | 10^9^ | Shannon | Gigawei or nanoether UnitSzabo = new(big.Int).Mul(UnitShannon, big.NewInt(1000)) // | 1,000,000,000,000 | 10^12^ | Szabo | Microether or micro UnitFinney = new(big.Int).Mul(UnitSzabo, big.NewInt(1000)) // | 1,000,000,000,000,000 | 10^15^ | Finney | Milliether or milli UnitEther = new(big.Int).Mul(UnitFinney, big.NewInt(1000)) // | 1,000,000,000,000,000,000 | 10^18^ | Ether | Ether UnitGrand = new(big.Int).Mul(UnitEther, big.NewInt(1000)) // | 1,000,000,000,000,000,000,000 | 10^21^ | Grand | Kiloether UnitMegaether = new(big.Int).Mul(UnitGrand, big.NewInt(1000)) // | 1,000,000,000,000,000,000,000,000 | 10^24^ | | Megaether )
Functions ¶
func ConvHexToBigInt ¶
HexToBigInt assumes that it's input is a hex encoded string and will try to convert it to a big int
func ConvHexToUint64 ¶
HexToUint64 assumes that its input is a hex encoded string and it will attempt to convert this into a uint64
func MustConvHexToBigInt ¶
func MustConvHexToUint64 ¶
Types ¶
type ChainClient ¶
type ChainClient struct {
RPCClient *Client
URL string
PrivateKey *ecdsa.PrivateKey
ChainID *big.Int
}
func NewChainClient ¶
func NewChainClient(c *Client, url string, privateKey *ecdsa.PrivateKey, chainID *big.Int) *ChainClient
func (*ChainClient) GetTxReceipt ¶
func (cc *ChainClient) GetTxReceipt(hash string) (*RawTxReceipt, error)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) MakeRequest ¶
func (*Client) MakeRequestBatch ¶
MakeRequestBatch will perform an RPC patch call. The response array will match the order of the input methods
func (*Client) MakeRequestBatchGenric ¶
func (*Client) SendTxSimple ¶
func (*Client) SetKeepAlive ¶
func (*Client) SetTimeout ¶
type RPCBlockResp ¶
type RPCBlockResp struct {
Result RawBlockResponse `json:"result"`
Error RPCError `json:"error"`
RPCBase
}
type RPCReceiptResp ¶
type RPCReceiptResp struct {
Result RawTxReceipt `json:"result"`
Error RPCError
RPCBase
}
type RawBlockResponse ¶
type RawBlockResponse struct {
// number: QUANTITY - the block number. null when its pending block.
Number RawQuantityResponse `json:"number"`
// hash: DATA, 32 Bytes - hash of the block. null when its pending block.
Hash RawData32Response `json:"hash"`
// parentHash: DATA, 32 Bytes - hash of the parent block.
ParentHash RawData32Response `json:"parentHash"`
// nonce: DATA, 8 Bytes - hash of the generated proof-of-work. null when its pending block.
Nonce RawData8Response `json:"nonce"`
// sha3Uncles: DATA, 32 Bytes - SHA3 of the uncles data in the block.
SHA3Uncles RawData32Response `json:"sha3Uncles"`
// logsBloom: DATA, 256 Bytes - the bloom filter for the logs of the block. null when its pending block.
LogsBloom RawData256Response `json:"logsBloom"`
// transactionsRoot: DATA, 32 Bytes - the root of the transaction trie of the block.
TransactionsRoot RawData32Response `json:"transactionsRoot"`
// stateRoot: DATA, 32 Bytes - the root of the final state trie of the block.
StateRoot RawData32Response `json:"stateRoot"`
// receiptsRoot: DATA, 32 Bytes - the root of the receipts trie of the block.
ReceiptsRoot RawData32Response `json:"receiptsRoot"`
// miner: DATA, 20 Bytes - the address of the beneficiary to whom the mining rewards were given.
Miner RawData20Response `json:"miner"`
// difficulty: QUANTITY - integer of the difficulty for this block.
Difficulty RawQuantityResponse `json:"difficulty"`
// totalDifficulty: QUANTITY - integer of the total difficulty of the chain until this block.
TotalDifficulty RawQuantityResponse `json:"totalDifficulty"`
// extraData: DATA - the "extra data" field of this block.
ExtraData RawDataResponse `json:"extraData"`
// size: QUANTITY - integer the size of this block in bytes.
Size RawQuantityResponse `json:"size"`
// gasLimit: QUANTITY - the maximum gas allowed in this block.
GasLimit RawQuantityResponse `json:"gasLimit"`
// gasUsed: QUANTITY - the total used gas by all transactions in this block.
GasUsed RawQuantityResponse `json:"gasUsed"`
// timestamp: QUANTITY - the unix timestamp for when the block was collated.
Timestamp RawQuantityResponse `json:"timestamp"`
// transactions: Array - Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
Transactions []RawTransactionResponse `json:"transactions"`
// uncles: Array - Array of uncle hashes.
Uncles []RawQuantityResponse `json:"uncles"`
// baseFeePerGass: QUANTITY - fixed per block fee
BaseFeePerGas RawQuantityResponse `json:"baseFeePerGas"`
}
func NewRawBlockResponseFromAny ¶
func NewRawBlockResponseFromAny(raw any) (*RawBlockResponse, error)
type RawData8Response ¶
type RawData8Response string
type RawData20Response ¶
type RawData20Response string
type RawData32Response ¶
type RawData32Response string
type RawData256Response ¶
type RawData256Response string
type RawDataResponse ¶
type RawDataResponse string
type RawQuantityResponse ¶
type RawQuantityResponse string
func (RawQuantityResponse) ToInt64 ¶
func (r RawQuantityResponse) ToInt64() int64
func (RawQuantityResponse) ToUint64 ¶
func (r RawQuantityResponse) ToUint64() uint64
type RawTransactionResponse ¶
type RawTransactionResponse struct {
// blockHash: DATA, 32 Bytes - hash of the block where this transaction was in. null when its pending.
BlockHash RawData32Response `json:"blockHash"`
// blockNumber: QUANTITY - block number where this transaction was in. null when its pending.
BlockNumber RawQuantityResponse `json:"blockNumber"`
// from: DATA, 20 Bytes - address of the sender.
From RawData20Response `json:"from"`
// gas: QUANTITY - gas provided by the sender.
Gas RawQuantityResponse `json:"gas"`
// gasPrice: QUANTITY - gas price provided by the sender in Wei.
GasPrice RawQuantityResponse `json:"gasPrice"`
// hash: DATA, 32 Bytes - hash of the transaction.
Hash RawData32Response `json:"hash"`
// input: DATA - the data send along with the transaction.
Input RawDataResponse `json:"input"`
// nonce: QUANTITY - the number of transactions made by the sender prior to this one.
Nonce RawQuantityResponse `json:"nonce"`
// to: DATA, 20 Bytes - address of the receiver. null when its a contract creation transaction.
To RawData20Response `json:"to"`
// transactionIndex: QUANTITY - integer of the transactions index position in the block. null when its pending.
TransactionIndex RawQuantityResponse `json:"transactionIndex"`
// value: QUANTITY - value transferred in Wei.
Value RawQuantityResponse `json:"value"`
// v: QUANTITY - ECDSA recovery id
V RawQuantityResponse `json:"v"`
// r: QUANTITY - ECDSA signature r
R RawQuantityResponse `json:"r"`
// s: QUANTITY - ECDSA signature s
S RawQuantityResponse `json:"s"`
}
type RawTxReceipt ¶
type RawTxReceipt struct {
// transactionHash: DATA, 32 Bytes - hash of the transaction.
TransactionHash RawData32Response `json:"transactionHash"`
// transactionIndex: QUANTITY - integer of the transactions index position in the block.
TransactionIndex RawQuantityResponse `json:"transactionIndex"`
// blockHash: DATA, 32 Bytes - hash of the block where this transaction was in.
BlockHash RawData32Response `json:"blockHash"`
// blockNumber: QUANTITY - block number where this transaction was in.
BlockNumber RawQuantityResponse `json:"blockNumber"`
// from: DATA, 20 Bytes - address of the sender.
From RawData20Response `json:"from"`
// to: DATA, 20 Bytes - address of the receiver. null when its a contract creation transaction.
To RawDataResponse `json:"to"`
// cumulativeGasUsed : QUANTITY - The total amount of gas used when this transaction was executed in the block.
CumulativeGasUsed RawQuantityResponse `json:"cumulativeGasUsed"`
// gasUsed : QUANTITY - The amount of gas used by this specific transaction alone.
GasUsed RawQuantityResponse `json:"gasUsed"`
// contractAddress : DATA, 20 Bytes - The contract address created, if the transaction was a contract creation, otherwise null.
ContractAddress RawData20Response `json:"contractAddress"`
// logs: Array - Array of log objects, which this transaction generated.
Logs []RawDataResponse `json:"logs"`
// logsBloom: DATA, 256 Bytes - Bloom filter for light clients to quickly retrieve related logs. It also returns either :
LogsBloom RawData256Response `json:"logsBloom"`
// root : DATA 32 bytes of post-transaction stateroot (pre Byzantium)
Root RawData32Response `json:"root"`
// status: QUANTITY either 1 (success) or 0 (failure)
Status RawQuantityResponse `json:"status"`
}
Click to show internal directories.
Click to hide internal directories.