Documentation
¶
Overview ¶
Copyright © 2025 NAME HERE <EMAIL ADDRESS>
Index ¶
- Constants
- func BuildEIP7702Tx(client *ethclient.Client, privateKey *ecdsa.PrivateKey, ...) (*types.Transaction, error)
- func BuildEip7702SignedTx(client *ethclient.Client, privateKey *ecdsa.PrivateKey, ...) (*types.Transaction, error)
- func BuildSignedTx(client *ethclient.Client, privateKey *ecdsa.PrivateKey, ...) (*types.Transaction, error)
- func BuildTupleArgData(typ abi.Type, data []string) (any, error)
- func BuildTupleArrayType(tupleType string) (abi.Type, error)
- func BuildTx(client *ethclient.Client, privateKey *ecdsa.PrivateKey, ...) (*types.Transaction, error)
- func Call(rpcClient *rpc.Client, toAddress common.Address, data []byte) ([]byte, error)
- func Execute() error
- func GenRawTx(signedTx *types.Transaction) (string, error)
- func GetFuncSig(funcHash string) ([]string, error)
- func GetFuncSigFrom4Byte(funcHash string) ([]string, error)
- func GetFuncSigFromOpenchain(funcHash string) ([]string, error)
- func GetInitCode() ([]byte, error)
- func GetNonce(sender string) (*big.Int, error)
- func GetPaymasterAndData() ([]byte, error)
- func GetRawTx(rpcClient *rpc.Client, txHash string) (string, error)
- func GetSender() common.Address
- func InitGlobalClient(nodeUrl string)
- func MnemonicToPrivateKey(mnemonic string, derivationPath string) (*ecdsa.PrivateKey, error)
- func ParseBigInt(input string) (*big.Int, error)
- func RecoverPubkey(v, r, s *big.Int, msg []byte) ([]byte, error)
- func SendRawTransaction(rpcClient *rpc.Client, signedTxHexStr string) (*common.Hash, error)
- func SendSignedTx(rpcClient *rpc.Client, signedTx *types.Transaction) (*common.Hash, error)
- func Transact(rpcClient *rpc.Client, client *ethclient.Client, privateKey *ecdsa.PrivateKey, ...) (string, error)
- func TransferHelper(rcpClient *rpc.Client, client *ethclient.Client, privateKeyHex string, ...) (string, error)
- type AbiData
- type AbiJSONData
- type ChainData
- type Client
- type ErrFuncNotFound
- type GasStationPrice
- type RpcEndpoint
- type RpcStatus
Constants ¶
const EthGasStationUrl = "https://ethgasstation.info/json/ethgasAPI.json"
const MulticallContractAddr = "0xcA11bde05977b3631167028862bE2a173976CA11" // See https://github.com/mds1/multicall
const MulticallFuncSignAggregate = "252dba42" // 4 bytes func signature of `aggregate((address,bytes)[])`
const MulticallFuncSignGetEthBalance = "4d2301cc" // 4 bytes func signature of `getEthBalance(address)`
Variables ¶
This section is empty.
Functions ¶
func BuildEIP7702Tx ¶ added in v1.6.0
func BuildEIP7702Tx(client *ethclient.Client, privateKey *ecdsa.PrivateKey, toAddress *common.Address, amount *big.Int, data []byte, delegateTo common.Address, ) (*types.Transaction, error)
BuildEIP7702Tx builds EIP7702 transaction
func BuildEip7702SignedTx ¶ added in v1.6.0
func BuildEip7702SignedTx( client *ethclient.Client, privateKey *ecdsa.PrivateKey, toAddress *common.Address, amount *big.Int, data []byte, sigData []byte, delegateTo common.Address, ) (*types.Transaction, error)
BuildEip7702SignedTx builds signed transaction
func BuildSignedTx ¶ added in v1.2.3
func BuildSignedTx( client *ethclient.Client, privateKey *ecdsa.PrivateKey, fromAddress, toAddress *common.Address, amount, gasPrice *big.Int, data []byte, sigData []byte, ) (*types.Transaction, error)
BuildSignedTx builds signed transaction
func BuildTupleArgData ¶ added in v1.2.3
BuildTupleArgData build tuple data accepted by abi Pack An example: typ: abi.NewType("tuple", "", []abi.ArgumentMarshaling{{Name: "Field0", Type: "uint256"}, {Name: "Field1", Type: "bool"}}) data: ["15", "true"] return: A dynamically created struct object: { Field0: big.NewInt("15"), Field1: true }
func BuildTupleArrayType ¶ added in v1.2.3
BuildTupleArrayType build tuple array abi.Type An example: tupleType: "(uint256, bool)[5]" return: abi.NewType("tuple[5]", "", []abi.ArgumentMarshaling{{Name: "Field0", Type: "uint256"}, {Name: "Field1", Type: "bool"}})
func BuildTx ¶ added in v1.2.3
func BuildTx(client *ethclient.Client, privateKey *ecdsa.PrivateKey, fromAddress, toAddress *common.Address, amount, gasPrice *big.Int, data []byte, ) (*types.Transaction, error)
BuildTx builds transaction
func GenRawTx ¶
func GenRawTx(signedTx *types.Transaction) (string, error)
GenRawTx return raw tx, a hex string with 0x prefix
func GetFuncSig ¶ added in v1.2.3
GetFuncSig recover function signature from 4 bytes hash
func GetFuncSigFrom4Byte ¶ added in v1.5.0
GetFuncSigFrom4Byte recover function signature from 4 bytes hash from 4byte API For example:
param: "0x8c905368" return: ["NotEnoughFunds(uint256,uint256)"]
This function uses 4byte API $ curl -X 'GET' 'https://www.4byte.directory/api/v1/signatures/?hex_signature=0x275fb869'
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1136703,
"created_at": "2025-03-22T17:59:30.142145Z",
"text_signature": "InsufficientSlippage(uint256,uint256)",
"hex_signature": "0x275fb869",
"bytes_signature": "'_¸i"
}
]
}
func GetFuncSigFromOpenchain ¶ added in v1.5.0
GetFuncSig recover function signature from 4 bytes hash For example:
param: "0x8c905368" return: ["NotEnoughFunds(uint256,uint256)"]
This function uses openchain API $ curl -X 'GET' 'https://api.openchain.xyz/signature-database/v1/lookup?function=0x8c905368&filter=true' {"ok":true,"result":{"event":{},"function":{"0x8c905368":[{"name":"NotEnoughFunds(uint256,uint256)","filtered":false}]}}} See https://openchain.xyz/signatures
func GetInitCode ¶ added in v1.2.3
func GetNonce ¶ added in v1.2.3
GetNonce get nonce of AA contract If specified in the parameter, it is used directly. If not specified, it is fetched from function getNonce in EntryPoint
func GetPaymasterAndData ¶ added in v1.2.3
func InitGlobalClient ¶
func InitGlobalClient(nodeUrl string)
InitGlobalClient initializes a client that uses the given RPC client.
func MnemonicToPrivateKey ¶ added in v1.2.6
func MnemonicToPrivateKey(mnemonic string, derivationPath string) (*ecdsa.PrivateKey, error)
MnemonicToPrivateKey generate private key from mnemonic words
func ParseBigInt ¶ added in v1.2.3
ParseBigInt parses input string to big.Int.
func RecoverPubkey ¶
RecoverPubkey recover public key, returns 65 bytes uncompressed public key
func SendRawTransaction ¶
SendRawTransaction broadcast signedTxHexStr and return tx returned by rpc node
func SendSignedTx ¶ added in v1.2.3
SendSignedTx broadcast signed tx and return tx returned by rpc node
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 ChainData ¶ added in v1.7.0
type ChainData struct {
Name string `json:"name"`
Chain string `json:"chain"`
ChainId uint64 `json:"chainId"`
Rpc []RpcEndpoint `json:"rpc"`
ChainSlug string `json:"chainSlug"`
}
type ErrFuncNotFound ¶ added in v1.2.3
type ErrFuncNotFound struct {
FuncName string
}
func (ErrFuncNotFound) Error ¶ added in v1.2.3
func (e ErrFuncNotFound) Error() string
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
type RpcEndpoint ¶ added in v1.7.0
Source Files
¶
- aacommon.go
- aadeploy.go
- aasimpleaccount.go
- aatransfer.go
- balance.go
- broadcasttx.go
- buildrawtx.go
- call.go
- common.go
- computecontractaddr.go
- decodetx.go
- deploy.go
- deployerc20.go
- downloadsrc.go
- droptx.go
- dumpaddr.go
- eip712sign.go
- eip7702seteoacode.go
- eip7702signauthtuple.go
- encodeparam.go
- erc20.go
- fourbyte.go
- genkey.go
- getcode.go
- keccak.go
- multicall.go
- personalsign.go
- publicrpc.go
- query.go
- recoverpublickey.go
- root.go
- transfer.go