Documentation ¶
Index ¶
- Variables
- func Add0xPrefix(hexStr string) string
- func AddressToHex(addr common.Address) string
- func Bytes2HexWith0x(buffer []byte) string
- func Bytes2HexWithout0x(buffer []byte) string
- func BytesToHex(buf []byte) string
- func CalcSignVByChainId(chainID *big.Int, v uint8) int64
- func DecryptKeystore(keystoreJson []byte, pwd string) *ecdsa.PrivateKey
- func DeriveChainId(v *big.Int) *big.Int
- func ECDSAPrivateKeyToHex(prv *ecdsa.PrivateKey) string
- func EcRecover(digestHash []byte, sig []byte) (common.Address, error)
- func EncryptPrivLight(priv *ecdsa.PrivateKey, pwd string) []byte
- func EncryptPrivStandard(priv *ecdsa.PrivateKey, pwd string) []byte
- func FillTo32Bytes(data []byte) []byte
- func FromWei(amount *big.Int) decimal.Decimal
- func FromWeiWithDecimals(amount *big.Int, decimals int32) decimal.Decimal
- func GenNewPrivateKey() string
- func GetAddress(privateKey string) string
- func GetBalance(client *ethclient.Client, account string) *big.Int
- func GetChainID(client *ethclient.Client) *big.Int
- func GetContractAbi(abiJson string) *abi.ABI
- func GetEthClientWithHeader(endpoint string, key string, val string) (*ethclient.Client, error)
- func GetEthStandardHex(hex string) string
- func GetInfuraEthClientUseJWT(endpoint string, token string) (*ethclient.Client, error)
- func GetInfuraEthClientUseSecret(endpoint string, secret string) (*ethclient.Client, error)
- func GetNextNonce(client *ethclient.Client, account string) uint64
- func GetRawTxHash(tx *types.Transaction) string
- func GetTxFrom(tx *types.Transaction, chainID *big.Int) string
- func Hex2Bytes(s string) []byte
- func HexToAddress(addr string) common.Address
- func HexToBytes(hexStr string) []byte
- func HexToECDSAPrivateKey(privateKey string) *ecdsa.PrivateKey
- func Int32ToBytes(i int64) []byte
- func Int64ToBytes(i int64) []byte
- func IntToBytes(i int) []byte
- func IsContract(client *ethclient.Client, account string) bool
- func IsValidAddressHex(hex string) bool
- func IsValidPrivateKeyHex(hex string) bool
- func JoinSignature(sign *Signature) string
- func Keccak256(data []byte) []byte
- func LogWithTime(msg string)
- func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *types.Transaction
- func NewTx(nonce uint64, to string, amount *big.Int, gasLimit uint64, gasPrice *big.Int, ...) *types.Transaction
- func PackFuncArgs(datas *[]AbiParam) *[]byte
- func PackSignArgs(datas *[]AbiParam) *[]byte
- func PaddingLeft0(data []byte, targetLen int) []byte
- func PaddingRight0(data []byte, targetLen int) []byte
- func PubkeyToAddress(pubkey *ecdsa.PublicKey) string
- func ReadPrivateKeys(filePath string) []string
- func RestoreSignV(chainID *big.Int, v int64) uint8
- func SendRawTx(client *ethclient.Client, tx *types.Transaction) error
- func SignTx(prv *ecdsa.PrivateKey, tx *types.Transaction, chainID *big.Int) *types.Transaction
- func ToWei(amount decimal.Decimal) *big.Int
- func ToWeiWithDecimals(amount decimal.Decimal, decimals int32) *big.Int
- func VerifySignature(address common.Address, digestHash []byte, signature []byte) bool
- func WaitTxReceipt(client *ethclient.Client, txId string, txDesc string, timeoutSeconds int64) bool
- func WaitTxReceiptSuccess(client *ethclient.Client, txId string, txDesc string, timeoutSeconds int64)
- type AbiParam
- type Signature
- type TxBaseParams
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //bytes of "\x19Ethereum Signed Message:\n32" SIGN_PREFIX_STANDARD []byte = []byte("\u0019Ethereum Signed Message:\n32") //bytes of "\x19\x01" SIGN_PREFIX_HEX1901 []byte = []byte("\u0019\u0001") )
Functions ¶
func Add0xPrefix ¶
func AddressToHex ¶
func Bytes2HexWith0x ¶
func Bytes2HexWithout0x ¶
func BytesToHex ¶
func DecryptKeystore ¶
func DecryptKeystore(keystoreJson []byte, pwd string) *ecdsa.PrivateKey
decrypt json keystore to private key plantext hex string
func DeriveChainId ¶
deriveChainId derives the chain id from the given v parameter
func EncryptPrivLight ¶
func EncryptPrivLight(priv *ecdsa.PrivateKey, pwd string) []byte
encrypt private key to json keystore,use light scryptN,scryptP
func EncryptPrivStandard ¶
func EncryptPrivStandard(priv *ecdsa.PrivateKey, pwd string) []byte
encrypt private key to json keystore,use standard scryptN,scryptP
func FromWeiWithDecimals ¶
func GenNewPrivateKey ¶
func GenNewPrivateKey() string
func GetEthClientWithHeader ¶
func HexToAddress ¶
func HexToBytes ¶
func HexToECDSAPrivateKey ¶
func HexToECDSAPrivateKey(privateKey string) *ecdsa.PrivateKey
私钥字符串转ecdsa私钥指针
func Int32ToBytes ¶
func Int64ToBytes ¶
func IntToBytes ¶
func LogWithTime ¶
func LogWithTime(msg string)
func NewContractCreation ¶
func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *types.Transaction
生成部署合约的交易
func NewTx ¶
func NewTx(nonce uint64, to string, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *types.Transaction
生成新交易
func PaddingLeft0 ¶
func PaddingRight0 ¶
func PubkeyToAddress ¶
func ReadPrivateKeys ¶
func SignTx ¶
func SignTx(prv *ecdsa.PrivateKey, tx *types.Transaction, chainID *big.Int) *types.Transaction
签名交易
func VerifySignature ¶
验证签名
func WaitTxReceipt ¶
Types ¶
type Signature ¶
签名
func SignMessage ¶
func SignMessage(digestHash []byte, prv *ecdsa.PrivateKey) *Signature
签名消息 The produced signature is in the [R || S || V] format where V is 0 or 1.
func SignOriginDatas ¶
func SignOriginDatas(prv *ecdsa.PrivateKey, prefix []byte, params *[]AbiParam) *Signature
签名原始参数
Click to show internal directories.
Click to hide internal directories.