Skip to main content

AccountAbstraction

Account Abstraction feature allows enhancing user experience and security by allowing smart contracts to manage user accounts and transactions more flexibly.

For using account abstraction functions, install web3-account-abstraction packages using: npm i web3-account-abstraction or yarn add web3-account-abstraction.

 import {AccountAbstraction} from 'web3-account-abstraction';

const aa = new AccountAbstraction('https://bundler-provider');
aa.supportedEntryPoints().then(console.log);

Type parameters

NameType
APIextends AARpcApi

Hierarchy

  • Web3Context

    AccountAbstraction

Accessors

BatchRequest

get BatchRequest(): Object

Will return the Web3BatchRequest constructor.

Returns

Object

Inherited from

Web3Context.BatchRequest


blockHeaderTimeout

get blockHeaderTimeout(): number

The blockHeaderTimeout is used over socket-based connections. This option defines the amount seconds it should wait for 'newBlockHeaders' event before falling back to polling to fetch transaction receipt. Default is 10 seconds.

Returns

number

Inherited from

Web3Context.blockHeaderTimeout

set blockHeaderTimeout(val): void

Will set the blockHeaderTimeout

Parameters

NameType
valnumber

Returns

void

Inherited from

Web3Context.blockHeaderTimeout


contractDataInputFill

get contractDataInputFill(): "input" | "data" | "both"

The contractDataInputFill options property will allow you to set the hash of the method signature and encoded parameters to the property either data, input or both within your contract. This will affect the contracts send, call and estimateGas methods Default is data.

Returns

"input" | "data" | "both"

Inherited from

Web3Context.contractDataInputFill

set contractDataInputFill(val): void

Will set the contractDataInputFill

Parameters

NameType
val"input" | "data" | "both"

Returns

void

Inherited from

Web3Context.contractDataInputFill


currentProvider

get currentProvider(): undefined | Web3BaseProvider<API>

Will return the current provider. (The same as provider)

Returns

undefined | Web3BaseProvider<API>

Returns the current provider

Example

const web3Context = new Web3Context("http://localhost:8545");
console.log(web3Context.provider);
> HttpProvider {
clientUrl: 'http://localhost:8545',
httpProviderOptions: undefined
}

Inherited from

Web3Context.currentProvider

set currentProvider(provider): void

Will set the current provider. (The same as provider)

Parameters

NameTypeDescription
providerundefined | string | LegacyRequestProvider | LegacySendProvider | LegacySendAsyncProvider | EIP1193Provider<API> | Web3BaseProvider<API> | SimpleProvider<API> | MetaMaskProvider<API>SupportedProviders The provider to set

Returns

void

Example

 const web3Context = new Web3Context("http://localhost:8545");
