aa-sdk/core

Enumerations

EnumerationDescription
DeploymentState-
LogLevel-
RoundingMode-

Classes

ClassDescription
AccountNotFoundErrorThis error is thrown when an account could not be found to execute a specific action. It extends the BaseError class.
AccountRequiresOwnerErrorRepresents an error that occurs when an account requires an owner to execute but none is provided.
BaseErrorA custom error class that extends from ViemBaseError. This class allows for error messages to include links to relevant documentation based on provided docsPath and docsSlug parameters. This is based on on viem’s BaseError type (obviously from the import and extend) we want the errors here to point to our docs if we supply a docsPath though
BatchExecutionNotSupportedErrorRepresents an error indicating that batch execution is not supported for a specific account type.
ChainNotFoundErrorError class representing a “Chain Not Found” error, typically thrown when no chain is supplied to the client.
DefaultFactoryNotDefinedErrorRepresents an error that is thrown when no default factory is defined for a specific account type on a given chain and entry point version. This error suggests providing an override via the factoryAddress parameter when creating an account.
EntityIdOverrideErrorError class denoting that the provided entity id is invalid because it’s overriding the native entity id.
EntryPointNotFoundErrorRepresents an error thrown when an entry point is not found for a specific chain and entry point version. This error indicates that a default entry point does not exist for the given chain and version, and suggests providing an override.
FailedToFindTransactionErrorRepresents an error that occurs when a transaction cannot be found for a given user operation. This error extends from BaseError. The hash of the transaction is provided to indicate which transaction could not be found.
FailedToGetStorageSlotErrorCustom error class FailedToGetStorageSlotError which is used to signal a failure when attempting to retrieve a storage slot. This error includes the slot and slot descriptor in its message and inherits from BaseError.
GetCounterFactualAddressErrorCustom error class for handling errors when getting a counterfactual address. This extends the BaseError class and provides a custom error message and name.
IncompatibleClientErrorRepresents an error thrown when a client is not compatible with the expected client type for a specific method. The error message provides guidance on how to create a compatible client.
IncorrectAccountTypeRepresents an error thrown when an account type does not match the expected type.
InvalidDeferredActionNonceError class denoting that the deferred action nonce used is invalid.
InvalidEntityIdErrorError class denoting that the provided entity id is invalid because it’s too large.
InvalidEntryPointErrorRepresents an error thrown when an invalid entry point version is encountered for a specific chain. This error extends the BaseError class.
InvalidModularAccountV2ModeError class denoting that the provided ma v2 account mode is invalid.
InvalidNonceKeyErrorError class denoting that the nonce key is invalid because its too large.
InvalidRpcUrlErrorRepresents an error that occurs when an invalid RPC URL is provided. This class extends the BaseError class and includes the invalid URL in the error message.
InvalidSignerTypeErrorRepresents an error thrown when an invalid signer type is provided to the SmartAccountSigner.
InvalidUserOperationErrorThrown when a UserOperationStruct is not a valid request
LocalAccountSignerRepresents a local account signer and provides methods to sign messages and transactions, as well as static methods to create the signer from mnemonic or private key.
LoggerLogger class provides static methods for logging at different levels such as error, warn, debug, info, and verbose. This class allows setting log levels and log filters to control the logging behavior.
NotAModularAccountV2ErrorThis error is thrown when an account is not a Modular Account V2
SignTransactionNotSupportedErrorError thrown when attempting to sign a transaction that is not supported by smart contracts.
SmartAccountWithSignerRequiredErrorError class indicating that a smart account operation requires a signer.
TraceHeaderSome tools that are useful when dealing with the values of the trace header. Follows the W3C trace context standard.
TransactionMissingToParamErrorError thrown when a transaction is missing the to address parameter. This class extends the BaseError class.
UpgradesNotSupportedErrorAn error class representing the condition where upgrades are not supported for a specific account type. This error extends the BaseError class and provides a custom error message based on the account type.
UpgradeToAndCallNotSupportedErrorRepresents an error that occurs when an attempt is made to call UpgradeToAndCall on an account type that does not support it. Includes the account type in the error message.
WaitForUserOperationErrorError thrown when waiting for user operation request to be mined.
WalletClientSignerRepresents a wallet client signer for smart accounts, providing methods to get the address, sign messages, sign typed data, and sign 7702 authorizations.

