Documentation
¶
Index ¶
- Constants
- 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 GetInitCode() ([]byte, error)
- func GetNonce(sender string) (*big.Int, error)
- func GetPaymasterAndData() ([]byte, 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 Client
- type ErrFuncNotFound
- type GasStationPrice
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 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 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 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 ErrFuncNotFound ¶ added in v1.2.3
type ErrFuncNotFound struct {
FuncName string
}
func (ErrFuncNotFound) Error ¶ added in v1.2.3
func (e ErrFuncNotFound) Error() string
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
- encodeparam.go
- erc20.go
- fourbyte.go
- genkey.go
- getcode.go
- keccak.go
- multicall.go
- personalsign.go
- query.go
- root.go
- transfer.go