web3Context.currentProvider = "ws://localhost:8545";
console.log(web3Context.provider);
> WebSocketProvider {
_eventEmitter: EventEmitter {
_events: [Object: null prototype] {},
_eventsCount: 0,
...
}

Inherited from

Web3Context.currentProvider


defaultAccount

get defaultAccount(): undefined | string

This default address is used as the default from property, if no from property is specified in for the following methods:

  • web3.eth.sendTransaction()
  • web3.eth.call()
  • myContract.methods.myMethod().call()
  • myContract.methods.myMethod().send()

Returns

undefined | string

Inherited from

Web3Context.defaultAccount

set defaultAccount(val): void

Will set the default account.

Parameters

NameType
valundefined | string

Returns

void

Inherited from

Web3Context.defaultAccount


defaultBlock

get defaultBlock(): BlockNumberOrTag

The default block is used for certain methods. You can override it by passing in the defaultBlock as last parameter. The default value is "latest".

  • web3.eth.getBalance()
  • web3.eth.getCode()
  • web3.eth.getTransactionCount()
  • web3.eth.getStorageAt()
  • web3.eth.call()
  • myContract.methods.myMethod().call()

Returns

BlockNumberOrTag

Inherited from

Web3Context.defaultBlock

set defaultBlock(val): void

Will set the default block.

  • A block number
  • "earliest" - String: The genesis block
  • "latest" - String: The latest block (current head of the blockchain)
  • "pending" - String: The currently mined block (including pending transactions)
  • "finalized" - String: (For POS networks) The finalized block is one which has been accepted as canonical by greater than 2/3 of validators
  • "safe" - String: (For POS networks) The safe head block is one which under normal network conditions, is expected to be included in the canonical chain. Under normal network conditions the safe head and the actual tip of the chain will be equivalent (with safe head trailing only by a few seconds). Safe heads will be less likely to be reorged than the proof of work network's latest blocks.

Parameters

NameType
valBlockNumberOrTag

Returns

void

Inherited from

Web3Context.defaultBlock


defaultCommon

get defaultCommon(): undefined | Common

Will get the default common property The default common property does contain the following Common object:

  • customChain - Object: The custom chain properties
    • name - string: (optional) The name of the chain
    • networkId - number: Network ID of the custom chain
    • chainId - number: Chain ID of the custom chain
  • baseChain - string: (optional) mainnet, goerli, kovan, rinkeby, or ropsten
  • hardfork - string: (optional) chainstart, homestead, dao, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul, berlin, or london Default is undefined.

Returns

undefined | Common

Inherited from

Web3Context.defaultCommon

set defaultCommon(val): void

Will set the default common property

Parameters

NameType
valundefined | Common

Returns

void

Inherited from

Web3Context.defaultCommon


defaultHardfork

get defaultHardfork(): string

Will return the default hardfork. Default is london The default hardfork property can be one of the following:

  • chainstart
  • homestead
  • dao
  • tangerineWhistle
  • spuriousDragon
  • byzantium
  • constantinople
  • petersburg
  • istanbul
  • berlin
  • london
  • 'arrowGlacier',
  • 'tangerineWhistle',
  • 'muirGlacier'

Returns

string

Inherited from

Web3Context.defaultHardfork

set defaultHardfork(val): void

Will set the default hardfork.

Parameters

NameType
valstring

Returns

void

Inherited from

Web3Context.defaultHardfork


enableExperimentalFeatures

get enableExperimentalFeatures(): Object

The enableExperimentalFeatures is used to enable trying new experimental features that are still not fully implemented or not fully tested or still have some related issues. Default is false for every feature.

Returns

Object

NameType
useRpcCallSpecificationboolean
useSubscriptionWhenCheckingBlockTimeoutboolean

Inherited from

Web3Context.enableExperimentalFeatures

set enableExperimentalFeatures(val): void

Will set the enableExperimentalFeatures

Parameters

NameType
valObject
val.useRpcCallSpecificationboolean
val.useSubscriptionWhenCheckingBlockTimeoutboolean

Returns

void

Inherited from

Web3Context.enableExperimentalFeatures


givenProvider

get givenProvider(): undefined | LegacyRequestProvider | LegacySendProvider | LegacySendAsyncProvider | EIP1193Provider<never> | Web3BaseProvider<never> | SimpleProvider<never> | MetaMaskProvider<never>

Will return the givenProvider if available.

When using web3.js in an Ethereum compatible browser, it will set with the current native provider by that browser. Will return the given provider by the (browser) environment, otherwise undefined.

Returns

undefined | LegacyRequestProvider | LegacySendProvider | LegacySendAsyncProvider | EIP1193Provider<never> | Web3BaseProvider<never> | SimpleProvider<never> | MetaMaskProvider<never>

Inherited from

Web3Context.givenProvider


handleRevert

get handleRevert(): boolean

The handleRevert options property returns the revert reason string if enabled for the following methods:

  • web3.eth.sendTransaction()
  • web3.eth.call()
  • myContract.methods.myMethod().call()
  • myContract.methods.myMethod().send() Default is false.

Note: At the moment handleRevert is only supported for sendTransaction and not for sendSignedTransaction

Returns

boolean

Inherited from

Web3Context.handleRevert

set handleRevert(val): void

Will set the handleRevert

Parameters

NameType
valboolean

Returns

void

Inherited from

Web3Context.handleRevert


ignoreGasPricing

get ignoreGasPricing(): boolean

Will get the ignoreGasPricing property. When true, the gasPrice, maxPriorityFeePerGas, and maxFeePerGas will not be autofilled in the transaction object. Useful when you want wallets to handle gas pricing.

Returns

boolean

Inherited from

Web3Context.ignoreGasPricing


provider

get provider(): undefined | Web3BaseProvider<API>

Will return the current provider.

Returns

undefined | Web3BaseProvider<API>

Returns the current provider

Example

const web3 = new Web3Context("http://localhost:8545");
console.log(web3.provider);
> HttpProvider {
clientUrl: 'http://localhost:8545',
httpProviderOptions: undefined
}

Inherited from

Web3Context.provider

set provider(provider): void

Will set the current provider.

Parameters

NameTypeDescription
providerundefined | string | LegacyRequestProvider | LegacySendProvider | LegacySendAsyncProvider | EIP1193Provider<API> | Web3BaseProvider<API> | SimpleProvider<API> | MetaMaskProvider<API>The provider to set Accepted providers are of type SupportedProviders

Returns

void

Example

 const web3Context = new web3ContextContext("http://localhost:8545");
web3Context.provider = "ws://localhost:8545";
console.log(web3Context.provider);
> WebSocketProvider {
_eventEmitter: EventEmitter {
_events: [Object: null prototype] {},
_eventsCount: 0,
...
}

Inherited from

Web3Context.provider


subscriptionManager

get subscriptionManager(): Web3SubscriptionManager<API, RegisteredSubs>

Will return the current subscriptionManager (Web3SubscriptionManager)

Returns

Web3SubscriptionManager<API, RegisteredSubs>

Inherited from

Web3Context.subscriptionManager


transactionBlockTimeout

get transactionBlockTimeout(): number

The transactionBlockTimeout is used over socket-based connections. This option defines the amount of new blocks it should wait until the first confirmation happens, otherwise the PromiEvent rejects with a timeout error. Default is 50.

Returns

number

Inherited from

Web3Context.transactionBlockTimeout

set transactionBlockTimeout(val): void

Will set the transactionBlockTimeout.

Parameters

NameType
valnumber

Returns

void

Inherited from

Web3Context.transactionBlockTimeout


transactionConfirmationBlocks

get transactionConfirmationBlocks(): number

This defines the number of blocks it requires until a transaction is considered confirmed. Default is 24.

Returns

number

Inherited from

Web3Context.transactionConfirmationBlocks

set transactionConfirmationBlocks(val): void

Will set the transactionConfirmationBlocks.

Parameters

NameType
valnumber

Returns

void

Inherited from

Web3Context.transactionConfirmationBlocks


transactionPollingInterval

get transactionPollingInterval(): number

Used over HTTP connections. This option defines the number of seconds between Web3 calls for a receipt which confirms that a transaction was mined by the network. Default is 1000 ms.

Returns

number

Inherited from

Web3Context.transactionPollingInterval

set transactionPollingInterval(val): void

Will set the transactionPollingInterval.

Parameters

NameType
valnumber

Returns

void

Inherited from

Web3Context.transactionPollingInterval


transactionPollingTimeout

get transactionPollingTimeout(): number

Used over HTTP connections. This option defines the number of seconds Web3 will wait for a receipt which confirms that a transaction was mined by the network. Note: If this method times out, the transaction may still be pending. Default is 750 seconds (12.5 minutes).

Returns

number

Inherited from

Web3Context.transactionPollingTimeout

set transactionPollingTimeout(val): void

Will set the transactionPollingTimeout.

Parameters

NameType
valnumber

Returns

void

Inherited from

Web3Context.transactionPollingTimeout


transactionReceiptPollingInterval

get transactionReceiptPollingInterval(): undefined | number

The transactionPollingInterval is used over HTTP connections. This option defines the number of seconds between Web3 calls for a receipt which confirms that a transaction was mined by the network. Default is undefined

Returns

undefined | number

Inherited from

Web3Context.transactionReceiptPollingInterval

set transactionReceiptPollingInterval(val): void

Will set the transactionReceiptPollingInterval

Parameters

NameType
valundefined | number

Returns

void

Inherited from

Web3Context.transactionReceiptPollingInterval


transactionSendTimeout

get transactionSendTimeout(): number

The time used to wait for Ethereum Node to return the sent transaction result. Note: If the RPC call stuck at the Node and therefor timed-out, the transaction may still be pending or even mined by the Network. We recommend checking the pending transactions in such a case. Default is 750 seconds (12.5 minutes).

Returns

number

Inherited from

Web3Context.transactionSendTimeout

set transactionSendTimeout(val): void

Will set the transactionSendTimeout.

Parameters

NameType
valnumber

Returns

void

Inherited from

Web3Context.transactionSendTimeout

Methods

estimateUserOperationGas

estimateUserOperationGas(userOperation, entryPoint): Promise<Web3APIReturnType<API, "eth_estimateUserOperationGas">>

Estimate the gas values for a UserOperation. Given UserOperation optionally without gas limits and gas prices, return the needed gas limits. The signature field is ignored by the wallet, so that the operation will not require user's approval. Still, it might require putting a "semi-valid" signature (e.g. a signature in the right length)

Parameters

NameTypeDescription
userOperationUserOperation-
entryPointstringa singleton contract to execute bundles of UserOperations. Bundlers/Clients whitelist the supported entrypoint.

Returns

Promise<Web3APIReturnType<API, "eth_estimateUserOperationGas">>

  • preVerificationGas gas overhead of this UserOperation
  • verificationGasLimit actual gas used by the validation of this UserOperation
  • callGasLimit value used by inner account execution

Example

	estimateUserOperationGas({
sender: "0x9fd042a18e90ce326073fa70f111dc9d798d9a52",
nonce: "123",
initCode: "0x68656c6c6f",
callData: "0x776F726C64",
callGasLimit: "1000",
verificationGasLimit: "2300",
preVerificationGas: "3100",
maxFeePerGas: "0",
maxPriorityFeePerGas: "0",
paymasterAndData: "0x626c6f63746f",
signature: "0x636c656d656e74"
},"0x636c656d656e74").then(console.log);
> {
callGasLimit : "0x18b33",
preVerificationGas: "0xdf17",
verificationGasLimit:"0x128c4"
}

extend

extend(extendObj): this

This method allows extending the web3 modules. Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing something new.

Parameters

NameType
extendObjExtensionObject

Returns

this

Inherited from

Web3Context.extend


generateUserOpHash

generateUserOpHash(userOp, entryPoint, chainId): string

calculate UserOperationHash

Parameters

NameTypeDescription
userOpUserOperationRequirea structure that describes a transaction to be sent on behalf of a user.
entryPointstringa singleton contract to execute bundles of UserOperations. Bundlers/Clients whitelist the supported entrypoint.
chainIdstring-

Returns

string

an array of the entryPoint addresses supported by the client. The first element of the array SHOULD be the entryPoint addressed preferred by the client.

Example

generateUserOpHash({
sender: "0x9fd042a18e90ce326073fa70f111dc9d798d9a52",
nonce: "123",
initCode: "0x68656c6c6f",
callData: "0x776F726C64",
callGasLimit: "1000",
verificationGasLimit: "2300",
preVerificationGas: "3100",
maxFeePerGas: "0",
maxPriorityFeePerGas: "0",
paymasterAndData: "0x626c6f63746f",
signature: "0x636c656d656e74"
},"0x636c656d656e74", '0x1').then(console.log);
> 0xxxx

getUserOperationByHash

getUserOperationByHash(hash): Promise<Web3APIReturnType<API, "eth_getUserOperationByHash">>

Return a UserOperation based on a hash (userOpHash) returned by eth_sendUserOperation

Parameters

NameTypeDescription
hashstringa userOpHash value returned by eth_sendUserOperation

Returns

Promise<Web3APIReturnType<API, "eth_getUserOperationByHash">>

null in case the UserOperation is not yet included in a block, or a full UserOperation, with the addition of entryPoint, blockNumber, blockHash and transactionHash

Example

	getUserOperationByHash("0xxxxx").then(console.log);
> {
userOperation: {
sender: "xxxx",
nonce: "xxxx",
initCode: "0xxxxxxxxxxxxxxx",
callData: "0xxxxxxxxxxxxxxx",
callGasLimit: "xxxx",
verificationGasLimit: "xxxx",
preVerificationGas: "xxxx",
maxFeePerGas: "0",
maxPriorityFeePerGas: "0",
paymasterAndData: "0xxxxxxxxxxxxxxx",
signature: "0xxxxxxxxxxxxxxx"
},
entryPoint: '0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789',
blockNumber: 39642225,
blockHash: '0x638a175940cacb33f35e265961b164b14aa77477438340e635b227752f31981f',
transactionHash: '0xc3e64ac247ae2343335596e106d1b97e35637656e1b99b37977a4165b34aeeb4',
}

getUserOperationReceipt

getUserOperationReceipt(hash): Promise<Web3APIReturnType<API, "eth_getUserOperationReceipt">>

Return null in case the UserOperation is not yet included in a block, or

  • userOpHash the request hash
  • entryPoint
  • sender
    • nonce
    • paymaster the paymaster used for this userOp (or empty)
    • actualGasCost - actual amount paid (by account or paymaster) for this UserOperation
    • actualGasUsed - total gas used by this UserOperation (including preVerification, creation, validation and execution)
    • success boolean - did this execution completed without revert
    • reason in case of revert, this is the revert reason
    • logs the logs generated by this UserOperation (not including logs of other UserOperations in the same bundle)
    • receipt the TransactionReceipt object. Note that the returned TransactionReceipt is for the entire bundle, not only for this UserOperation.

Parameters

NameTypeDescription
hashstringhash a userOpHash value returned by eth_sendUserOperation

Returns

Promise<Web3APIReturnType<API, "eth_getUserOperationReceipt">>

null in case the UserOperation is not yet included in a block, or UserOperation

Example

	getUserOperationReceipt("0xa890d7c0dccfd6cebc025919f4857ab97953ae218e82f5e24c297f02ceea5b21").then(console.log);
>"userOpHash": "0xa890d7c0dccfd6cebc025919f4857ab97953ae218e82f5e24c297f02ceea5b21",
"entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
"sender": "0x026B37A09aF3ceB346c39999c5738F86A1a48f4d",
"nonce": "0x7",
"paymaster": "0xa312d8D37Be746BD09cBD9e9ba2ef16bc7Da48FF",
"actualGasCost": "0x1a036c1638be0",
"actualGasUsed": "0x2e8d8",
"success": true,
"reason": "",
"logs": [
{
"address": "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789",
"topics": [
"0xbb47ee3e183a558b1a2ff0874b079f3fc5478b7454eacf2bfc5af2ff5878f972"
],
"data": "0x",
"blockHash": "0x638a175940cacb33f35e265961b164b14aa77477438340e635b227752f31981f",
"blockNumber": "0x25ce471",
"transactionHash": "0xc3e64ac247ae2343335596e106d1b97e35637656e1b99b37977a4165b34aeeb4",
"transactionIndex": "0x44",
"logIndex": "0x12d",
"removed": false
},
{
"address": "0xfd8ec18d48ac1f46b600e231da07d1da8209ceef",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x000000000000000000000000026b37a09af3ceb346c39999c5738f86a1a48f4d",
"0x000000000000000000000000000000000000000000000000000000000000007f"
],
"data": "0x",
"blockHash": "0x638a175940cacb33f35e265961b164b14aa77477438340e635b227752f31981f",
"blockNumber": "0x25ce471",
"transactionHash": "0xc3e64ac247ae2343335596e106d1b97e35637656e1b99b37977a4165b34aeeb4",
"transactionIndex": "0x44",
"logIndex": "0x12e",
"removed": false
},
{
"address": "0x00005ea00ac477b1030ce78506496e8c2de24bf5",
"topics": [
"0xe90cf9cc0a552cf52ea6ff74ece0f1c8ae8cc9ad630d3181f55ac43ca076b7d6",
"0x000000000000000000000000fd8ec18d48ac1f46b600e231da07d1da8209ceef",
"0x000000000000000000000000026b37a09af3ceb346c39999c5738f86a1a48f4d",
"0x0000000000000000000000000000a26b00c1f0df003000390027140000faa719"
],
"data": "0x000000000000000000000000026b37a09af3ceb346c39999c5738f86a1a48f4d0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e80000000000000000000000000000000000000000000000000000000000000000",
"blockHash": "0x638a175940cacb33f35e265961b164b14aa77477438340e635b227752f31981f",
"blockNumber": "0x25ce471",
"transactionHash": "0xc3e64ac247ae2343335596e106d1b97e35637656e1b99b37977a4165b34aeeb4",
"transactionIndex": "0x44",
"logIndex": "0x12f",
"removed": false
},
{
"address": "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789",
"topics": [
"0x49628fd1471006c1482da88028e9ce4dbb080b815c9b0344d39e5a8e6ec1419f",
"0xa890d7c0dccfd6cebc025919f4857ab97953ae218e82f5e24c297f02ceea5b21",
"0x000000000000000000000000026b37a09af3ceb346c39999c5738f86a1a48f4d",
"0x000000000000000000000000a312d8d37be746bd09cbd9e9ba2ef16bc7da48ff"
],
"data": "0x000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000001a036c1638be0000000000000000000000000000000000000000000000000000000000002e8d8",
"blockHash": "0x638a175940cacb33f35e265961b164b14aa77477438340e635b227752f31981f",
"blockNumber": "0x25ce471",
"transactionHash": "0xc3e64ac247ae2343335596e106d1b97e35637656e1b99b37977a4165b34aeeb4",
"transactionIndex": "0x44",
"logIndex": "0x130",
"removed": false
}
],
"receipt": {
"transactionHash": "0xc3e64ac247ae2343335596e106d1b97e35637656e1b99b37977a4165b34aeeb4",
"transactionIndex": "0x44",
"blockHash": "0x638a175940cacb33f35e265961b164b14aa77477438340e635b227752f31981f",
"blockNumber": "0x25ce471",
"from": "0x1e6754b227c6ae4b0ca61d82f79d60660737554a",
"to": "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789",
"cumulativeGasUsed": "0x1716d3b",
"gasUsed": "0x2b6c6",
"contractAddress": null,
"logs": [
{
"address": "0xfd8ec18d48ac1f46b600e231da07d1da8209ceef",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x000000000000000000000000026b37a09af3ceb346c39999c5738f86a1a48f4d",
"0x000000000000000000000000000000000000000000000000000000000000007f"
],
"data": "0x",
"blockHash": "0x638a175940cacb33f35e265961b164b14aa77477438340e635b227752f31981f",
"blockNumber": "0x25ce471",
"transactionHash": "0xc3e64ac247ae2343335596e106d1b97e35637656e1b99b37977a4165b34aeeb4",
"transactionIndex": "0x44",
"logIndex": "0x12e",
"removed": false
},
],
"status": "0x1",
"logsBloom": "0x000000000000000000000000000000000008000000000000000000000000000000080000000000000002001108040020001080000000000000000200004000000000000000000000000800080000008000000000000000000001000208400040000000000a0008000000000000000800000000000000004080800010020100040000000000000000100000000000010000000000200080000000000000000000210000000000000000400080000000000000000000000000108002000004004008000002000000000001001000800000000001000000800000148040020020000000000000000000000001000000000100000000000000000000002000100000",
"type": "0x2",
"effectiveGasPrice": "0x59682f2e"
}

