cmd

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const EthGasStationUrl = "https://ethgasstation.info/json/ethgasAPI.json"

Variables

This section is empty.

Functions

func Call

func Call(client *ethclient.Client, toAddress common.Address, data []byte) ([]byte, error)

Call invokes the (constant) contract method.

func Execute

func Execute() error

Execute cobra root command

func GenRawTx

func GenRawTx(signedTx *types.Transaction) (string, error)

GenRawTx return raw tx, a hex string with 0x prefix

func InitGlobalClient

func InitGlobalClient(nodeUrl string)

InitGlobalClient initializes a client that uses the given RPC client.

func RecoverPubkey

func RecoverPubkey(v, r, s *big.Int, msg []byte) ([]byte, error)

RecoverPubkey recover public key, returns 65 bytes uncompressed public key

func SendRawTransaction

func SendRawTransaction(rpcClient *rpc.Client, signedTx *types.Transaction) (*common.Hash, error)

SendRawTransaction broadcast signed tx and return tx returned by rpc node

func Transact

func Transact(rpcClient *rpc.Client, client *ethclient.Client, privateKey *ecdsa.PrivateKey, toAddress *common.Address, amount *big.Int, gasPrice *big.Int, data []byte) (string, error)

Transact invokes the (paid) contract method.

func TransferHelper

func TransferHelper(rcpClient *rpc.Client, client *ethclient.Client, privateKeyHex string, toAddress string, amountInWei *big.Int, gasPrice *big.Int, data []byte) (string, error)

Types

type AbiData

type AbiData struct {
	Inputs []struct {
		Name string `json:"name"`
		Type string `json:"type"`
	} `json:"inputs"`
	Name    string `json:"name"`
	Type    string `json:"type"` // constructor, function, etc.
	Outputs []struct {
		Name string `json:"name"`
		Type string `json:"type"`
	} `json:"outputs"`
}

ABI example: [

 {
     "inputs": [],
     "stateMutability": "nonpayable",
     "type": "constructor"
 },
	{
		"inputs": [
			{
				"internalType": "uint256[]",
				"name": "_a",
				"type": "uint256[]"
			},
			{
				"internalType": "address[]",
				"name": "_addr",
				"type": "address[]"
			}
		],
		"name": "f1",
		"outputs": [],
		"stateMutability": "nonpayable",
		"type": "function"
	},
	{
		"inputs": [],
		"name": "f2",
		"outputs": [
			{
				"internalType": "uint256",
				"name": "",
				"type": "uint256"
			}
		],
		"stateMutability": "view",
		"type": "function"
	},

...... ]

type AbiJSONData

type AbiJSONData struct {
	ABI []AbiData `json:"abi"`
}

type Client

type Client struct {
	EthClient *ethclient.Client
	RpcClient *rpc.Client
}

type GasStationPrice

type GasStationPrice struct {
	Fast        float64
	Fastest     float64
	SafeLow     float64
	Average     float64
	SafeLowWait float64
	AvgWait     float64
	FastWait    float64
	FastestWait float64
}

GasStationPrice, the struct of response of EthGasStationUrl

Jump to

Keyboard shortcuts

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