Skip to main content

PlaTrust Wallet js-sdk-API

1. Enumerations (enum)#

  1. Operation: Transaction call methods
CALL: Cross-contract callDElEGATECALL: Cross-contract delegatecall
  1. SignatureMode: Signature composition modes
guardians: Multi-signature must be wallet's guardian membersowner: Multi-signature must be wallet's owner memberssession: Single-signature under session mode without multi-signature

2. Classes (class)#

  1. WalletLib: Wallet base library
  2. Bundler: Bundler RPC library
  3. Paymaster: Paymaster operation library
  4. UserOperation: Encapsulation of user operations structure
  5. Callbase: Base class for assembling wallet function calls in UserOperation
  6. ERC20: UserOperation entry for assembling ERC20 related function calls (Depends on Callbase class)
  7. ERC721: UserOperation entry for assembling ERC721 related function calls (Depends on Callbase class)
  8. ERC1155: UserOperation entry for assembling ERC1155 related function calls (Depends on Callbase class)
  9. LAT: UserOperation entry for assembling LAT transfer related function calls (Depends on Callbase class)

3. Interfaces (interface)#

  1. ApproveToken: Encapsulation of ERC20 approve parameters
  2. ExecutionResult: Encapsulation of transaction normal execution results
  3. ValidationResult: Definition of the execution verification userOp result according to EIP-4337
  4. FailedOp: Exception information
  5. Result: Wrapper information for ExecutionResult, ValidationResult, and FailedOp
  6. StakeInfo: Staking information
  7. ReturnInfo: Gas and content returned when simulating a transaction
  8. EstimateUserOpGas: Estimation result of userOp gas
  9. ParsedTransaction: Encapsulation of transaction receipt
  10. UserOperationReceipt: Execution receipt information of userOp
  11. Logs: Encapsulation of transaction receipt logs

4. Global Functions#

  1. encodeSignature: Encodes the signature information of userOp.
encodeSignature(signatureMode, signature, validAfter?, validUntil?, aggregator?): string

Input Parameters:

Field NameTypeDescriptionRequired
signatureModeBigNumberSignature mode, 0: owner; 1: guardians; 2: sessionY
signaturestringHexadecimal signature informationY
aggregatorstringAggregator address for aggregate signatures (optional)N
validAfterBigNumberSignature's valid-after timestamp (optional)N
validUntilBigNumberSignature's valid-until timestamp (optional)N

Return Parameters:

Field NameTypeDescription
packedSignaturestringSignature information of userOp
  1. decodeSignature: Decodes the signature information of userOp.
decodeSignature(packedSignature): Object

Input Parameters:

Field NameTypeDescriptionRequired
packedSignaturestringSignature information of userOpY

Return Parameters:

| Field Name    | Type      | Description                                        || ------------- | --------- | -------------------------------------------------- || signatureMode | BigNumber | Signature mode, 0: owner; 1: guardians; 2: session || signature     | string    | Hexadecimal signature information                  || aggregator    | string    | Aggregator address for aggregate signatures        || validAfter    | BigNumber | Signature's valid-after timestamp                  || validUntil    | BigNumber | Signature's valid-until timestamp                  |
  1. packSignatureHash: Computes the signature information of a data hash.
packSignatureHash(hash, signatureMode?, validAfter?, validUntil?, aggregator?): string

Input Parameters:

Field NameTypeDescriptionRequired
hashstringData hash to be signedY
signatureModeBigNumberSignature mode, 0: owner; 1: guardians; 2: sessionN
aggregatorstringAggregator address for aggregate signatures (optional)N
validAfterBigNumberSignature's valid-after timestamp (optional)N
validUntilBigNumberSignature's valid-until timestamp (optional)N

Return Parameters:

Field NameTypeDescription
_hashstringkeccak256(abi.encodePacked(hash,signatureMode,aggregator&validAfter&validUntil))
  1. recoverAddress: Resolves the signer's account address.
recoverAddress(msg, signature): string

Input Parameters:

Field NameTypeDescriptionRequired
msgstringData used for signingY
signaturestringSignature informationY

Return Parameters:

Field NameTypeDescription
-stringSigner's account address
  1. signMessage: Signs a message using a private key.
signMessage(msg, privateKey): string

Input Parameters:

Field NameTypeDescriptionRequired
msgstringMessage to be signedY
privateKeystringPrivate keyY

Return Parameters:

Field NameTypeDescription
-stringSignature

5. WalletLib External Functions#

  1. Constructor
new WalletLib(singletonFactory?)

Input:

Field NameTypeDescriptionRequired
singletonFactorystringWallet factory contract addressNo

Output:

WalletLib

  1. singletonFactory Get the wallet's factory contract address
singletonFactory(): string

Input:

None

Output:

Field NameTypeDescription
-stringWallet factory contract address
  1. getInitCode Get the wallet's initCode
getInitCode(walletFactory, walletLogic, initializer, salt): string

Input:

Field NameTypeDescriptionRequired
walletFactorystringWallet factory contract addressYes
walletLogicstringWallet logic contract addressYes
initializerstringWallet initialization encoding (setUp function encoding)Yes
saltstringSalt (controls create2-generated wallet address)Yes

Output:

Field NameTypeDescription
-stringWallet's initCode
  1. getNonce Get the wallet's nonce value
getNonce(walletAddress, etherProvider, defaultBlock?): Promise<number>

Input:

Field NameTypeDescriptionRequired
walletAddressstringWallet contract addressYes
etherProviderethers.providers.BaseProviderethers.js provider (e.g., ethers.provider)Yes
defaultBlockstringearliest, latest, pending, default: latestNo

Output:

Field NameTypeDescription
-numberWallet's nonce value
  1. getPaymasterData Get the paymaster call information for assembling userOp
getPaymasterData(payMasterAddress, token, maxCost): string

Input:

Field NameTypeDescriptionRequired
payMasterAddressstringPaymaster addressYes
tokenstringPaymaster's accepted token addressYes
maxCostBigNumberMaximum costYes

Output:

Field NameTypeDescription
-numberPaymaster call information
  1. getSetupCode Get the setup call encoding for the wallet instance
getSetupCode(entryPoint, owners, threshold, to, data, fallbackHandler, lockPeriod): string

Input:

Field NameTypeDescriptionRequired
entryPointstringEntryPoint contract addressYes
ownersstring[]Multiple owners of the wallet, at least one is requiredYes
thresholdBigNumberMultisig threshold of the wallet ownersYes
tostring'to' parameter for the module call in the walletYes
datastring'calldata' information for the module call in the wallet (in hexadecimal)Yes
fallbackHandlerstringWallet's fallback handler contract addressYes
lockPeriodBigNumberWallet's lock duration, [recommended to be 1 week] (unit: ms)Yes

Output:

