rpc

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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", "GET"},
	"GetBlockReceipts":      {"eth_getBlockReceipts", "GET"},
	"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 Endpoint

type Endpoint struct {
	ParsedURL *url.URL
	// contains filtered or unexported fields
}

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

func ConnectEndpoint(Rawurl string) (*Endpoint, error)

NOTE does it really make sense to keep this Endpoint in this form? 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) GetBalance

func (ep *Endpoint) GetBalance(address string) (*RPCResponse, error)

func (*Endpoint) GetBlockReceipts

func (ep *Endpoint) GetBlockReceipts(blockNumber string) (*RPCResponse, error)

func (*Endpoint) GetCode

func (ep *Endpoint) GetCode(address 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) (*RPCResponse, 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)

TODO should probably return a struct representing the response

func (*Endpoint) SendRawTransaction

func (ep *Endpoint) SendRawTransaction(rawSignedTransaction string) (*RPCResponse, error)

func (*Endpoint) SendTransaction

func (ep *Endpoint) SendTransaction(transaction Transaction) (*RPCResponse, error)

func (*Endpoint) Sha3

func (ep *Endpoint) Sha3(data string) (*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 Parameters

type Parameters interface{}

Represent the parameters to allow multiple type

type RPCError added in v0.3.0

type RPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type RPCMethod

type RPCMethod struct {
	Method     string
	HTTPMethod string
}

type RPCResponse added in v0.3.0

type RPCResponse struct {
	Jsonrpc string    `json:"jsonrpc"`
	Id      int       `json:"id"`
	Result  string    `json:"result"`
	Error   *RPCError `json:"error"`
}

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:"input"`
}

Represent the transaction

func BuildTransaction

func BuildTransaction(from string, to string, value string, input string) Transaction

Jump to

Keyboard shortcuts

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