Interfaces

Type Aliases

Type AliasDescription
AbiContract ABI Specification
AccountOp-
Address-
AuthorizationRequest-
BaseSmartAccountClient-
BaseSmartAccountClientActions-
BatchUserOperationCallData-
BigNumberish-
BigNumberishRange-
BuildTransactionParameters-
BuildUserOperationFromTransactionsResult-
BuildUserOperationParameters-
BundlerActions-
BundlerClient-
BundlerRpcSchema-
BytesLike-
ClientMiddleware-
ClientMiddlewareArgs-
ClientMiddlewareConfig-
ClientMiddlewareFn-
ConnectionConfig-
ConnectorData-
DefaultEntryPointVersion-
Deferrable-
DropAndReplaceUserOperationParameters-
Eip7702ExtendedFields-
EmptyHex-
EntryPointDef-
EntryPointParameter-
EntryPointVersion-
EQ-
EqualsOneOfTheComponents-
Erc7677Client-
Erc7677MiddlewareParams-
Erc7677RpcSchema-
GetAccountAddressParams-
GetAccountParameter-
GetContextParameter-
GetEntryPointFromAccount-
GetEntryPointOptions-
HttpTransport-
IsMemberOrSubtypeOfAComponent-
IsOneOf-
IsUndefined-
MiddlewareClientMiddleware client type
Multiplier-
Never-
NotTypeUsed to ensure type doesn’t extend another, for use in & chaining of properties
NoUndefined-
NullAddress-
OneOf-
OptionalFields-
Prettify-
PromiseOrValue-
RecordableKeys-
RequiredBy-
SendTransactionsParameters-
SendUserOperationParameters-
SendUserOperationResult-
SignatureRequest-
SigningMethods-
SignUserOperationParameters-
SmartAccountClient-
SmartAccountClientActions-
SmartAccountClientConfig-
SmartAccountClientRpcSchema-
SmartContractAccount-
SmartContractAccountWithSigner-
SupportedEntryPoint-
ToSmartContractAccountParams-
UnpackedSignature-
UpgradeAccountParams-
UpgradeToAndCallParams-
UpgradeToData-
UserOperationCallData-
UserOperationContext-
UserOperationFeeOptions-
UserOperationFeeOptionsField-
UserOperationOverrides-
UserOperationOverridesParameter-
UserOperationPaymasterOverrides-
UserOperationRequest-
UserOperationStruct-
WaitForUserOperationTxParameters-
WithOptional-
WithRequired-

Variables

VariableDescription
ADD_BREADCRUMBThe symbol that is used to add a breadcrumb to the headers. Is an optional function that is used to add a breadcrumb to the headers.
BigNumberishRangeSchema-
BigNumberishSchema-
bundlerActionsA viem client decorator that provides Bundler specific actions. These actions include estimating gas for user operations, sending raw user operations, retrieving user operations by hash, getting supported entry points, and getting user operation receipts.
ChainSchema-
ConnectionConfigSchema-
createBundlerClientFromExistingCreates a bundler client from an existing public client with the provided transport and chain.
default7702GasEstimatorA middleware function to estimate the gas usage of a user operation when using an EIP-7702 delegated account. Has an optional custom gas estimator. This function is only compatible with accounts using EntryPoint v0.7.0, and the account must have an implementation address defined in getImplementationAddress().
default7702UserOpSignerProvides a default middleware function for signing user operations with a client account when using EIP-7702 delegated accounts. If the signer doesn’t support signAuthorization, then this just runs the provided signUserOperation middleware. This function is only compatible with accounts using EntryPoint v0.7.0, and the account must have an implementation address defined in getImplementationAddress().
defaultEntryPointVersion-
defaultGasEstimatorDescription default gas estimator middleware for SmartAccountClient You can override this middleware with your custom gas estimator middleware by passing it to the client constructor
defaultPaymasterAndDataMiddleware function that sets the paymasterAndData field in the given struct based on the entry point version of the account. This is the default used by createSmartAccountClient and is not necessary to be used directly.
defaultUserOpSignerProvides a default middleware function for signing user operations with a client account. This function validates the request and adds the signature to it. This is already included in the client returned from createSmartAccountClient
EntryPointAbi_v6-
EntryPointAbi_v7-
entryPointRegistry-
HexSchema-
minPriorityFeePerBidDefaults-
MultiplierSchema-
noopMiddlewareNoop middleware that does nothing and passes the arguments through
SignerSchema-
SimpleAccountAbi_v6-
SimpleAccountAbi_v7-
SimpleAccountFactoryAbi-
smartAccountClientActionsProvides a set of smart account client actions to decorate the provided client. These actions include building and signing user operations, sending transactions, and more.
smartAccountClientMethodKeys-
SmartAccountClientOptsSchema-
TRACE_HEADER_NAMEThese are the headers that are used in the trace headers, could be found in the spec
TRACE_HEADER_STATEThese are the headers that are used in the trace headers, could be found in the spec
waitForUserOperationTransactionWaits for a user operation transaction to be confirmed by checking the receipt periodically until it is found or a maximum number of retries is reached.
webauthnGasEstimatorA middleware function to estimate the gas usage of a user operation when using a Modular Account V2 WebAuthn account. Has an optional custom gas estimator. This function is only compatible with accounts using EntryPoint v0.7.0, and the account must have an implementation address defined in getImplementationAddress().