link<T>(parentContext): void

Link current context to another context.

Type parameters

NameType
Textends Web3Context<unknown, any, T>

Parameters

NameType
parentContextT

Returns

void

Inherited from

Web3Context.link


sendUserOperation

sendUserOperation(userOperation, entryPoint): Promise<Web3APIReturnType<API, "eth_sendUserOperation">>

Sends a UserOperation to the bundler. If accepted, the bundler will add it to the UserOperation mempool and return a userOpHash.

Parameters

NameTypeDescription
userOperationUserOperation-
entryPointstringa singleton contract to execute bundles of UserOperations. Bundlers/Clients whitelist the supported entrypoint.

Returns

Promise<Web3APIReturnType<API, "eth_sendUserOperation">>

userOperation hash or throws error instead of balance.

Example

	sendUserOperation({
sender: "0x9fd042a18e90ce326073fa70f111dc9d798d9a52",
nonce: "123",
initCode: "0x68656c6c6f",
callData: "0x776F726C64",
callGasLimit: "1000",
verificationGasLimit: "2300",
preVerificationGas: "3100",
maxFeePerGas: "8500",
maxPriorityFeePerGas: "1",
paymasterAndData: "0x626c6f63746f",
signature: "0x636c656d656e74"
},"0x636c656d656e74").then(console.log);
> 0xe554d0701f7fdc734f84927d109537f1ac4ee4ebfa3670c71d224a4fa15dbcd1

