Documentation ¶
Index ¶
- Variables
- func AutoDeploy(optionName string, deployFunc DeployFunc, auth *bind.TransactOpts) (common.Address, *types.Transaction, interface{})
- func AutoSendTx(optionName string, transactFunc TransactFunc, auth *bind.TransactOpts) *types.Transaction
- func MustGenrateKey() *ecdsa.PrivateKey
- func MustGetClient(url string) *ethclient.Client
- func MustGetDefaultOptByEncryptFile(keypath string, pw string, client *ethclient.Client) *bind.TransactOpts
- func MustGetDefaultOptByHexKey(keyHex string, client *ethclient.Client) *bind.TransactOpts
- func MustGetETHAccountByEncryptFile(keypath string, pw string) *bind.TransactOpts
- func MustGetEthAccount(keyHex string) *bind.TransactOpts
- func MustGetPrivateKeyByEncryptFile(keypath string, pw string) *keystore.Key
- func MustReadLines(f string) []string
- func MustSetNonce(client *ethclient.Client, account *bind.TransactOpts)
- func PanicIfErr(err error)
- func PrivateKeyToHex(key *ecdsa.PrivateKey) string
- func WaitForTx(client *ethclient.Client, hash common.Hash) (*types.Receipt, error)
- type DeployFunc
- type RPCClient
- type TransactFunc
Constants ¶
This section is empty.
Variables ¶
var ( Wei = big.NewInt(gparams.Wei) GWei = big.NewInt(gparams.GWei) Ether = big.NewInt(gparams.Ether) )
These are the multipliers for ether denominations.
var ( One = big.NewInt(1) Two = big.NewInt(2) )
Normal used numbers in ethereum dapp.
var (
CallOpt = &bind.CallOpts{}
)
common params
var (
LocalRPCURL = "http://127.0.0.1:8545"
)
Config default values.
Functions ¶
func AutoDeploy ¶
func AutoDeploy(optionName string, deployFunc DeployFunc, auth *bind.TransactOpts) (common.Address, *types.Transaction, interface{})
AutoDeploy deploys contract/ panic if error/logs info info. Transaction sender's nonce will add 1 automatically.
func AutoSendTx ¶
func AutoSendTx(optionName string, transactFunc TransactFunc, auth *bind.TransactOpts) *types.Transaction
AutoSendTx send tx to contract using contract object generated by abigen. Panic if errors. Transaction sender's nonce will add 1 automatically.
func MustGenrateKey ¶
func MustGenrateKey() *ecdsa.PrivateKey
MustGenrateKey generates an random key using ethereum/crypto.
func MustGetClient ¶
MustGetClient panics if can't get client
func MustGetDefaultOptByEncryptFile ¶
func MustGetDefaultOptByEncryptFile(keypath string, pw string, client *ethclient.Client) *bind.TransactOpts
MustGetDefaultOptByEncryptFile returns an ethereum account with nonce set by keystore file path path.
func MustGetDefaultOptByHexKey ¶
func MustGetDefaultOptByHexKey(keyHex string, client *ethclient.Client) *bind.TransactOpts
MustGetDefaultOptByHexKey returns an ethereum account with nonce set by hex key.
func MustGetETHAccountByEncryptFile ¶
func MustGetETHAccountByEncryptFile(keypath string, pw string) *bind.TransactOpts
MustGetETHAccountByEncryptFile returns an ethereum account by keystore file path path.
func MustGetEthAccount ¶
func MustGetEthAccount(keyHex string) *bind.TransactOpts
MustGetEthAccount returns an ethereum operation account by hex private key.
func MustSetNonce ¶
func MustSetNonce(client *ethclient.Client, account *bind.TransactOpts)
MustSetNonce sets nonce to ethereum account if nonce is nil.
func PrivateKeyToHex ¶
func PrivateKeyToHex(key *ecdsa.PrivateKey) string
PrivateKeyToHex change to private key to hex format.
Types ¶
type DeployFunc ¶
type DeployFunc func() (common.Address, *types.Transaction, interface{}, error)
DeployFunc deploys contracts when executing.
type RPCClient ¶
type RPCClient struct {
// contains filtered or unexported fields
}
RPCClient implements methods by calling rpc client
func MustGetRPCClient ¶
MustGetRPCClient returns a ethereum rpc client instance.
func (*RPCClient) StartMining ¶
StartMining start miner mining process
func (*RPCClient) StopMining ¶
StopMining stop miner mining process
type TransactFunc ¶
type TransactFunc func() (*types.Transaction, error)
TransactFunc is a func to send tx to contract. Panic if errors. Transaction sender's nonce will add 1 automatically.