Documentation
¶
Index ¶
- Variables
- type ContractCreationTr
- type Endpoint
- func (ep *Endpoint) Call(tr Transaction) (*RPCResponse, error)
- func (ep *Endpoint) ClientVersion() (*RPCResponse, error)
- func (ep *Endpoint) DeployContract(sender string, contractByteCodePath string) (*TransactionReceiptResponse, error)
- func (ep *Endpoint) EstimateGas(tr Transaction) (*RPCResponse, error)
- func (ep *Endpoint) FeeHistory(blockCount string, newestBlock string, rewardPercentile []float32) (*RPCResponse, error)
- func (ep *Endpoint) GetAccounts() (*RPCResponse, error)
- func (ep *Endpoint) GetBalance(address string) (*RPCResponse, error)
- func (ep *Endpoint) GetBlockByNumber(blockNumber string) (*RPCResponse, error)
- func (ep *Endpoint) GetBlockReceipts(blockNumber string) (*RPCResponse, error)
- func (ep *Endpoint) GetBlockTransactionCountByHash(blockHash string) (*RPCResponse, error)
- func (ep *Endpoint) GetBlockTransactionCountByNumber(blockNumber string) (*RPCResponse, error)
- func (ep *Endpoint) GetCode(address string) (*RPCResponse, error)
- func (ep *Endpoint) GetCoinbase() (*RPCResponse, error)
- func (ep *Endpoint) GetGasPrice() (*RPCResponse, error)
- func (ep *Endpoint) GetProof(address string, storageKey []string, blockNumber string) (*RPCResponse, error)
- func (ep *Endpoint) GetStorageAt(contractAdress string, storageAddr int) (*RPCResponse, error)
- func (ep *Endpoint) GetTransactionByHash(transactionHash string) (*RPCResponse, error)
- func (ep *Endpoint) GetTransactionCount(address string) (*RPCResponse, error)
- func (ep *Endpoint) GetTransactionReceipt(transactionHash string) (*TransactionReceiptResponse, error)
- func (ep *Endpoint) HttpRequest(httpMethod string, RPCjson []byte) (*RPCResponse, error)
- func (ep *Endpoint) MostRecentBlock() (*RPCResponse, error)
- func (ep *Endpoint) NetworkId() (*RPCResponse, error)
- func (ep *Endpoint) Request(Params []Parameters, rpcDetail RPCMethod) (*RPCResponse, error)
- func (ep *Endpoint) SendRawTransaction(rawSignedTransaction string) (*RPCResponse, error)
- func (ep *Endpoint) SendToken(amount string, from string, to string) (*RPCResponse, error)
- func (ep *Endpoint) SendTransaction(transaction interface{}) (*RPCResponse, error)
- func (ep *Endpoint) Sha3(data string) (*RPCResponse, error)
- func (ep *Endpoint) SignTransaction(transaction Transaction) (*RPCResponse, error)
- func (ep *Endpoint) UnixSocketRequest(RPCjson []byte) (*RPCResponse, error)
- type Parameters
- type RPCError
- type RPCMethod
- type RPCResponse
- type RPCTransaction
- type Transaction
- type TransactionReceiptResponse
Constants ¶
This section is empty.
Variables ¶
var RPCendpoint = map[string]RPCMethod{
"ClientVersion": {"web3_clientVersion", "GET"},
"Sha3": {"web3_sha3", "POST"},
"NetworkId": {"net_id", "GET"},
"MostRecentBlock": {"eth_blockNumber", "POST"},
"GetBalance": {"eth_getBalance", "POST"},
"GetStorageAt": {"eth_getStorageAt", "GET"},
"GetTransactionCount": {"eth_getTransactionCount", "GET"},
"GetCode": {"eth_getCode", "GET"},
"GetBlockByHash": {"eth_getBlockByHash", "GET"},
"Sign": {"eth_sign", "POST"},
"SignTransaction": {"eth_signTransaction", "POST"},
"SendTransaction": {"eth_sendTransaction", "POST"},
"SendRawTransaction": {"eth_sendRawTransaction", "POST"},
"GasPrice": {"eth_gasPrice", "GET"},
"Coinbase": {"eth_coinbase", "GET"},
"GetTransactionByHash": {"eth_getTransactionByHash", "POST"},
"GetBlockReceipts": {"eth_getBlockReceipts", "POST"},
"GetTransactionReceipt": {"eth_getTransactionReceipt", "POST"},
"Call": {"eth_call", "POST"},
"Account": {"eth_accounts", "GET"},
"EstimateGas": {"eth_estimateGas", "GET"},
"GetBlockTransactionCountByNumber": {"eth_getBlockTransactionCountByNumber", "GET"},
"GetBlockByNumber": {"eth_getBlockByNumber", "GET"},
"GetProof": {"eth_getProof", "GET"},
"GetBlockTransactionCountByHash": {"eth_getBlockTransactionCountByHash", "GET"},
"FeeHistory": {"eth_feeHistory", "GET"},
}
https://ethereum.github.io/execution-apis/api-documentation/
Functions ¶
This section is empty.
Types ¶
type ContractCreationTr ¶ added in v0.6.0
type ContractCreationTr struct { From string `json:"from"` Value string `json:"value"` Input string `json:"data"` }
Represent the transaction to create a contract When creating a contract, the TO field should be absent
type Endpoint ¶
represent the endpoint used as the entry point to the network. This can be a public endpoint as well as a personal node
func ConnectEndpoint ¶
Initialize the endpoint.
func ConnectLocalEndpoint ¶ added in v0.6.2
return by default the IPC endpoint created when running geth locally
func (*Endpoint) Call ¶
func (ep *Endpoint) Call(tr Transaction) (*RPCResponse, error)
func (*Endpoint) ClientVersion ¶
func (ep *Endpoint) ClientVersion() (*RPCResponse, error)
func (*Endpoint) DeployContract ¶ added in v0.6.0
func (ep *Endpoint) DeployContract(sender string, contractByteCodePath string) (*TransactionReceiptResponse, error)
DeployContract deploy a contract to the blockchain it takes the account which is deploying the contract as first argument The second argument is the path to the compiled contract it return a TransactionReceipt struct (which contain the contract address) upon successfull completion if an error occur, return nil and an error
func (*Endpoint) EstimateGas ¶ added in v0.6.2
func (ep *Endpoint) EstimateGas(tr Transaction) (*RPCResponse, error)
func (*Endpoint) FeeHistory ¶ added in v0.6.2
func (*Endpoint) GetAccounts ¶ added in v0.6.2
func (ep *Endpoint) GetAccounts() (*RPCResponse, error)
func (*Endpoint) GetBalance ¶
func (ep *Endpoint) GetBalance(address string) (*RPCResponse, error)
func (*Endpoint) GetBlockByNumber ¶ added in v0.6.2
func (ep *Endpoint) GetBlockByNumber(blockNumber string) (*RPCResponse, error)
func (*Endpoint) GetBlockReceipts ¶
func (ep *Endpoint) GetBlockReceipts(blockNumber string) (*RPCResponse, error)
func (*Endpoint) GetBlockTransactionCountByHash ¶ added in v0.6.2
func (ep *Endpoint) GetBlockTransactionCountByHash(blockHash string) (*RPCResponse, error)
APPAREMENT C EST PAS REQUIRE LE BLOCKHASH ??
func (*Endpoint) GetBlockTransactionCountByNumber ¶ added in v0.6.2
func (ep *Endpoint) GetBlockTransactionCountByNumber(blockNumber string) (*RPCResponse, error)
func (*Endpoint) GetCoinbase ¶
func (ep *Endpoint) GetCoinbase() (*RPCResponse, error)
func (*Endpoint) GetGasPrice ¶
func (ep *Endpoint) GetGasPrice() (*RPCResponse, error)
func (*Endpoint) GetStorageAt ¶
func (ep *Endpoint) GetStorageAt(contractAdress string, storageAddr int) (*RPCResponse, error)
func (*Endpoint) GetTransactionByHash ¶
func (ep *Endpoint) GetTransactionByHash(transactionHash string) (*RPCResponse, error)
func (*Endpoint) GetTransactionCount ¶
func (ep *Endpoint) GetTransactionCount(address string) (*RPCResponse, error)
func (*Endpoint) GetTransactionReceipt ¶
func (ep *Endpoint) GetTransactionReceipt(transactionHash string) (*TransactionReceiptResponse, error)
GetTransactionReceipt query the receipt of a transaction based on the hash of the transaction. Upon successful completion, it return a pointer to a TransactionReceiptResponse struct In case of failure, return nil and an appropriate error
func (*Endpoint) HttpRequest ¶
func (ep *Endpoint) HttpRequest(httpMethod string, RPCjson []byte) (*RPCResponse, error)
* Used when connecting to the endpoint via http * return an RPCResponse if everything goes well and nil and an error otherwise
func (*Endpoint) MostRecentBlock ¶
func (ep *Endpoint) MostRecentBlock() (*RPCResponse, error)
func (*Endpoint) NetworkId ¶ added in v0.2.0
func (ep *Endpoint) NetworkId() (*RPCResponse, error)
func (*Endpoint) Request ¶ added in v0.3.0
func (ep *Endpoint) Request(Params []Parameters, rpcDetail RPCMethod) (*RPCResponse, error)
func (*Endpoint) SendRawTransaction ¶
func (ep *Endpoint) SendRawTransaction(rawSignedTransaction string) (*RPCResponse, error)
func (*Endpoint) SendToken ¶ added in v0.6.2
wrapper around sendTransaction to facilitate the sending of token the two arguments are value, the amount in wei to send from the sender of the amount to the address to send the amount to
func (*Endpoint) SendTransaction ¶
func (ep *Endpoint) SendTransaction(transaction interface{}) (*RPCResponse, error)
func (*Endpoint) SignTransaction ¶
func (ep *Endpoint) SignTransaction(transaction Transaction) (*RPCResponse, error)
func (*Endpoint) UnixSocketRequest ¶ added in v0.3.0
func (ep *Endpoint) UnixSocketRequest(RPCjson []byte) (*RPCResponse, error)
* Used when trying to dialog with the node via UnixSocket * Return an RPCResponse structure with the structure or an error if something went wrong * note that if the RPC request went wrong, this function return a RPCResponse with an RPCERROR in it
type RPCResponse ¶ added in v0.3.0
type RPCTransaction ¶
type RPCTransaction struct { Jsonrpc string `json:"jsonrpc"` Method string `json:"method"` Params []Parameters `json:"params"` Id int `json:"id"` //not sure what this is used for, seems like it can be anything. }
The structure of the RPC call made to the endpoint
type Transaction ¶
type Transaction struct { From string `json:"from"` To string `json:"to"` Value string `json:"value"` Input string `json:"data"` }
Represent the transaction
func BuildTransaction ¶
func BuildTransaction(from string, to string, value string, input string) Transaction
type TransactionReceiptResponse ¶ added in v0.6.0
type TransactionReceiptResponse struct { BlockHash string `json:"blockHash"` BlockNumber string `json:"blockNumber"` ContractAddress string `json:"contractAddress"` CumulativeGasUser string `json:"cumulativeGasUser"` EffectiveGasPrice string `json:"effectiveGasPrice"` From string `json:"from"` GasUsed string `json:"gasUsed"` LogsBloom string `json:"logsBloom"` Status string `json:"status"` To string `json:"to"` TransactionHash string `json:"transactionHash"` TransactionIndex string `json:"transactionIndex"` Type string `json:"type"` }
TransactionReceiptResponse represent the Response when querying the receipt of a transaction