Field NameTypeDescription
-stringSetup call encoding
  1. getWalletCode Get the wallet's deployment encoding
getWalletCode(walletLogicAddress, walletProxyConfig?): string

Input:

Field NameTypeDescriptionRequired
walletLogicAddressstringWallet logic contract addressYes
walletProxyConfigstructProxy configuration (including proxy's ABI and proxy's bytecode)No

Output:

Field NameTypeDescription
-stringActual walletproxy encoding (includes the bytecode from walletProxyConfig)
  1. activateWalletOp Assemble userOp for deploying the wallet
activateWalletOp(walletLogic, initializer, paymasterAndData, salt, walletFactory, maxFeePerGas, maxPriorityFeePerGas, callGasLimit, verificationGasLimit, preVerificationGas): UserOperation

Input:

Field NameTypeDescriptionRequired
walletLogicstringWallet logic contract addressYes
initializerstringInitialization function call encoding for the walletYes
paymasterAndDatastringPaymaster call informationYes
saltstringSalt (controls create2-generated wallet address)Yes
walletFactorystringWallet factory contract addressYes
maxFeePerGasnumberMaximum fee per gas (similar to EIP-1559 max_fee_per_gas)Yes
maxPriorityFeePerGasnumberMaximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas)Yes
callGasLimitnumberGas allocated for the main execution call (calculated locally, executing callData's gas)Yes
verificationGasLimitnumberGas allocated for the verification step (used in functions validateUserOp()/validatePaymasterUserOp())Yes
preVerificationGasnumberGas paid for compensating pre-verification execution and call data bundling (extra gas prepared to handle some routine logic gas consumption)Yes

Output:

Field NameTypeDescription
-UserOperationAssembled userOp
  1. calculateWalletAddress Calculate the wallet address (create2-generated address)
calculateWalletAddress(walletLogic, initializer, salt, walletFactory): string

Input:

Field NameTypeDescriptionRequired
walletLogicstringWallet logic contract addressYes
initializerstringInitialization function call encoding for the walletYes
saltstringSalt (controls create2-generated wallet address)Yes
walletFactorystringWallet factory contract addressYes

Output:

Field NameTypeDescription
-stringWallet address
  1. addOwnerWithThresholdOp Add a wallet owner and update the multisig threshold
addOwnerWithThresholdOp(walletAddress, etherProvider, owner, threshold, paymasterAndData, maxFeePerGas, maxPriorityFeePerGas, callGasLimit, verificationGasLimit, preVerificationGas): Promise<UserOperation>

Input:

Field NameTypeDescriptionRequired
walletAddressstringWallet proxy contract addressYes
etherProviderethers.providers.BaseProviderethers.js provider (e.g., ethers.provider)Yes
ownerstringNew wallet ownerYes
thresholdnumberWallet multisig thresholdYes
paymasterAndDatastringPaymaster contract address and data sent to paymaster, currently, the implementation of paymaster is not clear, if we use our own paymaster, this value is not required, fixed to 0x0No
maxFeePerGasnumberMaximum fee per gas (similar to EIP-1559 max_fee_per_gas)No
maxPriorityFeePerGasnumberMaximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas)No
callGasLimitnumberGas allocated for the main execution call (calculated locally, executing callData's gas)No
verificationGasLimitnumberGas allocated for the verification step (used in functions validateUserOp()/validatePaymasterUserOp())No
preVerificationGasnumberGas paid for compensating pre-verification execution and call data bundling (extra gas prepared to handle some routine logic gas consumption)No

Output:

Field NameTypeDescription
-UserOperationAssembled userOp
  1. changeThresholdOp Update the multisig threshold
changeThresholdOp(walletAddress, etherProvider, threshold, paymasterAndData, maxFeePerGas, maxPriorityFeePerGas, callGasLimit, verificationGasLimit, preVerificationGas): Promise<UserOperation>

Input:

Field NameTypeDescriptionRequired
walletAddressstringWallet proxy contract addressYes
etherProviderethers.providers.BaseProviderethers.js provider (e.g., ethers.provider)Yes
thresholdnumberWallet multisig thresholdYes
paymasterAndDatastringPaymaster contract address and data sent to paymaster, currently, the implementation of paymaster is not clear, if we use our own paymaster, this value is not required, fixed to 0x0No
maxFeePerGasnumberMaximum fee per gas (similar to EIP-1559 max_fee_per_gas)No
maxPriorityFeePerGasnumberMaximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas)No
callGasLimitnumberGas allocated for the main execution call (calculated locally, executing callData's gas)No
verificationGasLimitnumberGas allocated for the verification step (used in functions validateUserOp()/validatePaymasterUserOp())No
preVerificationGasnumberGas paid for compensating pre-verification execution and call data bundling (extra gas prepared to handle some routine logic gas consumption)No

Output:

Field NameTypeDescription
-UserOperationAssembled userOp
  1. getThreshold - Get the threshold of the wallet's multisig.

getThreshold(walletAddress, etherProvider): Promise

markdown Copy code

Input Parameters:

FieldTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderethers.js provider, e.g., ethers.providerY

Return Parameters:

FieldTypeDescription
-numberMultisig threshold
  1. swapOwnerOp - Replace an owner of a wallet.
swapOwnerOp(walletAddress, etherProvider, prevOwner, oldOwner, newOwner, paymasterAndData, maxFeePerGas, maxPriorityFeePerGas, callGasLimit, verificationGasLimit, preVerificationGas): Promise<UserOperation>

Input Parameters:

FieldTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderethers.js provider, e.g., ethers.providerY
prevOwnerstringPrevious owner of the owner to be replacedY
oldOwnerstringOwner to be replacedY
newOwnerstringNew ownerY
paymasterAndDatastringPaymaster contract address and data to send to it (currently unclear implementation of paymaster, set to 0x0 if using our own paymaster)N
maxFeePerGasnumberMaximum fee per gas for each type of gas (similar to EIP-1559 max_fee_per_gas)N
maxPriorityFeePerGasnumberMaximum priority fee per gas for each type of gas (similar to EIP-1559 max_priority_fee_per_gas)N
callGasLimitnumberGas allocated for main execution call (simulated locally, gas for executing callData)N
verificationGasLimitnumberGas allocated for verification steps (used in functions validateUserOp()/validatePaymasterUserOp())N
preVerificationGasnumberGas paid for compensating pre-verification execution and call data bundler (extra gas to handle regular gas consumption, e.g., in loops)N

Return Parameters:

FieldTypeDescription
-UserOperationAssembled userOp
  1. removeOwnerOp - Remove an owner from the wallet.
removeOwnerOp(walletAddress, etherProvider, prevOwner, owner, threshold, paymasterAndData, maxFeePerGas, maxPriorityFeePerGas, callGasLimit, verificationGasLimit, preVerificationGas): Promise<UserOperation>

Input Parameters:

FieldTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderethers.js provider, e.g., ethers.providerY
prevOwnerstringPrevious owner of the owner to be removedY
ownerstringOwner to be removedY
thresholdnumberNew multisig threshold (if no update needed, provide the old value)Y
paymasterAndDatastringPaymaster contract address and data to send to it (currently unclear implementation of paymaster, set to 0x0 if using our own paymaster)N
maxFeePerGasnumberMaximum fee per gas for each type of gas (similar to EIP-1559 max_fee_per_gas)N
maxPriorityFeePerGasnumberMaximum priority fee per gas for each type of gas (similar to EIP-1559 max_priority_fee_per_gas)N
callGasLimitnumberGas allocated for main execution call (simulated locally, gas for executing callData)N
verificationGasLimitnumberGas allocated for verification steps (used in functions validateUserOp()/validatePaymasterUserOp())N
preVerificationGasnumberGas paid for compensating pre-verification execution and call data bundler (extra gas to handle regular gas consumption, e.g., in loops)N

Return Parameters:

FieldTypeDescription
-UserOperationAssembled userOp
  1. getOwners - Get the list of owners of the wallet.
getOwners(walletAddress, etherProvider): Promise<Array<string>>

Input Parameters:

FieldTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderethers.js provider, e.g., ethers.providerY

Return Parameters:

FieldTypeDescription
-Array\<string>List of wallet owners
  1. isOwner - Check if an account is an owner of the wallet.
isOwner(owner, walletAddress, etherProvider): Promise<boolean>

Input Parameters:

FieldTypeDescriptionRequired
ownerstringAccount address to be checkedY
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderethers.js provider, e.g., ethers.providerY

Return Parameters:

FieldTypeDescription
-booleanWhether it is a wallet owner
  1. startSessionOp - Start a multisig-free session.
startSessionOp(walletAddress, etherProvider, sessionUser, duration, paymasterAndData, maxFeePerGas, maxPriorityFeePerGas, callGasLimit, verificationGasLimit, preVerificationGas): Promise<UserOperation>

Input Parameters:

FieldTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderethers.js provider, e.g., ethers.providerY
sessionUserstringOwner of the wallet sessionY
durationnumberValid duration of the wallet session (in ms)Y
paymasterAndDatastringPaymaster contract address and data to send to it (currently unclear implementation of paymaster, set to 0x0 if using our own paymaster)N
maxFeePerGasnumberMaximum fee per gas for each type of gas (similar to EIP-1559 max_fee_per_gas)N
maxPriorityFeePerGasnumberMaximum priority fee per gas for each type of gas (similar to EIP-1559 max_priority_fee_per_gas)N
callGasLimitnumberGas allocated for main execution call (simulated locally, gas for executing callData)N
verificationGasLimitnumberGas allocated for verification steps (used in functions validateUserOp()/validatePaymasterUserOp())N
preVerificationGasnumberGas paid for compensating pre-verification execution and call data bundler (extra gas to handle regular gas consumption, e.g., in loops)N

Return Parameters:

FieldTypeDescription
-UserOperationAssembled userOp
  1. clearSessionOp - End a multisig-free session.
clearSessionOp(walletAddress, etherProvider, paymasterAndData, maxFeePerGas, maxPriorityFeePerGas, callGasLimit, verificationGasLimit, preVerificationGas): Promise<UserOperation>

Input Parameters:

FieldTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderethers.js provider, e.g., ethers.providerY
paymasterAndDatastringPaymaster contract address and data to send to it (currently unclear implementation of paymaster, set to 0x0 if using our own paymaster)N
maxFeePerGasnumberMaximum fee per gas for each type of gas (similar to EIP-1559 max_fee_per_gas)N
maxPriorityFeePerGasnumberMaximum priority fee per gas for each type of gas (similar to EIP-1559 max_priority_fee_per_gas)N
callGasLimitnumberGas allocated for main execution call (simulated locally, gas for executing callData)N
verificationGasLimitnumberGas allocated for verification steps (used in functions validateUserOp()/validatePaymasterUserOp())N
preVerificationGasnumberGas paid for compensating pre-verification execution and call data bundler (extra gas to handle regular gas consumption, e.g., in loops)N

Return Parameters:

FieldTypeDescription
-UserOperationAssembled userOp
  1. enableModuleOp - Enable a module.
enableModuleOp(walletAddress, etherProvider, module, paymasterAndData, maxFeePerGas, maxPriorityFeePerGas, callGasLimit, verificationGasLimit, preVerificationGas): Promise<UserOperation>

Input Parameters:

FieldTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderethers.js provider, e.g., ethers.providerY
modulestringModule addressY
paymasterAndDatastringPaymaster contract address and data to send to it (currently unclear implementation of paymaster, set to 0x0 if using our own paymaster)N
maxFeePerGasnumberMaximum fee per gas for each type of gas (similar to EIP-1559 max_fee_per_gas)N
maxPriorityFeePerGasnumberMaximum priority fee per gas for each type of gas (similar to EIP-1559 max_priority_fee_per_gas)N
callGasLimitnumberGas allocated for main execution call (simulated locally, gas for executing callData)N
verificationGasLimitnumberGas allocated for verification steps (used in functions validateUserOp()/validatePaymasterUserOp())N
preVerificationGasnumberGas paid for compensating pre-verification execution and call data bundler (extra gas to handle regular gas consumption, e.g., in loops)N

Return Parameters:

FieldTypeDescription
-UserOperationAssembled userOp
  1. disableModuleOp - Disable a module.
disableModuleOp(walletAddress, etherProvider, prevModule, module, paymasterAndData, maxFeePerGas, maxPriorityFeePerGas, callGasLimit, verificationGasLimit, preVerificationGas): Promise<UserOperation>

Input Parameters:

FieldTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderethers.js provider, e.g., ethers.providerY
prevModulestringPrevious module address to be disabledY
modulestringModule address to be disabledY
paymasterAndDatastringPaymaster contract address and data to send to it (currently unclear implementation of paymaster, set to 0x0 if using our own paymaster)N
maxFeePerGasnumberMaximum fee per gas for each type of gas (similar to EIP-1559 max_fee_per_gas)N
maxPriorityFeePerGasnumberMaximum priority fee per gas for each type of gas (similar to EIP-1559 max_priority_fee_per_gas)N
callGasLimitnumberGas allocated for main execution call (simulated locally, gas for executing callData)N
verificationGasLimitnumberGas allocated for verification steps (used in functions validateUserOp()/validatePaymasterUserOp())N
preVerificationGasnumberGas paid for compensating pre-verification execution and call data bundler (extra gas to handle regular gas consumption, e.g., in loops)N

Return Parameters:

FieldTypeDescription
-UserOperationAssembled userOp
  1. isEnabledModule - Check if an address is a valid module.
isEnabledModule(module, walletAddress, etherProvider): Promise<boolean>

Input Parameters:

FieldTypeDescriptionRequired
modulestringModule addressY
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderethers.js provider, e.g., ethers.providerY

Return Parameters:

FieldTypeDescription
-booleanWhether it is a valid module
  1. isEnabledModules - Check a group of addresses for valid modules.
isEnabledModules(modules, walletAddress, etherProvider): Promise<boolean>

Input Parameters:

FieldTypeDescriptionRequired
modulesstring[]A group of module addressesY
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderethers.js provider, e.g., ethers.providerY

Return Parameters:

FieldTypeDescription
-booleanWhether all are valid modules
  1. getModulesPaginated Paginated retrieval of an array of modules
getModulesPaginated(start: string, pageSize: number, walletAddress: string, etherProvider: ethers.providers.BaseProvider): Promise<any[]>

Input Parameter:

Field NameTypeDescriptionRequired
startstringStarting address of the paginationY
pageSizenumberPage sizeY
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderEthers.js provider, e.g., ethers.providerY

Return Parameter:

Field NameTypeDescription
-any[]Array of modules returned, and the address of the next page of modules (The first element is the list of modules, and the second element is the address of the next page)
  1. lockWalletOp Lock the wallet
lockWalletOp(walletAddress: string, etherProvider: ethers.providers.BaseProvider, paymasterAndData: string, maxFeePerGas: number, maxPriorityFeePerGas: number, callGasLimit: number, verificationGasLimit: number, preVerificationGas: number): Promise<UserOperation>

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderEthers.js provider, e.g., ethers.providerY
paymasterAndDatastringPaymaster contract address and data sent to paymaster (The current implementation of paymaster is not yet clear. If we use our own paymaster, this value is not required and can be fixed to 0x0.)N
maxFeePerGasnumberMaximum fee per unit of gas, similar to EIP-1559 max_fee_per_gasN
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, similar to EIP1559 max_priority_fee_per_gasN
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)N
verificationGasLimitnumberGas allocated for the verification step (used in functions validateUserOp() and validatePaymasterUserOp())N
preVerificationGasnumberGas paid for compensating the pre-verification execution and call data bundler (additional gas reserved to deal with some regular gas consumption, such as loops)N

