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) GetBalance(address string) (*RPCResponse, error)
- func (ep *Endpoint) GetBlockReceipts(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) 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) 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"},
"FeeHistory": {"eth_feeHistory", "GET"},
"GetBlockByNumber": {"eth_getBlockByNumber", "GET"},
"GetBlockTransactionCountByHash": {"eth_getBlockTransactionCountByhash", "GET"},
"GetBlockTransactionCountByNumber": {"eth_getBlockTransactionCountByNumber", "GET"},
"GetProof": {"eth_getProof", "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 (*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) GetBalance ¶
func (ep *Endpoint) GetBalance(address string) (*RPCResponse, error)
func (*Endpoint) GetBlockReceipts ¶
func (ep *Endpoint) GetBlockReceipts(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) 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