rpc

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RPCendpoint = map[string]RPCMethod{
	"ClientVersion":       RPCMethod{"web3_clientVersion", "get"},
	"Sha3":                RPCMethod{"web3_sha3", "post"},
	"NetworkId":           RPCMethod{"net_id", "get"},
	"MostRecentBlock":     RPCMethod{"eth_blockNumber", "get"},
	"GetBalance":          RPCMethod{"eth_getBalance", "get"},
	"GetStorageAt":        RPCMethod{"eth_getStorageAt", "get"},
	"GetTransactionCount": RPCMethod{"eth_getTransactionCount", "get"},
	"GetCode":             RPCMethod{"eth_getCode", "get"},
	"GetBlockByHash":      RPCMethod{"eth_getBlockByHash", "get"},

	"Sign":                  RPCMethod{"eth_sign", "post"},
	"SignTransaction":       RPCMethod{"eth_signTransaction", "post"},
	"SendTransaction":       RPCMethod{"eth_sendTransaction", "post"},
	"SendRawTransaction":    RPCMethod{"eth_sendRawTransaction", "post"},
	"GasPrice":              RPCMethod{"eth_gasPrice", "get"},
	"Coinbase":              RPCMethod{"eth_coinbase", "get"},
	"GetTransactionByHash":  RPCMethod{"eth_getTransactionByHash", "get"},
	"GetBlockReceipts":      RPCMethod{"eth_getBlockReceipts", "get"},
	"GetTransactionReceipt": RPCMethod{"eth_getTransactionReceipt", "post"},
	"Call":                  RPCMethod{"eth_call", "post"},

	"Account":                          RPCMethod{"eth_accounts", "get"},
	"EstimateGas":                      RPCMethod{"eth_estimateGas", "get"},
	"FeeHistory":                       RPCMethod{"eth_feeHistory", "get"},
	"GetBlockByNumber":                 RPCMethod{"eth_getBlockByNumber", "get"},
	"GetBlockTransactionCountByHash":   RPCMethod{"eth_getBlockTransactionCountByhash", "get"},
	"GetBlockTransactionCountByNumber": RPCMethod{"eth_getBlockTransactionCountByNumber", "get"},
	"GetProof":                         RPCMethod{"eth_getProof", "get"},
}

https://ethereum.github.io/execution-apis/api-documentation/

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	// 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(url string, port string) *Endpoint

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) (*http.Response, error)

func (*Endpoint) ClientVersion

func (ep *Endpoint) ClientVersion() (*http.Response, error)

func (*Endpoint) GetBalance

func (ep *Endpoint) GetBalance(address string) (*http.Response, error)

func (*Endpoint) GetBlockReceipts

func (ep *Endpoint) GetBlockReceipts(blockNumber string) (*http.Response, error)

func (*Endpoint) GetCode

func (ep *Endpoint) GetCode(address string) (*http.Response, error)

func (*Endpoint) GetCoinbase

func (ep *Endpoint) GetCoinbase() (*http.Response, error)

func (*Endpoint) GetGasPrice

func (ep *Endpoint) GetGasPrice() (*http.Response, error)

func (*Endpoint) GetStorageAt

func (ep *Endpoint) GetStorageAt(contractAdress string, storageAddr int) (*http.Response, error)

func (*Endpoint) GetTransactionByHash

func (ep *Endpoint) GetTransactionByHash(transactionHash string) (*http.Response, error)

func (*Endpoint) GetTransactionCount

func (ep *Endpoint) GetTransactionCount(address string) (*http.Response, error)

func (*Endpoint) GetTransactionReceipt

func (ep *Endpoint) GetTransactionReceipt(transactionHash string) (*http.Response, error)

func (*Endpoint) HttpRequest

func (ep *Endpoint) HttpRequest(Params []Parameters, rpcDetail RPCMethod) (*http.Response, error)

func (*Endpoint) MostRecentBlock

func (ep *Endpoint) MostRecentBlock() (*http.Response, error)

func (*Endpoint) SendRawTransaction

func (ep *Endpoint) SendRawTransaction(rawSignedTransaction string) (*http.Response, error)

func (*Endpoint) SendTransaction

func (ep *Endpoint) SendTransaction(transaction Transaction) (*http.Response, error)

func (*Endpoint) Sha3

func (ep *Endpoint) Sha3(data string) (*http.Response, error)

func (*Endpoint) SignTransaction

func (ep *Endpoint) SignTransaction(transaction Transaction) (*http.Response, error)

TODO should do a build transaction function

type Parameters

type Parameters interface{}

Represent the parameters to allow multiple type

type RPCMethod

type RPCMethod struct {
	Method     string
	HTTPMethod string
}

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