Return Parameter:

Field NameTypeDescription
-UserOperationAssembled UserOperation
  1. unlockWalletOp Unlock the wallet
unlockWalletOp(walletAddress: string, etherProvider: ethers.providers.BaseProvider, paymasterAndData: string, maxFeePerGas: number, maxPriorityFeePerGas: number, callGasLimit: number, verificationGasLimit: number, preVerificationGas: number): Promise<UserOperation>

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderEthers.js provider, e.g., ethers.providerY
paymasterAndDatastringPaymaster contract address and data sent to paymaster (The current implementation of paymaster is not yet clear. If we use our own paymaster, this value is not required and can be fixed to 0x0.)N
maxFeePerGasnumberMaximum fee per unit of gas, similar to EIP-1559 max_fee_per_gasN
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, similar to EIP1559 max_priority_fee_per_gasN
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)N
verificationGasLimitnumberGas allocated for the verification step (used in functions validateUserOp() and validatePaymasterUserOp())N
preVerificationGasnumberGas paid for compensating the pre-verification execution and call data bundler (additional gas reserved to deal with some regular gas consumption, such as loops)N

Return Parameter:

Field NameTypeDescription
-UserOperationAssembled UserOperation
  1. isLocked Verify if the wallet is locked
isLocked(walletAddress: string, etherProvider: ethers.providers.BaseProvider): Promise<boolean>

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderEthers.js provider, e.g., ethers.providerY

