Safe Account V2
Safe Account V2 uses the original Safe Singleton and adds ERC-4337 functionality using a module/fallback handler.
The V2 contracts, known as the SafeAccountV0_2_0 class in AbstractionKit, support EntryPoint v0.6.
Import
import { SafeAccountV0_2_0 as SafeAccount } from "abstractionkit";
How to Use
Initialize a new Safe Account and calculate its address:
const ownerPublicAddress = "0xBdbc5FBC9cA8C3F514D073eC3de840Ac84FC6D31"; // Safe owner pub address
const smartAccount = SafeAccount.initializeNewAccount([ownerPublicAddress]);
const accountAddress = smartAccount.accountAddress;
Methods at a Glance
| Method | Signature | Returns |
|---|---|---|
| constructor | new SafeAccountV0_2_0(accountAddress: string, overrides?: { safe4337ModuleAddress?; entrypointAddress?; onChainIdentifierParams?; onChainIdentifier?; safeAccountSingleton? }) | SafeAccountV0_2_0 |
| initializeNewAccount (static) | initializeNewAccount(owners: Signer[], overrides?: InitCodeOverrides) | SafeAccountV0_2_0 |
| createUserOperation | createUserOperation(transactions: MetaTransaction[], providerRpc?: string | Transport | JsonRpcNode, bundlerRpc?: string | Transport | Bundler, overrides?: CreateUserOperationV6Overrides) | Promise<UserOperationV6> |
| signUserOperation | signUserOperation(useroperation: UserOperationV6, privateKeys: string[], chainId: bigint, options?: SafeSignatureOptions) | string |
| createInitCode (static) | createInitCode(owners: Signer[], overrides?: InitCodeOverrides) | string |
| createAccountAddressAndInitCode (static) | createAccountAddressAndInitCode(owners: Signer[], overrides?: InitCodeOverrides) | [string, string] |
| estimateUserOperationGas | estimateUserOperationGas(userOperation: UserOperationV6, bundlerRpc: string | Transport | Bundler, overrides?) | Promise<[bigint, bigint, bigint]> |
| createMigrateToSafeAccountV0_3_0MetaTransactions | createMigrateToSafeAccountV0_3_0MetaTransactions(nodeRpcUrl: string | Transport | JsonRpcNode, overrides?: { safeV06ModuleAddress?; safeV07ModuleAddress?; prevModuleAddress?; pageSize?; modulesStart?; skipPreflight? }) | Promise<MetaTransaction[]> |
SafeAccountV0_2_0 also inherits the shared Safe methods, documented once for every Safe class: sending, external-signer signing, calldata encoding and EIP-712 helpers on Safe Account Transactions and Signing, and address, owner, module and account-state methods on Safe Account Setup, Owners and Modules.
Constructor
Creates a SafeAccountV0_2_0 instance for an existing deployed Safe account. For new (undeployed) accounts, use the static initializeNewAccount method instead.
Usage
import { SafeAccountV0_2_0 as SafeAccount } from "abstractionkit";
const accountAddress = "0x1a02592A3484c2077d2E5D24482497F85e1980C6";
const smartAccount = new SafeAccount(accountAddress);
- Param Types
- Return Type
| key | type | description |
|---|---|---|
accountAddress | string | The on-chain address of the deployed Safe account. |
overrides? | object | Optional overrides for module and EntryPoint addresses. |
overrides?.safe4337ModuleAddress? | string | Override the default Safe 4337 module address. |
overrides?.entrypointAddress? | string | Override the default EntryPoint address. |
overrides?.onChainIdentifierParams? | OnChainIdentifierParamsType | Parameters for on-chain identifier tracking. |
overrides?.onChainIdentifier? | string | Pre-computed on-chain identifier string. |
| key | type | description |
|---|---|---|
SafeAccountV0_2_0 | SafeAccountV0_2_0 | An instance of the SafeAccountV0_2_0 class connected to the existing account. |
Source code
Methods
The Essentials methods provide all necessary functionalities with support for overrides, offering a streamlined approach.
initializeNewAccount
Initializes a new SafeAccount class given a list of owners' public addresses. Only needs to be called on the first transaction when the account has not been deployed yet.
Usage
In this example, we initiate a single owner account.
- example.ts
- Param Types
- Return Type
import { SafeAccountV0_2_0 as SafeAccount } from "abstractionkit";
const ownerPublicAddress = "0xBdbc5FBC9cA8C3F514D073eC3de840Ac84FC6D31";
const smartAccount = SafeAccount.initializeNewAccount([ownerPublicAddress]);
console.log("Account address (sender): " + smartAccount.accountAddress);
| key | type | description |
|---|---|---|
owners[] | object | Pass the owner(s) address(es) of the account. It can be a single owner account, a multi-sig, or a WebAuthn |
owners[].Signer | ECDSAPublicAddress | WebauthnPublicKey | Signer type which can be either an ECDSA public address or a Webauthn public key |
initCodeOverrides? | object | Override values to change the initialization default values |
initCodeOverrides?.threshold? | number | Signature threshold, defines how many signatures are required. Default is 1. |
initCodeOverrides?.c2Nonce? | bigint | Create2 nonce used to generate different sender addresses from the same owners. Default is 0. |
initCodeOverrides?.entrypointAddress? | string | Address of the entry point for transactions or contracts. |
initCodeOverrides?.safe4337ModuleAddress? | string | Address of the Safe 4337 module. |
initCodeOverrides?.safeModuleSetupAddress? | string | Address used for setting up the Safe module. |
initCodeOverrides?.safeAccountSingleton? | SafeAccountSingleton | Safe singleton address and init hash. Default is Safe L2 v1.4.1 ("0x29fcB43b46531BcA003ddC8FCB67FFE91900C762"), or Safe L2 v1.5.0 ("0xEdd160fEBBD92E350D4D398fb636302fccd67C7e") for SafeMultiChainSigAccountV2. Pass the exported Safe_L2_V1_4_1 or Safe_L2_V1_5_0 to pick one explicitly. |
initCodeOverrides?.safeAccountFactoryAddress? | string | Address of the Safe Factory. Default is "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67". |
initCodeOverrides?.multisendContractAddress? | string | Address of the Safe MultiSend contract. Default is "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526". |
initCodeOverrides?.webAuthnSharedSigner? | string | Shared signer used for WebAuthn-based authentication. |
initCodeOverrides?.eip7212WebAuthnPrecompileVerifierForSharedSigner? | string | Verifier contract for WebAuthn precompile, related to the shared signer. |
initCodeOverrides?.eip7212WebAuthnContractVerifierForSharedSigner? | string | Contract verifier for WebAuthn-based shared signer, compliant with EIP-7212. |
initCodeOverrides?.onChainIdentifierParams? | OnChainIdentifierParamsType | Parameters for on-chain identifier tracking. |
initCodeOverrides?.onChainIdentifier? | string | Pre-computed on-chain identifier string. |
| key | type | description |
|---|---|---|
ECDSAPublicAddress | string | Public address of an ECDSA (EOA) owner |
WebauthnPublicKey
| key | type | description |
|---|---|---|
x | bigint | The x coordinate of the webAuthn public key |
y | bigint | The y coordinate of the webAuthn public key |
| key | type | description |
|---|---|---|
SafeAccount class | SafeAccountV0_2_0 | An instance of the Safe V2 Account and the initialization parameters |
Example Response
Account address (sender): 0xb8741a449D50ed0Dcfe395287F85BE152884c8d9
Source code
createUserOperation
This method determines the nonce, fetches the gas prices, estimates gas limits, and returns a UserOperation to be signed. You can override any of these values using the overrides parameter.
Usage
This example mints the same NFT twice in a single UserOperation.
- example.ts
- Param Types
- Return Type
import { MetaTransaction } from "abstractionkit";
const jsonRpcNodeProvider = "https://ethereum-sepolia-rpc.publicnode.com";
const bundlerUrl = "https://api.candide.dev/public/v3/11155111";
const transaction: MetaTransaction = {
to: "0xD9de104e3386d9A45a61BcE269c43E48B534e4E7", // NFT contract address
value: 0n,
data: "0x1249c58b", // mint()
}
let userOperation = await smartAccount.createUserOperation(
[transaction, transaction], // batch transactions to mint 2 NFTs
jsonRpcNodeProvider,
bundlerUrl,
)
console.log(userOperation);
| Param Name | Param Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Transactions | MetaTransaction[]
| MetaTransaction is the type of a transaction to construct a Safe operation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Provider RPC | string | Transport | JsonRpcNode | The node URL. It is used to fetch the current nonce and fetch gas prices | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bundler URL | string | Transport | Bundler | The Bundler URL. It is used to fetch the gas limits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Overrides | CreateUserOperationOverrides, optional object
| CreateUserOperationOverrides allows you to override any of the default parameters for the user operation |
| Param Name | Param Type | Description | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| UserOperation | Promise<UserOperationV6> UserOperation object
| Resolves to the UserOperation to be signed. A node or bundler RPC failure throws an AbstractionKitError. |
Example Response
{
sender: '0x1e4Cd9D1DBf1D4DF6A79E1D11f5ff45Cc7F0458b',
nonce: 0n,
callData: '0x541d63c800000000000000000000000038869bf66a61cf6bdb996a6ae40d5853fd43b526...',
callGasLimit: 429347n,
verificationGasLimit: 1502311n,
preVerificationGas: 149456n,
maxFeePerGas: 81n,
maxPriorityFeePerGas: 60n,
signature: '0xffffffffffffffffffffffff47003599ffa7e9198f321afa774e34a12a959844efd6363b...',
initCode: '0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec671688f0b9000000000000000000000000...',
paymasterAndData: '0x'
}
Source code
signUserOperation
This method takes a userOperation, the private keys of the owner of the account, and the chainId and returns the signature field.
- example.ts
- Param Types
- Return Type
const chainId = BigInt("11155111"); // sepolia chain ID
const privateKey = "0x4cad764980d84fc6684ca839cae2c78be5432e292fa98416e11687ceb9096a03";
const userOperation = {..}
const signature = smartAccount.signUserOperation(
userOperation,
[privateKey],
chainId,
);
console.log(signature);
| key | type | description |
|---|---|---|
userOperation | UserOperationV6 | userOperation to sign |
privateKeys | string[] | private keys of owners/signers |
chainId | bigint | target chain id |
options? | object | SafeSignatureOptions: per-call signing options |
options?.validAfter? | bigint | Timestamp the signature will be valid after |
options?.validUntil? | bigint | Timestamp the signature will be valid until |
options?.safe4337ModuleAddress? | string | Override the Safe 4337 module address used when constructing the signature. Defaults to the module of the account instance. |
UserOperationV6
| key | type | description |
|---|---|---|
sender | string | The account making the operation |
nonce | bigint | Anti-replay parameter (see “Semi-abstracted Nonce Support” ) |
initCode | string | The initCode of the account (needed if and only if the account is not yet on-chain and needs to be created) |
callData | string | The data to pass to the sender during the main execution call |
callGasLimit | bigint | The amount of gas to allocate the main execution call |
verificationGasLimit | bigint | The amount of gas to allocate for the verification step |
preVerificationGas | bigint | The amount of gas to pay for to compensate the bundler for pre-verification execution and calldata |
maxFeePerGas | bigint | Maximum fee per gas (similar to EIP-1559 max_fee_per_gas) |
maxPriorityFeePerGas | bigint | Maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas) |
paymasterAndData | string | Address of paymaster sponsoring the transaction, followed by extra data to send to the paymaster (empty for self-sponsored transaction). Revolves to '0x' if not using a paymaster, and a paymasterDummyData when estimating gas |
signature | string | The signature for the userOperation. It is the data passed into the account along with the nonce during the verification step. Resolves to '0x' when the user did not provide their signature yet |
| key | type | description |
|---|---|---|
Signature field | string | UserOperation Signature with the data passed into the account along with the nonce during the verification step |
Example Response
0x00000000000000000000000041c6297bd9573e8d979a272db4f6576a98f639a7e6874055a627769401dc46d01143551ccaa473364ace4340ec395c546dccb725e1eac2639ecef443d229f0071b
Source code
Advanced Methods
The Advanced methods offer fine control and customization, catering to developers who require detailed configurations for their specific requirements.
createInitCode
Calculates the initCode needed to deploy the account on-chain.
Usage
In this example, we initiate a single owner account.
- example.ts
- Param Types
- Return Type
import { SafeAccountV0_2_0 as SafeAccount } from "abstractionkit";
const owner1PublicAddress = "0xBdbc5FBC9cA8C3F514D073eC3de840Ac84FC6D31";
const owner2PublicAddress = "0x4991A5360e5da9BAF62fF644d89F46268e5159eA";
const initCode = SafeAccount.createInitCode(
[owner1PublicAddress, owner2PublicAddress],
{ threshold: 2 },
);
console.log("initCode: ", initCode);
| key | type | description |
|---|---|---|
owners[] | object | Pass the owner(s) address(es) of the account. It can be a single owner account, a multi-sig, or a WebAuthn |
owners[].Signer | ECDSAPublicAddress | WebauthnPublicKey | Signer type which can be either an ECDSA public address or a Webauthn public key |
initCodeOverrides? | object | Override values to change the initialization default values |
initCodeOverrides?.threshold? | number | Signature threshold, defines how many signatures are required. Default is 1. |
initCodeOverrides?.c2Nonce? | bigint | Create2 nonce used to generate different sender addresses from the same owners. Default is 0. |
initCodeOverrides?.entrypointAddress? | string | Address of the entry point for transactions or contracts. |
initCodeOverrides?.safe4337ModuleAddress? | string | Address of the Safe 4337 module. |
initCodeOverrides?.safeModuleSetupAddress? | string | Address used for setting up the Safe module. |
initCodeOverrides?.safeAccountSingleton? | SafeAccountSingleton | Safe singleton address and init hash. Default is Safe L2 v1.4.1 ("0x29fcB43b46531BcA003ddC8FCB67FFE91900C762"), or Safe L2 v1.5.0 ("0xEdd160fEBBD92E350D4D398fb636302fccd67C7e") for SafeMultiChainSigAccountV2. Pass the exported Safe_L2_V1_4_1 or Safe_L2_V1_5_0 to pick one explicitly. |
initCodeOverrides?.safeAccountFactoryAddress? | string | Address of the Safe Factory. Default is "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67". |
initCodeOverrides?.multisendContractAddress? | string | Address of the Safe MultiSend contract. Default is "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526". |
initCodeOverrides?.webAuthnSharedSigner? | string | Shared signer used for WebAuthn-based authentication. |
initCodeOverrides?.eip7212WebAuthnPrecompileVerifierForSharedSigner? | string | Verifier contract for WebAuthn precompile, related to the shared signer. |
initCodeOverrides?.eip7212WebAuthnContractVerifierForSharedSigner? | string | Contract verifier for WebAuthn-based shared signer, compliant with EIP-7212. |
initCodeOverrides?.onChainIdentifierParams? | OnChainIdentifierParamsType | Parameters for on-chain identifier tracking. |
initCodeOverrides?.onChainIdentifier? | string | Pre-computed on-chain identifier string. |
| key | type | description |
|---|---|---|
ECDSAPublicAddress | string | Public address of an ECDSA (EOA) owner |
WebauthnPublicKey
| key | type | description |
|---|---|---|
x | bigint | The x coordinate of the webAuthn public key |
y | bigint | The y coordinate of the webAuthn public key |
| key | type | description |
|---|---|---|
initCode | string | The initCode of the account, only needed if the account is not yet on-chain and needs to be created |
Example Response
initCode: 0x...
Source code
createAccountAddressAndInitCode
Calculates the Safe address and the initCode needed to deploy the account on-chain.
Usage
In this example, we initiate a single owner account.
- example.ts
- Param Types
- Return Type
import { SafeAccountV0_2_0 as SafeAccount } from "abstractionkit";
const ownerPublicAddress = "0xBdbc5FBC9cA8C3F514D073eC3de840Ac84FC6D31";
let [accountAddress, initCode] = SafeAccount.createAccountAddressAndInitCode(
[ownerPublicAddress],
);
console.log("Account address (sender): " + accountAddress);
console.log("initCode: ", initCode);
| key | type | description |
|---|---|---|
owners[] | object | Pass the owner(s) address(es) of the account. It can be a single owner account, a multi-sig, or a WebAuthn |
owners[].Signer | ECDSAPublicAddress | WebauthnPublicKey | Signer type which can be either an ECDSA public address or a Webauthn public key |
initCodeOverrides? | object | Override values to change the initialization default values |
initCodeOverrides?.threshold? | number | Signature threshold, defines how many signatures are required. Default is 1. |
initCodeOverrides?.c2Nonce? | bigint | Create2 nonce used to generate different sender addresses from the same owners. Default is 0. |
initCodeOverrides?.entrypointAddress? | string | Address of the entry point for transactions or contracts. |
initCodeOverrides?.safe4337ModuleAddress? | string | Address of the Safe 4337 module. |
initCodeOverrides?.safeModuleSetupAddress? | string | Address used for setting up the Safe module. |
initCodeOverrides?.safeAccountSingleton? | SafeAccountSingleton | Safe singleton address and init hash. Default is Safe L2 v1.4.1 ("0x29fcB43b46531BcA003ddC8FCB67FFE91900C762"), or Safe L2 v1.5.0 ("0xEdd160fEBBD92E350D4D398fb636302fccd67C7e") for SafeMultiChainSigAccountV2. Pass the exported Safe_L2_V1_4_1 or Safe_L2_V1_5_0 to pick one explicitly. |
initCodeOverrides?.safeAccountFactoryAddress? | string | Address of the Safe Factory. Default is "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67". |
initCodeOverrides?.multisendContractAddress? | string | Address of the Safe MultiSend contract. Default is "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526". |
initCodeOverrides?.webAuthnSharedSigner? | string | Shared signer used for WebAuthn-based authentication. |
initCodeOverrides?.eip7212WebAuthnPrecompileVerifierForSharedSigner? | string | Verifier contract for WebAuthn precompile, related to the shared signer. |
initCodeOverrides?.eip7212WebAuthnContractVerifierForSharedSigner? | string | Contract verifier for WebAuthn-based shared signer, compliant with EIP-7212. |
initCodeOverrides?.onChainIdentifierParams? | OnChainIdentifierParamsType | Parameters for on-chain identifier tracking. |
initCodeOverrides?.onChainIdentifier? | string | Pre-computed on-chain identifier string. |
| key | type | description |
|---|---|---|
ECDSAPublicAddress | string | Public address of an ECDSA (EOA) owner |
WebauthnPublicKey
| key | type | description |
|---|---|---|
x | bigint | The x coordinate of the webAuthn public key |
y | bigint | The y coordinate of the webAuthn public key |
| key | type | description |
|---|---|---|
account address | string | The Safe Account Address |
initcode | string | The initCode field in the userOperation |
Example Response
Account address (sender): 0xb8741a449D50ed0Dcfe395287F85BE152884c8d9
initCode: 0x...
Source code
createAccountAddressAndInitCode
estimateUserOperationGas
Estimates gas limits for a UserOperation.
Usage
- example.ts
- Param Types
- Response Type
import {
SafeAccountV0_2_0 as SafeAccount,
UserOperationV6
} from "abstractionkit";
const bundlerRPC = "https://api.candide.dev/public/v3/11155111";
const ownerPublicAddress = "0xBdbc5FBC9cA8C3F514D073eC3de840Ac84FC6D31";
const smartAccount = SafeAccount.initializeNewAccount([ownerPublicAddress])
// Use createUserOperation() to help you construct the userOp below
let userOperation: UserOperationV6 = await smartAccount.createUserOperation(..);
const [preVerificationGas, verificationGasLimit, callGasLimit] = await smartAccount.estimateUserOperationGas(userOperation, bundlerRPC);
| key | type | description |
|---|---|---|
userOperation | UserOperationV6 | userOperation to send |
bundlerRpc | string | Transport | Bundler | bundler rpc to send userOperation |
overrides? | object | overrides for the default values |
overrides?.stateOverrideSet? | object | Pass state overrides for gas estimation |
overrides?.stateOverrideSet?.[address: string] | object | Overrides for a specific address |
overrides?.stateOverrideSet?.[address: string].balance? | bigint | Override the balance of the address |
overrides?.stateOverrideSet?.[address: string].nonce? | bigint | Override the nonce of the address |
overrides?.stateOverrideSet?.[address: string].code? | string | Override the code of the address |
overrides?.stateOverrideSet?.[address: string].state? | Dictionary<string> | Override the storage slots of the address |
overrides?.stateOverrideSet?.[address: string].stateDiff? | Dictionary<string> | Apply state differences to the storage slots of the address |
overrides?.dummySignerSignaturePairs? | object | Provide dummy signatures for the operation |
overrides?.dummySignerSignaturePairs?.SignerSignaturePair[] | object | Signature Pair |
overrides?.dummySignerSignaturePairs?.SignerSignaturePair[].signer | ECDSAPublicAddress | WebauthnPublicKey | Signer type which can be either an ECDSA public address or a Webauthn public key |
overrides?.dummySignerSignaturePairs?.SignerSignaturePair[].signature | string | signature |
overrides?.dummySignerSignaturePairs?.SignerSignaturePair[].isContractSignature? | boolean | Whether this is a contract signature (EIP-1271) |
overrides?.expectedSigners? | object | The expected signers that will sign over the transaction. This improves the gas estimates. |
overrides?.expectedSigners?.Signer | ECDSAPublicAddress | WebauthnPublicKey | Signer type which can be either an ECDSA public address or a Webauthn public key |
overrides?.webAuthnSharedSigner? | string | Specify the WebAuthn shared signer |
overrides?.webAuthnSignerFactory? | string | Specify the WebAuthn signer factory |
overrides?.webAuthnSignerSingleton? | string | Specify the WebAuthn signer singleton |
overrides?.webAuthnSignerProxyCreationCode? | string | Specify the WebAuthn signer proxy creation code |
overrides?.eip7212WebAuthnPrecompileVerifier? | string | Specify the EIP-7212 WebAuthn precompile verifier |
overrides?.eip7212WebAuthnContractVerifier? | string | Specify the EIP-7212 WebAuthn contract verifier |
UserOperationV6
| key | type | description |
|---|---|---|
sender | string | The account making the operation |
nonce | bigint | Anti-replay parameter (see “Semi-abstracted Nonce Support” ) |
initCode | string | The initCode of the account (needed if and only if the account is not yet on-chain and needs to be created) |
callData | string | The data to pass to the sender during the main execution call |
callGasLimit | bigint | The amount of gas to allocate the main execution call |
verificationGasLimit | bigint | The amount of gas to allocate for the verification step |
preVerificationGas | bigint | The amount of gas to pay for to compensate the bundler for pre-verification execution and calldata |
maxFeePerGas | bigint | Maximum fee per gas (similar to EIP-1559 max_fee_per_gas) |
maxPriorityFeePerGas | bigint | Maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas) |
paymasterAndData | string | Address of paymaster sponsoring the transaction, followed by extra data to send to the paymaster (empty for self-sponsored transaction). Revolves to '0x' if not using a paymaster, and a paymasterDummyData when estimating gas |
signature | string | The signature for the userOperation. It is the data passed into the account along with the nonce during the verification step. Resolves to '0x' when the user did not provide their signature yet |
| key | type | description |
|---|---|---|
ECDSAPublicAddress | string | Public address of an ECDSA (EOA) owner |
WebauthnPublicKey
| key | type | description |
|---|---|---|
x | bigint | The x coordinate of the webAuthn public key |
y | bigint | The y coordinate of the webAuthn public key |
| Parameter | Type | Description |
|---|---|---|
| gas estimates | Promise<[bigint, bigint, bigint]> | Returns the gas estimates of preVerificationGas, verificationGasLimit, callGasLimit |
Example Response
[ 149456n, 1502311n, 429347n ]
Source code
createMigrateToSafeAccountV0_3_0MetaTransactions
Creates an array of meta-transactions to migrate a Safe account from EntryPoint v0.6 (module v0.2.0) to EntryPoint v0.7 (module v0.3.0). The migration disables the v0.6 module, enables the v0.7 module, and updates the fallback handler.
Usage
import { SafeAccountV0_2_0 as SafeAccount } from "abstractionkit";
const nodeRpcUrl = "https://ethereum-sepolia-rpc.publicnode.com";
const smartAccount = new SafeAccount(accountAddress);
const migrationMetaTransactions =
await smartAccount.createMigrateToSafeAccountV0_3_0MetaTransactions(nodeRpcUrl);
// Include these meta-transactions in a UserOperation to execute the migration
const userOperation = await smartAccount.createUserOperation(
migrationMetaTransactions,
nodeRpcUrl,
bundlerUrl,
);
- Param Types
- Return Types
| key | type | description |
|---|---|---|
nodeRpcUrl | string | Transport | JsonRpcNode | The JSON-RPC API URL for the target chain. |
overrides? | object | Optional overrides for contract addresses, pagination, and the preflight check. |
overrides?.safeV06ModuleAddress? | string | Override the Safe v0.6 module address to disable. |
overrides?.safeV07ModuleAddress? | string | Override the Safe v0.7 module address to enable. |
overrides?.prevModuleAddress? | string | Override the linked-list predecessor of the module being disabled. Defaults to an on-chain lookup. |
overrides?.pageSize? | bigint | Page size for the module pagination query. |
overrides?.modulesStart? | string | Starting address for the module pagination query. |
overrides?.skipPreflight? | boolean | Skip the on-chain check that verifies the account is a Safe (>= 1.4.1) running the old module before building the batch. Defaults to false. |
| key | type | description |
|---|---|---|
MetaTransaction[] | object | Array of meta-transactions that disable the v0.6 module, enable the v0.7 module, and update the fallback handler. |
MetaTransaction[].to | string | The target address for the meta-transaction. |
MetaTransaction[].data | string | The encoded function call data. |
MetaTransaction[].value | bigint | The value to send with the meta-transaction (0n for these operations). |
Source code
createMigrateToSafeAccountV0_3_0MetaTransactions