Documentation ¶
Index ¶
- Variables
- func AddressToHex(addr common.Address) string
- func BigIntToBytes(i *big.Int) []byte
- func Byte32ToBytes(bs [32]byte) []byte
- func BytesToHex(buf []byte) string
- func CalcSignVByChainId(chainID *big.Int, v uint8) int64
- func DeriveChainId(v *big.Int) *big.Int
- func ECDSAPrivateKeyToHex(prv *ecdsa.PrivateKey) string
- func Ecrecover(digestHash []byte, signature []byte) string
- func GetAddress(privateKey string) string
- 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 GetRawTxHash(tx *types.Transaction) string
- func GetTxFrom(tx *types.Transaction, chainID *big.Int) string
- 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 IsValidAddressHex(hex string) bool
- func IsValidPrivateKeyHex(hex string) bool
- func JoinSignature(sign *Signature) string
- func Keccak256(data []byte) []byte
- 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 PubkeyToAddress(pubkey *ecdsa.PublicKey) 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 VerifySignature(address string, digestHash, signature []byte) bool
- type AbiParam
- type Signature
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 AddressToHex ¶
func BigIntToBytes ¶
func Byte32ToBytes ¶
func BytesToHex ¶
func DeriveChainId ¶
deriveChainId derives the chain id from the given v parameter
func GetEthClientWithHeader ¶
func HexToAddress ¶
func HexToBytes ¶
func HexToECDSAPrivateKey ¶
func HexToECDSAPrivateKey(privateKey string) *ecdsa.PrivateKey
私钥字符串转ecdsa私钥指针
func Int32ToBytes ¶
func Int64ToBytes ¶
func IntToBytes ¶
func NewTx ¶
func NewTx(nonce uint64, to string, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *types.Transaction
生成新交易(未签名)
func PubkeyToAddress ¶
func SignTx ¶
func SignTx(prv *ecdsa.PrivateKey, tx *types.Transaction, chainID *big.Int) *types.Transaction
签名交易
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.