Return Parameter:

Field NameTypeDescription
-booleanWhether the wallet is locked or not (true: locked; false: not locked)
  1. getLock Retrieve the lock duration of the wallet

getLock(walletAddress: string, etherProvider: ethers.providers.BaseProvider): Promise Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderEthers.js provider, e.g., ethers.providerY

Return Parameter:

Field NameTypeDescription
-numberLock duration of the wallet (in ms)
  1. setFallbackHandlerOp Set the wallet's fallback handler for additional functionalities
setFallbackHandlerOp(walletAddress: string, etherProvider: ethers.providers.BaseProvider, handler: string, paymasterAndData: string, maxFeePerGas: number, maxPriorityFeePerGas: number, callGasLimit: number, verificationGasLimit: number, preVerificationGas: number): Promise<UserOperation>

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderEthers.js provider, e.g., ethers.providerY
handlerstringWallet extension contract addressY
paymasterAndDatastringPaymaster contract address and data sent to paymaster (The current implementation of paymaster is not yet clear. If we use our own paymaster, this value is not required and can be fixed to 0x0.)N
maxFeePerGasnumberMaximum fee per unit of gas, similar to EIP-1559 max_fee_per_gasN
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, similar to EIP1559 max_priority_fee_per_gasN
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)N
verificationGasLimitnumberGas allocated for the verification step (used in functions validateUserOp() and validatePaymasterUserOp())N
preVerificationGasnumberGas paid for compensating the pre-verification execution and call data bundler (additional gas reserved to deal with some regular gas consumption, such as loops)N

Return Parameter:

Field NameTypeDescription
-UserOperationAssembled UserOperation
  1. getEntryPoint Retrieve the EntryPoint address of the wallet
getEntryPoint(walletAddress: string, etherProvider: ethers.providers.BaseProvider): Promise<string>

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderEthers.js provider, e.g., ethers.providerY

Return Parameter:

Field NameTypeDescription
-stringEntryPoint address
  1. withdrawDepositOp Withdraw the wallet's own pledge to the amount advanced to the EntryPoint
withdrawDepositOp(walletAddress: string, etherProvider: ethers.providers.BaseProvider, withdrawAddress: string, amount: number, paymasterAndData: string, maxFeePerGas: number, maxPriorityFeePerGas: number, callGasLimit: number, verificationGasLimit: number, preVerificationGas: number): Promise<UserOperation>

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderEthers.js provider, e.g., ethers.providerY
withdrawAddressstringWithdraw addressY
amountnumberAmount of the pledge to be withdrawnY
paymasterAndDatastringPaymaster contract address and data sent to paymaster (The current implementation of paymaster is not yet clear. If we use our own paymaster, this value is not required and can be fixed to 0x0.)N
maxFeePerGasnumberMaximum fee per unit of gas, similar to EIP-1559 max_fee_per_gasN
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, similar to EIP1559 max_priority_fee_per_gasN
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)N
verificationGasLimitnumberGas allocated for the verification step (used in functions validateUserOp() and validatePaymasterUserOp())N
preVerificationGasnumberGas paid for compensating the pre-verification execution and call data bundler (additional gas reserved to deal with some regular gas consumption, such as loops)N

Return Parameter:

