Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateKeyPair() (string, string, string, error)
- func MakePayment(client Client, pk string, from string, to string, amount, gasPrice *big.Int, ...) (string, error)
- func PubkeyToAddress(p ecdsa.PublicKey) string
- func Test(b bool) bool
- type ChainId
- type Client
- func (c Client) GasPrice() (*big.Int, error)
- func (c Client) GasPrice2() (*big.Int, *EthGasStationResponse, error)
- func (c Client) GetBalance(address string) (balanceInWei *big.Int, err error)
- func (c Client) Post(jsonRpcCommand string, id int64) (*JsonRpcResponse, error)
- func (c Client) SendTransaction(chainId ChainId, pk, from string, to string, ...) (string, error)
- func (c Client) Test(b bool) bool
- type EthGasStationResponse
- type JsonRpcError
- type JsonRpcResponse
Constants ¶
View Source
const ( // These are the multipliers for ether denominations. // Example: To get the wei value of an amount in 'douglas', use // // new(big.Int).Mul(value, big.NewInt(params.Douglas)) // Wei = 1 Ada = 1e3 Babbage = 1e6 Shannon = 1e9 Szabo = 1e12 Finney = 1e15 Ether = 1e18 Einstein = 1e21 Douglas = 1e42 )
View Source
const ( DefaultGas int64 = 90000 DefaultGasPrice int64 = 1 * Shannon )
Variables ¶
View Source
var IdMismatch = errors.New("Ids do not match!")
View Source
var InvalidChainId = errors.New("Invalid ChainId")
View Source
var IsTest = false
View Source
var JsonRpcMessage = `{"jsonrpc":"%s","method":"%s","params":%s,"id":%v}`
View Source
var JsonRpcVersion = "2.0"
Functions ¶
func MakePayment ¶
func PubkeyToAddress ¶
Types ¶
type Client ¶
type Client struct {
IsTest bool
Commands []string
Chain ChainId
// contains filtered or unexported fields
}
func (Client) GasPrice2 ¶
func (c Client) GasPrice2() (*big.Int, *EthGasStationResponse, error)
Get the current average gasprice via https://ethgasstation.info/json/ethgasAPI.json
func (Client) GetBalance ¶
func (Client) Post ¶
func (c Client) Post(jsonRpcCommand string, id int64) (*JsonRpcResponse, error)
Post a JSON-RPC Command
type EthGasStationResponse ¶
type EthGasStationResponse struct {
BlockNum float64 `json:"blockNum"`
BlockTime float64 `json:"block_time"`
Speed float64 `json:"speed"`
FastestWait float64 `json:"fastestWait"`
Fastest float64 `json:"fastest"`
FastWait float64 `json:"fastWait"`
Fast float64 `json:"fast"`
AverageWait float64 `json:"avgWait"`
Average float64 `json:"average"`
SafeLowWait float64 `json:"safeLowWait"`
SafeLow float64 `json:"safeLow"`
}
type JsonRpcError ¶
type JsonRpcResponse ¶
type JsonRpcResponse struct {
Id int64 `json:"id"`
JsonRpcVersion string `json:"jsonrpc"`
Result ej.RawMessage `json:"result"`
Error JsonRpcError `json:"error"`
}
Click to show internal directories.
Click to hide internal directories.