Documentation ¶
Index ¶
- Constants
- Variables
- func HeaderLatest(ctx context.Context) (*types.Header, error)
- func HeaderNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func JsonABI(reader io.Reader) abi.ABI
- func Keccak256Hash(data ...[]byte) (hash string)
- func Keccak256Sign(prv string, data ...[]byte) (signature string, err error)
- func Keccak256SignBytes(prv string, data ...[]byte) (signature []byte, err error)
- func RecoverETHSig(msg, sig []byte) (*ecdsa.PublicKey, error)
- func RecoverHexSig(msg []byte, hexSig string) (*ecdsa.PublicKey, error)
- func Sign(prv string, data []byte) (str string, err error)
- func Uint(mul int, data []byte) []byte
- type Account
- func (c Account) Address() (string, error)
- func (c Account) Balance(ctx context.Context) (*big.Int, error)
- func (c Account) Keccak256Sign(data ...[]byte) (signature string, err error)
- func (c Account) Keccak256SignBytes(data ...[]byte) (signature []byte, err error)
- func (c Account) NewSmcTx(ctx context.Context, tx SmcTxData) (*bind.TransactOpts, error)
- func (c Account) NewTx(ctx context.Context, data TxData) (*types.Transaction, error)
- func (c Account) PublicKey() (string, error)
- func (c Account) SendTx(ctx context.Context, data TxData) (*types.Transaction, error)
- func (a *Account) SetClient(client *GotherClient) *Account
- func (a *Account) SetPrivate(privateKey string) *Account
- func (c Account) Sign(data []byte) (str string, err error)
- type GotherClient
- func (c GotherClient) Balance(ctx context.Context, address string) (*big.Int, error)
- func (a GotherClient) HeaderLatest(ctx context.Context) (*types.Header, error)
- func (a GotherClient) HeaderNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (c GotherClient) IsSmartContract(ctx context.Context, addr string) (bool, error)
- type IAgent
- type Lazier
- type Scanner
- func (s Scanner) Clone() *Scanner
- func (sc *Scanner) InjAddresses(addresses ...common.Address) *Scanner
- func (sc *Scanner) InjClient(client *GotherClient) *Scanner
- func (sc *Scanner) InjOffset(offset uint64) *Scanner
- func (sc *Scanner) Scan(ctx context.Context) (logs []types.Log, scannedBlock uint64, err error)
- type Smc
- type SmcTxData
- type TxData
- type Wallet
Constants ¶
const ( SIG_PREFIX = "\x19Ethereum Signed Message:\n" SIG_V = 27 )
Variables ¶
var Util gotherUtil
Functions ¶
func Keccak256Hash ¶
func Keccak256Sign ¶
Keccak256Sign will hash data to 32 bytes (= keccak256) then signing it, return hexa-signature which is 132 bytes (0x...)
func Keccak256SignBytes ¶
Keccak256SignBytes will hash data to 32 bytes (= keccak256) then signing it return bytes-signature which is 65 bytes (32 bytes r, 32 bytes s, 1 byte v)
func RecoverETHSig ¶
RecoverHexSig will recover public key from [65]byte signature
func RecoverHexSig ¶
RecoverHexSig will recover public key from hex signature
Types ¶
type Account ¶
type Account struct { *GotherClient // contains filtered or unexported fields }
func NewAccount ¶
func (Account) Keccak256Sign ¶
func (Account) Keccak256SignBytes ¶
func (Account) NewSmcTx ¶
NewSmcTx creates a transaction calling smart contract with suggest gas price and 110% gas limit
func (*Account) SetClient ¶
func (a *Account) SetClient(client *GotherClient) *Account
func (*Account) SetPrivate ¶
type GotherClient ¶
var Client *GotherClient = &GotherClient{}
func Dial ¶
func Dial(url string) (*GotherClient, error)
DialCtx will connect to `url` and set the default client to client(url) if default client is nil
func DialCtx ¶
func DialCtx(ctx context.Context, url string) (*GotherClient, error)
DialCtx will connect to `url` and set the default client to client(url) if default client is nil
func SetClient ¶
func SetClient(c *ethclient.Client) *GotherClient
SetClient is used in case you already have ethclient.Client and want to use features of gother
func (GotherClient) HeaderLatest ¶
func (GotherClient) HeaderNumber ¶
func (GotherClient) IsSmartContract ¶
type Scanner ¶
type Scanner struct { ScanNum uint64 // how many blocks scanning each time From uint64 // scan from? Addresses []common.Address // smart contract address // contains filtered or unexported fields }
func NewScanner ¶
NewScanner create a scanner which will scan `scanNum` blocks each time, it scans from `from` and only scans log from smart contracts which has address in `addresses` array
func (*Scanner) InjAddresses ¶
InjAddresses changes the addresses of smart contracts that will be scanned
func (*Scanner) InjClient ¶
func (sc *Scanner) InjClient(client *GotherClient) *Scanner
InjClient set the client for scanner
func (*Scanner) InjOffset ¶
InjOffset sets the offset from latest block, this will scan all the blocks except last `offset` blocks because we need to scan the most stable blocks, latest blocks may be forked or replaced...