Field NameTypeDescription
-UserOperationAssembled UserOperation
  1. addDeposit Pledge the wallet's own deposit to the EntryPoint
addDeposit(walletAddress: string, signer: ethers.Wallet, value: string): Promise<any>

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
signerethers.WalletEthers.js WalletY
valuestringThe amount of the pledgeY

Return Parameter:

None

  1. getDeposit Query the balance of the wallet's own deposit
getDeposit(walletAddress: string, etherProvider: ethers.providers.BaseProvider): Promise<number>

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet proxy contract addressY
etherProviderethers.providers.BaseProviderEthers.js provider, e.g., ethers.providerY

Return Parameter:

Field NameTypeDescription
-numberBalance of the wallet's own deposit

6. Bundler External Functions#

  1. Constructor
new Bundler(entryPoint: string, etherProvider: ethers.providers.BaseProvider, bundlerApiURL: string, timeout?: ApiTimeOut)

Input Parameters:

NameTypeDescriptionRequired
entryPointstringAddress of the entryPoint contractY
etherProviderethers.providers.BaseProviderethers.js provider, e.g., ethers.providerY
bundlerApiURLstringURL of the bundlerY
timeoutApiTimeOutTimeout options: web3ApiRequestTimeout, web3ApiResponseTimeout, bundlerApiRequestTimeout, bundlerApiResponseTimeoutN

Return Parameters:

NameTypeDescription
-BundlerBundler object
  1. platon_chainId (EIP-4337 specification) - Returns the EIP-155 chain ID
platon_chainId(timeout?: number): Promise<string>

Input Parameters:

NameTypeDescriptionRequired
timeoutnumberTimeoutN

Return Parameters:

NameTypeDescription
-stringChain ID
  1. platon_estimateUserOperationGas (EIP-4337 specification) - Estimates gas for UserOperation
platon_estimateUserOperationGas(userOp: UserOperation, timeout?: number): Promise<EstimateUserOpGas>

Input Parameters:

NameTypeDescriptionRequired
userOpUserOperationUserOperation objectY
timeoutnumberTimeoutN

Return Parameters:

NameTypeDescription
-EstimateUserOpGasGas estimation result
  1. platon_getUserOperationByHash (EIP-4337 specification) - Returns a UserOperation based on the hash returned by eth_sendUserOperation
platon_getUserOperationByHash(userOpHash: string, timeout?: number): Promise<null | UserOperationReceipt>

Input Parameters:

NameTypeDescriptionRequired
userOpHashstringUserOp's hashY
timeoutnumberTimeoutN

Return Parameters:

NameTypeDescription
-UserOperationReceiptEIP-4337 specification-defined response
  1. platon_getUserOperationReceipt (EIP-4337 specification) - Returns a UserOperation receipt based on the hash returned by eth_sendUserOperation
platon_getUserOperationReceipt(userOpHash: string, timeout?: number): Promise<null | UserOperationReceipt>

Input Parameters:

NameTypeDescriptionRequired
userOpHashstringUserOp's hashY
timeoutnumberTimeoutN

Return Parameters:

NameTypeDescription
-UserOperationReceiptEIP-4337 specification-defined response
  1. platon_sendUserOperation (EIP-4337 specification) - Submits a UserOperation object to the bundler's User Operation pool
platon_sendUserOperation(userOp: UserOperation, timeout?: number): Promise<string>

Input Parameters:

NameTypeDescriptionRequired
userOpUserOperationUserOperation informationY
timeoutnumberTimeoutN

Return Parameters:

NameTypeDescription
-stringEIP-4337 userOpHash
  1. platon_supportedEntryPoints (EIP-4337 specification) - Returns an array of entryPoint contract addresses supported by the bundler
platon_supportedEntryPoints(timeout?: number): Promise<string[]>

Input Parameters:

NameTypeDescriptionRequired
timeoutnumberTimeoutN

Return Parameters:

NameTypeDescription
-string[]Array of entryPoint contract addresses
  1. sendUserOperation Submits a UserOperation object to the bundler's User Operation pool and appends a listener
sendUserOperation(userOp: UserOperation, timeout?: number, receiptTimeout?: number, receiptInterval?: number): EventEmitter

Input Parameters:

NameTypeDescriptionRequired
userOpUserOperationUserOperation informationY
timeoutnumberTimeout for bundler requestN
receiptTimeoutnumberTimeout for listenerN
receiptIntervalnumberListener intervalN

Return Parameters:

NameTypeDescription
-EventEmitterJS event listener
  1. simulateHandleOp Simulates the execution of a userOp
simulateHandleOp(op: UserOperation, target?: string, targetCallData?: string): Promise<Result>

Input Parameters:

NameTypeDescriptionRequired
opUserOperationUserOperation informationY
targetstringTarget address if non-zero, indicating a call to be made after the userOp simulation. If called, targetSuccess and TargetResult are set to the return value of the callN
targetCallDatastringCallData to be passed to the target addressN

Return Parameters:

NameTypeDescription
-ResultExecution result
  1. simulateValidation Simulates the validation of a userOp
simulateValidation(op: UserOperation): Promise<Result>

Input Parameters:

NameTypeDescriptionRequired
opUserOperationUserOperation informationY

Return Parameters:

NameTypeDescription
-ResultExecution result

7. Paymaster External Functions#

  1. Constructor
new Paymaster(payMasterAddress: string, wallet: ethers.Wallet)

Input Parameters:

NameTypeDescriptionRequired
payMasterAddressstringPaymaster addressY
walletethers.Walletethers.js wallet instance (owner of the paymaster)Y

Return Parameters:

NameTypeDescription
-PaymasterPaymaster object
  1. addSupportedToken Add supported token category
addSupportedToken(token: string, priceOracle: string): Promise<any>

Input Parameters:

NameTypeDescriptionRequired
tokenstringToken addressY
priceOraclestringToken's price oracle addressY

Return Parameters:

NameTypeDescription
-transaction receiptTransaction receipt
  1. removeSupportedToken Remove supported token category
removeSupportedToken(token: string): Promise<any>

Input Parameters:

NameTypeDescriptionRequired
tokenstringToken addressY

Return Parameters:

NameTypeDescription
-transaction receiptTransaction receipt
  1. paymasterSupportedToken Check supported token category
paymasterSupportedToken(tokens: string[]): Promise<string[]>

Input Parameters:

NameTypeDescriptionRequired
tokensstring[]Token addressesY

Return Parameters:

NameTypeDescription
-string[]Token addresses
  1. entryPoint Get the entrypoint contract address of the paymaster
entryPoint(): Promise<any>

Input Parameters:

NameTypeDescriptionRequired
--None-

Return Parameters:

NameTypeDescription
-addressEntrypoint address
  1. addStake Add stake
addStake(extraUnstakeDelaySec: number, value: string): Promise<any>