Functions

FunctionDescription
allEqualUtility method for checking if the passed in values are all equal (strictly)
applyUserOpFeeOptionUtility method for applying a UserOperationFeeOptionsField value over the current value set for the field
applyUserOpOverrideUtility method for applying a UserOperationOverrides field value over the current value set for the field
applyUserOpOverrideOrFeeOptionUtility method for applying a UserOperationOverrides field value and a UserOperationFeeOptionsField value over the current value set for the field, with the override taking precedence over the fee option
asyncPipeUtility function that allows for piping a series of async functions together
bigIntClampGiven a bigint and a min-max range, returns the min-max clamped bigint value
bigIntMaxReturns the max bigint in a list of bigints
bigIntMinReturns the min bigint in a list of bigints
bigIntMultiplyGiven a bigint and a number (which can be a float), returns the bigint value. Note: this function has loss and will round down to the nearest integer.
buildUserOperationBuilds a user operation using the provided client and operation parameters. Ensures that the account exists and the client is compatible.
buildUserOperationFromTxPerforms buildUserOperationFromTx in batch and builds into a single, yet to be signed UserOperation (UO) struct. The output user operation struct will be filled with all gas fields (and paymaster data if a paymaster is used) based on the transactions data (to, data, value, maxFeePerGas, maxPriorityFeePerGas) computed using the configured ClientMiddlewares on the SmartAccountClient
buildUserOperationFromTxsPerforms buildUserOperationFromTx in batch and builds into a single, yet to be signed UserOperation (UO) struct. The output user operation struct will be filled with all gas fields (and paymaster data if a paymaster is used) based on the transactions data (to, data, value, maxFeePerGas, maxPriorityFeePerGas) computed using the configured ClientMiddlewares on the SmartAccountClient.
bypassPaymasterAndDataUtility method for checking whether the middleware pipeline should bypass the paymaster middleware for the user operation with the given overrides, either because the UserOp is paying for its own gas, or passing a specific paymaster
bypassPaymasterAndDataEmptyHexAn alternative to bypassPaymasterAndData which only returns true if the data parameter is “0x,” this is useful for cases when middleware should be bypassed ONLY IF the UserOp will pay for its own gas
checkGasSponsorshipEligibilityThis function verifies the eligibility of the connected account for gas sponsorship concerning the upcoming UserOperation (UO) that is intended to be sent. Internally, this method invokes buildUserOperation, which navigates through the middleware pipeline, including the PaymasterMiddleware. Its purpose is to construct the UO struct meant for transmission to the bundler. Following the construction of the UO struct, this function verifies if the resulting structure contains a non-empty paymasterAndData field. You can utilize this method before sending the user operation to confirm its eligibility for gas sponsorship. Depending on the outcome, it allows you to tailor the user experience accordingly, based on eligibility.
clientHeaderTrackAdd a crumb to the breadcrumb.
concatPaymasterAndDataUtility method for converting the object containing the paymaster address and paymaster data to the paymaster and data concatenated hex string
conditionalReturnUtility method for checking the condition and return the value if condition holds true, undefined if not.
convertChainIdToCoinTypeConverts a given chain ID to a coin type, following specific standards for mainnet and non-mainnet chains.
convertCoinTypeToChainConverts a coin type to its corresponding blockchain chain based on a predefined mapping.
convertCoinTypeToChainIdConverts a coin type to a chain ID based on predefined mappings. This function follows ENSIP-9 for coin type 60 and ENSIP-11 for other coin types.
createBundlerClientCreates a Bundler Client using the provided configuration parameters, including chain and optional type.
createSmartAccountClientCreates a smart account client using the provided configuration. This client handles various Ethereum transactions and message signing operations.
createSmartAccountClientFromExistingCreates a smart account client using an existing client and specific configuration. This function can be used to reuse a pre-existing BundlerClient while customizing other aspects of the smart account.
deepHexlifyRecursively converts all values in an object to hex strings
defaultFeeEstimatorDefault fee estimator middleware function that estimates the maximum fee per gas and maximum priority fee per gas for a given client and applies the necessary overrides and fee options.
dropAndReplaceUserOperationDrops an existing user operation and replaces it with a new one while ensuring the appropriate fees and overrides are applied.
erc7677MiddlewareMiddleware function for interacting with ERC-7677 enabled clients. It supports resolving paymaster and data fields for user operations. This middleware assumes that your RPC provider supports the ERC-7677 methods (pm_getPaymasterStubData and pm_getPaymasterData).
filterUndefinedFilters out properties with undefined or null values from the provided object.
getAccountAddressRetrieves the account address. Uses a provided accountAddress if available; otherwise, it computes the address using the entry point contract and the initial code.
getDefaultUserOperationFeeOptions-
getEntryPointRetrieves the entry point definition for the specified chain and version, falling back to the default version if not provided. Throws an error if the entry point address cannot be found.
getUserOperationErrorRetrieves the error message from an entrypoint for a User Operation.
isBigNumberish-
isEntryPointVersionChecks if the given value is a valid key of the EntryPointRegistry.
isMultiplier-
isSignerChecks if the provided object is a SmartAccountSigner.
isSmartAccountClientUse this method to assert that a client is a BaseSmartAccountClient. Useful for narrowing the type of the client down when used within the smart account client decorators
isSmartAccountWithSignerDetermines if the given SmartContractAccount has a signer associated with it.
isValidFactoryAndDataUtility method for asserting a UserOperationStruct has valid fields for the paymaster data
isValidPaymasterAndDataUtility method for asserting a UserOperationRequest has valid fields for the paymaster data
isValidRequestUtility method for asserting a UserOperationStruct has valid fields for the given entry point version
middlewareActionsfunction that takes in ClientMiddlewareConfig used during client initiation and returns the middleware actions object that the smart account client extends with
parseFactoryAddressFromAccountInitCodeParses the factory address and factory calldata from the provided account initialization code (initCode).
parsePaymasterAndDataUtility method for parsing the paymaster address and paymasterData from the paymasterAndData hex string
pickPicks the specified keys from an object and returns a new object containing only those key-value pairs.
resolvePropertiesAwait all of the properties of a Deferrable object
sendTransactionSends a transaction using the provided client, arguments, optional overrides, and context. This sends a UO and then waits for it to be mined
sendTransactionsSends transactions using the provided client and transaction parameters. This function builds user operations from the transactions, sends them, and waits for the transaction to be mined.
sendUserOperationSends a user operation or batch of user operations using the connected account. Before executing, sendUserOperation will run the user operation through the middleware pipeline.
splitThe Split Transport allows you to split RPC traffic for specific methods across different RPC providers. This is done by specifying the methods you want handled specially as overrides and providing a fallback transport for all other methods.
stringToIndexUseful if you want to use a string, such as a user’s email address, as salt to generate a unique SmartAccount per user.
takeBytesGiven a bytes string, returns a slice of the bytes
toRecordConverts an array of objects into a record (object) where each key is determined by the specified selector and the value is determined by the provided function.
toSmartContractAccountConverts an account to a smart contract account and sets up various account-related methods using the provided parameters like transport, chain, entry point, and other utilities.
unpackSignRawMessageBytes-
wrapSignatureWith6492Wraps a given signature with additional data following the EIP-6492 standard.