setProvider

setProvider(provider?): boolean

Will set the provider.

Parameters

NameTypeDescription
provider?string | LegacyRequestProvider | LegacySendProvider | LegacySendAsyncProvider | EIP1193Provider<unknown> | Web3BaseProvider<unknown> | SimpleProvider<unknown> | MetaMaskProvider<unknown>SupportedProviders The provider to set

Returns

boolean

Returns true if the provider was set

Inherited from

Web3Context.setProvider


supportedEntryPoints

supportedEntryPoints(): Promise<Web3APIReturnType<API, "eth_supportedEntryPoints">>

Returns an array of the entryPoint addresses supported by the client. The first element of the array SHOULD be the entryPoint addressed preferred by the client.

Returns

Promise<Web3APIReturnType<API, "eth_supportedEntryPoints">>

an array of the entryPoint addresses supported by the client. The first element of the array SHOULD be the entryPoint addressed preferred by the client.

Example

	supportedEntryPoints().then(console.log);
> ["0xcd01C8aa8995A59eB7B2627E69b40e0524B5ecf8", "0x7A0A0d159218E6a2f407B99173A2b12A6DDfC2a6"]

use

use<T, T2>(ContextRef, ...args): T

Use to create new object of any type extended by Web3Context and link it to current context. This can be used to initiate a global context object and then use it to create new objects of any type extended by Web3Context.

Type parameters

NameType
Textends Web3Context<unknown, any, T>
T2extends unknown[]

Parameters

NameType
ContextRefWeb3ContextConstructor<T, T2>
...args[...T2[]]

Returns

T

Inherited from

Web3Context.use