Input Parameters:

NameTypeDescriptionRequired
extraUnstakeDelaySecnumberDelay in seconds for unstakingY
valuestringHex value of the staking amount (in lat)Y

Return Parameters:

NameTypeDescription
-transaction receiptTransaction receipt
  1. deposit Add deposit amount
deposit(value: string): Promise<any>

Input Parameters:

NameTypeDescriptionRequired
valuestringHex value of the deposit amount (in lat)Y

Return Parameters:

NameTypeDescription
-transaction receiptTransaction receipt
  1. unlockStake Unlock stake
unlockStake(): Promise<any>

Input Parameters:

NameTypeDescriptionRequired
--None-

Return Parameters:

NameTypeDescription
-transaction receiptTransaction receipt
  1. withdrawStake Withdraw stake amount
withdrawStake(withdrawAddress: string): Promise<any>

Input Parameters:

NameTypeDescriptionRequired
withdrawAddressstringAccount address to receive the withdrawn stakeY

Return Parameters:

NameTypeDescription
-transaction receiptTransaction receipt
  1. withdrawTo Withdraw deposit amount
withdrawTo(withdrawAddress: string, amount: string): Promise<any>

Input Parameters:

NameTypeDescriptionRequired
withdrawAddressstringAccount address to receive the withdrawn depositY
amountstringHex value of the withdrawn deposit amount (in lat)Y

Return Parameters:

NameTypeDescription
-transaction receiptTransaction receipt
  1. withdrawToken Withdraw compensated tokens
withdrawToken(token: string, to: string, amount: string): Promise<any>

Input Parameters:

NameTypeDescriptionRequired
tokenstringToken address to be withdrawnY
tostringAccount address to receive the withdrawn tokensY
amountstringAmount of tokens to be withdrawn (in lat)Y

Return Parameters:

NameTypeDescription
-transaction receiptTransaction receipt
  1. getDeposit Get remaining deposit balance
getDeposit(): Promise<any>

Input Parameters:

NameTypeDescriptionRequired
--None-

Return Parameters:

NameTypeDescription
-numberDeposit balance
  1. getExchangePrice Get token price information
getExchangePrice(token: string, fetchTokenDecimals?: boolean): Promise<{ decimals: number; price: BigNumber; tokenDecimals: undefined | number }>

Input Parameters:

NameTypeDescriptionRequired
tokenstringToken addressY
fetchTokenDecimalsbooleanWhether to fetch token decimalsN

Return Parameters:

NameTypeDescription
priceBigNumberToken price
decimalsnumberToken price decimals
tokenDecimalsnumberToken decimals

8. UserOperation External Functions#

  1. Constructor
new UserOperation(sender?, nonce?, initCode?, callData?, callGasLimit?, maxFeePerGas?, maxPriorityFeePerGas?, paymasterAndData?, verificationGasLimit?, preVerificationGas?, signature?)

Return Parameters:

Field NameTypeDescriptionRequired
senderstringWallet address that performs the operation (the address of the wallet contract, but the sender's EOA address during the first deployment)N
noncenumberAnti-replay parameter set in the wallet, also used as salt for the initial creation of the walletN
initCodestringAll wallet creation in this design is deployed by the predefined wallet template contract (EIP-1167), so this field is emptyN
callDatastringData passed by the sender to the main execution call (opcode converted by the wallet from the user's request)N
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)N
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)N
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)N
paymasterAndDatastringPaymaster contract address and data sent to the paymaster, the implementation of the paymaster is not clear yet, and if we use our own paymaster, this value is not needed, set to 0x0N
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())N
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)N
signaturestringSignatures of multiple Owners, multiple Owners sign the UserOperationN

Return Parameter:

UserOperation

  1. addSupportedToken Serialize UserOperation
Serialized(): void

Input Parameter:

None

Return Parameter:

None

  1. callDataCost Calculate the call cost
callDataCost(): number

Input Parameter:

None

Return Parameter:

Field NameTypeDescription
-BigNumberCall cost
  1. getStruct Get the serialized UserOperation
getStruct(): SerializedUserOperation

Input Parameter:

None

Return Parameter:

Field NameTypeDescription
senderstringWallet address that performs the operation (the address of the wallet contract, but the sender's EOA address during the first deployment)
noncenumberAnti-replay parameter set in the wallet, also used as salt for the initial creation of the wallet
initCodestringAll wallet creation in this design is deployed by the predefined wallet template contract (EIP-1167), so this field is empty
callDatastringData passed by the sender to the main execution call (opcode converted by the wallet from the user's request)
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)
paymasterAndDatastringPaymaster contract address and data sent to the paymaster, the implementation of the paymaster is not clear yet, and if we use our own paymaster, this value is not needed, set to 0x0
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)
signaturestringSignatures of multiple Owners, multiple Owners sign the UserOperation
  1. getUserOpHash Get UserOperation Hash
getUserOpHash(entryPointAddress, chainId): string

Input Parameter:

Field NameTypeDescriptionRequired
entryPointAddressstringEntrypoint contract addressY
chainIdnumberChain IDY

Return Parameter:

Field NameTypeDescription
-stringUserOperation hash value
  1. getUserOpHashFromContract Get UserOperation Hash
getUserOpHashFromContract(entryPointAddress, etherProvider, defaultBlock?): Promise<string>

Input Parameter:

Field NameTypeDescriptionRequired
entryPointAddressstringEntrypoint contract addressY
etherProviderethers.providers.BaseProviderethers.js provider, e.g., ethers.providerY
defaultBlockstring'earliest', 'latest', 'pending', default: 'latest'N

Return Parameter:

Field NameTypeDescription
-stringUserOperation hash value
  1. packUserOp Assemble EIP-712 information of UserOperation
packUserOp(forSignature?): string

Input Parameter:

Field NameTypeDescriptionRequired
forSignaturebooleanWhether it is for computing the EIP-712 information for signature value, true: does not include the signature value; false: includes the signature valueN

Return Parameter:

Field NameTypeDescription
-stringEIP-712 information of UserOperation
  1. signWithSignature Fill in the value of the 'signature' field of UserOperation based on the signature, signature mode, validity period start time, and validity period end time
signWithSignature(signature, signatureMode?, validAfter?, validUntil?): void

Input Parameter:

Field NameTypeDescriptionRequired
signaturestringSignature messageY
signatureModeSignatureModeSignature mode, 0: owner; 1: guardians; 2: sessionN
validAfternumberValidity period start timeN
validUntilnumberValidity period end timeN

Return Parameter:

None

  1. toJSON Convert UserOperation to JSON format information
toJSON(): string

Input Parameter:

None

Return Parameter:

Field NameTypeDescription
-stringJSON format information of UserOperation
  1. toTuple Convert UserOperation to tuple format information
toTuple(): string

Input Parameter:

None

Return Parameter:

