Documentation ¶
Overview ¶
Package rpc invokes JSON-RPC with ethereum node
Index ¶
- Constants
- Variables
- type RPC
- func (r *RPC) Call(to, data string) (string, error)
- func (r *RPC) DoRPC(req interface{}) (ret string, err error)
- func (r *RPC) GetChainID() *big.Int
- func (r *RPC) GetCode(addr string) (string, error)
- func (r *RPC) GetEthClient() *ethclient.Client
- func (r *RPC) GetGasPrice() uint64
- func (r *RPC) GetTransactionCount(addr string) uint64
- func (r *RPC) InitClient()
- func (r *RPC) SendRawTransaction(raw []byte) (string, error)
- func (r *RPC) SendTransaction(from, to, data string, gas int) (string, error)
Constants ¶
View Source
const ( // Mainnet is a const string indicates mainnet Mainnet = "MAIN" // Testnet is a const string indicates testnet Testnet = "TEST" )
View Source
const ContentType = "application/json"
ContentType is a content-type for JSON-RPC
Variables ¶
View Source
var MainnetUrls = []string{""}
MainnetUrls is a URL list for mainnet
View Source
var ( // NetType is either mainnet or testnet NetType = Testnet )
View Source
var TestnetUrls = []string{"REPLACE WITH YOUR NODE URL #1", "REPLACE WITH YOUR NODE URL #2"} //ex. "https://api.metadium.com/dev"
TestnetUrls is a URL list for testnet
Functions ¶
This section is empty.
Types ¶
type RPC ¶
type RPC struct { NetType string NetVersion *big.Int GasPrice uint64 // contains filtered or unexported fields }
RPC is a JSON-RPC manager through HTTP
func (*RPC) DoRPC ¶
DoRPC invokes HTTP post request to ethereum node Retry when fail, give penalty to low-latency node
func (*RPC) GetEthClient ¶
GetEthClient returns ether client among urls included in target net
func (*RPC) GetTransactionCount ¶
GetTransactionCount invokes RPC "eth_getTransactionCount"
func (*RPC) InitClient ¶
func (r *RPC) InitClient()
InitClient initializes HTTP client to reduce handshaking overhead
func (*RPC) SendRawTransaction ¶
SendRawTransaction invokes RPC "eth_sendRawTransaction"
Click to show internal directories.
Click to hide internal directories.