Field NameTypeDescription
-stringTuple format information of UserOperation
  1. fromJSON Convert JSON format information to UserOperation
fromJSON(json): UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
jsonstringJSON format information of UserOperationY

Return Parameter:

Field NameTypeDescription
-UserOperationUserOperation information
  1. fromObject Convert object format information to UserOperation
fromObject(obj): UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
objobjectObject format information of UserOperationY

Return Parameter:

Field NameTypeDescription
-UserOperationUserOperation information

9. Callbase External Functions#

  1. createOp Create UserOperation for calling the wallet (executeFromModule)
createOp(        walletAddress: string,        nonce: NumberLike,        paymasterAndData: string,        maxFeePerGas: NumberLike,        maxPriorityFeePerGas: NumberLike,        callGasLimit: NumberLike,        verificationGasLimit: NumberLike,        preVerificationGas: NumberLike,        data: string,    ) : UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet address that performs the operation (the address of the wallet contract, but the sender's EOA address during the first deployment)Y
noncenumberAnti-replay parameter set in the wallet, also used as salt for the initial creation of the walletY
paymasterAndDatastringPaymaster contract address and data sent to the paymaster, the implementation of the paymaster is not clear yet, and if we use our own paymaster, this value is not needed, set to 0x0Y
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)Y
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)Y
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)Y
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())Y
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)Y
datastringParameter for calling the wallet contract's executeFromModule (i.e., the encoded call for other wallet functions)Y

Return Parameter:

UserOperation

  1. createOpByBatch Create UserOperation for calling the wallet (executeBatchFromModule)
createOpByBatch(        walletAddress: string,        nonce: NumberLike,        paymasterAndData: string,        maxFeePerGas: NumberLike,        maxPriorityFeePerGas: NumberLike,        callGasLimit: NumberLike,        verificationGasLimit: NumberLike,        preVerificationGas: NumberLike,        datas: string[],    ) : UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet address that performs the operation (the address of the wallet contract, but the sender's EOA address during the first deployment)Y
noncenumberAnti-replay parameter set in the wallet, also used as salt for the initial creation of the walletY
paymasterAndDatastringPaymaster contract address and data sent to the paymaster, the implementation of the paymaster is not clear yet, and if we use our own paymaster, this value is not needed, set to 0x0Y
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)Y
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)Y
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)Y
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())Y
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)Y
datasstring[]Parameters for calling the wallet contract's executeBatchFromModule (i.e., the encoded calls for other wallet functions)Y

Return Parameter:

UserOperation

10. ERC20 External Functions#

  1. Constructor
new ERC20()

Input Parameter:

None

Return Parameter:

ERC20

  1. approve Create UserOperation for calling the 'approve' function of ERC20
approve(walletAddress: string, nonce: NumberLike, paymasterAddress: string,            maxFeePerGas: NumberLike, maxPriorityFeePerGas: NumberLike, callGasLimit: NumberLike,            verificationGasLimit: NumberLike, preVerificationGas: NumberLike, _token: string, _spender: string, _value: string) : UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet addressY
noncenumberWallet nonceY
paymasterAddressstringPaymaster addressY
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)Y
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)Y
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)Y
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())Y
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)Y
_tokenstringERC20 token address to operate onY
_spenderstringThe _spender parameter for 'approve'Y
_valuestringThe _value parameter for 'approve'Y

Return Parameter:

UserOperation

  1. transferFrom Create UserOperation for calling the 'transferFrom' function of ERC20
transferFrom(walletAddress: string, nonce: NumberLike, paymasterAddress: string,                 maxFeePerGas: NumberLike, maxPriorityFeePerGas: NumberLike, callGasLimit: NumberLike,                 verificationGasLimit: NumberLike, preVerificationGas: NumberLike, _token: string, _from: string, _to: string, _value: string) : UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet addressY
noncenumberWallet nonceY
paymasterAddressstringPaymaster addressY
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)Y
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)Y
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)Y
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())Y
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)Y
_tokenstringERC20 token address to operate onY
_fromstringThe _from parameter for 'transferFrom'Y
_tostringThe _to parameter for 'transferFrom'Y
_valuestringThe _value parameter for 'transferFrom'Y

Return Parameter:

UserOperation

  1. transfer Create UserOperation for calling the 'transfer' function of ERC20
transfer(walletAddress: string, nonce: NumberLike, paymasterAddress: string,             maxFeePerGas: NumberLike, maxPriorityFeePerGas: NumberLike, callGasLimit: NumberLike,             verificationGasLimit: NumberLike, preVerificationGas: NumberLike, _token: string, _to: string, _value: string) : UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet addressY
noncenumberWallet nonceY
paymasterAddressstringPaymaster addressY
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)Y
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)Y
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)Y
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())Y
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)Y
_tokenstringERC20 token address to operate onY
_tostringThe _to parameter for 'transfer'Y
_valuestringThe _value parameter for 'transfer'Y

Return Parameter:

UserOperation

11. ERC721 External Functions#

  1. Constructor
new ERC721();

Input Parameter:

None

Return Parameter:

ERC721

  1. approve Create UserOperation for calling the 'approve' function of ERC721
approve(walletAddress: string, nonce: NumberLike, paymasterAddress: string,        maxFeePerGas: NumberLike, maxPriorityFeePerGas: NumberLike, callGasLimit: NumberLike,        verificationGasLimit: NumberLike, preVerificationGas: NumberLike, _token: string, _spender: string, _tokenId: string) : UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet addressY
noncenumberWallet nonceY
paymasterAddressstringPaymaster addressY
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)Y
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)Y
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)Y
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())Y
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)Y
_tokenstringERC20 token address to operate onY
_spenderstringThe _spender parameter for 'approve'Y
_tokenIdstringThe _tokenId parameter for 'approve'Y

Return Parameter:

UserOperation

  1. transferFrom Create UserOperation for calling the 'transferFrom' function of ERC721
transferFrom(walletAddress: string, nonce: NumberLike, paymasterAddress: string,             maxFeePerGas: NumberLike, maxPriorityFeePerGas: NumberLike, callGasLimit: NumberLike,             verificationGasLimit: NumberLike, preVerificationGas: NumberLike, _token: string, _from: string, _to: string, _tokenId: string) : UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet addressY
noncenumberWallet nonceY
paymasterAddressstringPaymaster addressY
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)Y
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)Y
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)Y
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())Y
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)Y
_tokenstringERC20 token address to operate onY
_fromstringThe _from parameter for 'transferFrom'Y
_tostringThe _to parameter for 'transferFrom'Y
_tokenIdstringThe _tokenId parameter for 'transferFrom'Y

Return Parameter:

UserOperation

  1. transfer Create UserOperation for calling the 'transfer' function of ERC721
transfer(walletAddress: string, nonce: NumberLike, paymasterAddress: string,         maxFeePerGas: NumberLike, maxPriorityFeePerGas: NumberLike, callGasLimit: NumberLike,         verificationGasLimit: NumberLike, preVerificationGas: NumberLike, _token: string, _to: string, _tokenId: string) : UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet addressY
noncenumberWallet nonceY
paymasterAddressstringPaymaster addressY
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)Y
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)Y
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)Y
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())Y
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)Y
_tokenstringERC20 token address to operate onY
_tostringThe _to parameter for 'transfer'Y
_tokenIdstringThe _tokenId parameter for 'transfer'Y

Return Parameter:

UserOperation

  1. safeTransferFrom Create UserOperation for calling the 'safeTransferFrom' function of ERC721
safeTransferFrom(walletAddress: string, nonce: NumberLike, paymasterAddress: string,                 maxFeePerGas: NumberLike, maxPriorityFeePerGas: NumberLike, callGasLimit: NumberLike,                 verificationGasLimit: NumberLike, preVerificationGas: NumberLike, _token: string, _from: string, _to: string, _tokenId: string) : UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet addressY
noncenumberWallet nonceY
paymasterAddressstringPaymaster addressY
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)Y
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)Y
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)Y
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())Y
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)Y
_tokenstringERC20 token address to operate onY
_fromstringThe _from parameter for 'safeTransferFrom'Y
_tostringThe _to parameter for 'safeTransferFrom'Y
_tokenIdstringThe _tokenId parameter for 'safeTransferFrom'Y

Return Parameter:

UserOperation

  1. setApprovalForAll Create UserOperation for calling the 'setApprovalForAll' function of ERC721
setApprovalForAll(walletAddress: string, nonce: NumberLike, paymasterAddress: string,                  maxFeePerGas: NumberLike, maxPriorityFeePerGas: NumberLike, callGasLimit: NumberLike,                  verificationGasLimit: NumberLike, preVerificationGas: NumberLike, _token: string, _operator: string, _approved: boolean) : UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet addressY
noncenumberWallet nonceY
paymasterAddressstringPaymaster addressY
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)Y
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)Y
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)Y
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())Y
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)Y
_tokenstringERC20 token address to operate onY
_operatorstringThe _operator parameter for 'setApprovalForAll'Y
_approvedbooleanThe _approved parameter for 'setApprovalForAll'Y

Return Parameter:

UserOperation

12. ERC1155 External Functions#

  1. Constructor
new ERC1155();

Input Parameter:

None

Return Parameter:

ERC1155

  1. safeTransferFrom Create UserOperation for calling the 'safeTransferFrom' function of ERC1155
safeTransferFrom(walletAddress: string, nonce: NumberLike, paymasterAddress: string,                 maxFeePerGas: NumberLike, maxPriorityFeePerGas: NumberLike, callGasLimit: NumberLike,                 verificationGasLimit: NumberLike, preVerificationGas: NumberLike, _token: string, _from: string, _to: string, _id: string, _value: string, _data: string)  : UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet addressY
noncenumberWallet nonceY
paymasterAddressstringPaymaster addressY
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)Y
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)Y
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)Y
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())Y
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)Y
_tokenstringERC20 token address to operate onY
_fromstringThe _from parameter for 'safeTransferFrom'Y
_tostringThe _to parameter for 'safeTransferFrom'Y
_idstringThe _id parameter for 'safeTransferFrom'Y
_valuestringThe _value parameter for 'safeTransferFrom'Y
_datastringThe _data parameter for 'safeTransferFrom'Y

Return Parameter:

UserOperation

  1. safeBatchTransferFrom Create UserOperation for calling the 'safeBatchTransferFrom' function of ERC1155
safeBatchTransferFrom(walletAddress: string, nonce: NumberLike, paymasterAddress: string,                      maxFeePerGas: NumberLike, maxPriorityFeePerGas: NumberLike, callGasLimit: NumberLike,                      verificationGasLimit: NumberLike, preVerificationGas: NumberLike, _token: string, _from: string, _to: string, _ids: string, _values: string, _data: string) : UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet addressY
noncenumberWallet nonceY
paymasterAddressstringPaymaster addressY
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)Y
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)Y
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)Y
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())Y
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)Y
_tokenstringERC20 token address to operate onY
_fromstringThe _from parameter for 'safeBatchTransferFrom'Y
_tostringThe _to parameter for 'safeBatchTransferFrom'Y
_idsstringThe _ids parameter for 'safeBatchTransferFrom'Y
_valuesstringThe _values parameter for 'safeBatchTransferFrom'Y
_datastringThe _data parameter for 'safeBatchTransferFrom'Y

Return Parameter:

UserOperation

  1. setApprovalForAll Create UserOperation for calling the 'setApprovalForAll' function of ERC1155
setApprovalForAll(walletAddress: string, nonce: NumberLike, paymasterAddress: string,                  maxFeePerGas: NumberLike, maxPriorityFeePerGas: NumberLike, callGasLimit: NumberLike,                  verificationGasLimit: NumberLike, preVerificationGas: NumberLike, _token: string, _operator: string, _approved: boolean) : UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet addressY
noncenumberWallet nonceY
paymasterAddressstringPaymaster addressY
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)Y
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)Y
callGasLimitnumberGas allocated for the main execution call (calculated locally, the gas for executing callData)Y
verificationGasLimitnumberGas allocated for the verification step (gas used in functions validateUserOp()/validatePaymasterUserOp())Y
preVerificationGasnumberGas paid to the bundler for compensation pre-verification execution and call data (additional gas prepared to deal with some common gas consumption, such as loops, etc.)Y
_tokenstringERC20 token address to operate onY
_operatorstringThe _operator parameter for 'setApprovalForAll'Y
_approvedstringThe _approved parameter for 'setApprovalForAll'Y

Return Parameter:

UserOperation

13. LAT External Functions#

  1. Constructor
new LAT();

Input Parameter:

None

Return Parameter:

LAT

  1. transfer Create UserOperation for calling the 'transfer' function of LAT
transfer(walletAddress: string,        nonce: NumberLike, paymasterAddress: string,        maxFeePerGas: NumberLike, maxPriorityFeePerGas: NumberLike, to: string, value: string) : UserOperation

Input Parameter:

Field NameTypeDescriptionRequired
walletAddressstringWallet addressY
noncenumberWallet nonceY
paymasterAddressstringPaymaster addressY
maxFeePerGasnumberMaximum fee per unit of gas, i.e., gas price (similar to EIP-1559 max_fee_per_gas)Y
maxPriorityFeePerGasnumberMaximum priority fee per unit of gas, i.e., the fee allocated to miners in EIP-1559 (similar to EIP-1559 max_priority_fee_per_gas)Y
tostringRecipient's LAT account addressY
valuestringAmount of LAT to transferY

Return Parameter:

UserOperation