safeOperations
This extension extends the SafeClient
functionality by allowing a bundler and a paymaster to submit ERC-4337 (opens in a new tab) user operations.
Usage
_20import { PaymasterOptions } from '@safe-global/relay-kit' _20import { BundlerOptions, safeOperations } from '@safe-global/sdk-starter-kit'_20import { safeClient } from './setup.ts'_20_20const bundlerOptions: BundlerOptions = {_20 bundlerUrl: 'https://...'_20}_20_20const paymasterOptions: PaymasterOptions = {_20 isSponsored: true, // Optional_20 paymasterUrl: 'https://...', // Optional_20 sponsorshipPolicyId: 'abc', // Optional_20 paymasterAddress: '0x...', // Optional_20 paymasterTokenAddress: '0x...', // Optional_20 amountToApprove: 123n // Optional_20}_20_20const safeOperationsClient = await safeClient.extend(_20 safeOperations(bundlerOptions, paymasterOptions)_20)
Returns
Promise<SafeClient & { sendSafeOperation, confirmSafeOperation, getPendingSafeOperation }>
The SafeClient
instance with the extended functionality.
Parameters
bundlerOptions.bundlerUrl
- Type:
string
The URL of the bundler.
_11safeOperations(_11 { bundlerUrl: 'https://...' },_11 {_11 isSponsored: true,_11 paymasterUrl: 'https://...',_11 sponsorshipPolicyId: 'abc',_11 paymasterAddress: '0x...',_11 paymasterTokenAddress: '0x...',_11 amountToApprove: 123n_11 }_11)
paymasterOptions.isSponsored
(Optional)
- Type:
boolean
A boolean variable that indicates if the user operation is sponsored or not.
_11safeOperations(_11 { bundlerUrl: 'https://...' },_11 {_11 isSponsored: true,_11 paymasterUrl: 'https://...',_11 sponsorshipPolicyId: 'abc',_11 paymasterAddress: '0x...',_11 paymasterTokenAddress: '0x...',_11 amountToApprove: 123n_11 }_11)
paymasterOptions.paymasterUrl
- Type:
string
The URL of the paymaster.
_11safeOperations(_11 { bundlerUrl: 'https://...' },_11 {_11 isSponsored: true,_11 paymasterUrl: 'https://...',_11 sponsorshipPolicyId: 'abc',_11 paymasterAddress: '0x...',_11 paymasterTokenAddress: '0x...',_11 amountToApprove: 123n_11 }_11)
paymasterOptions.sponsorshipPolicyId
(Optional)
- Type:
string
The sponsorship policy id used in the user operation. You can get it from the selected paymaster provider.
_11safeOperations(_11 { bundlerUrl: 'https://...' },_11 {_11 isSponsored: true,_11 paymasterUrl: 'https://...',_11 sponsorshipPolicyId: 'abc',_11 paymasterAddress: '0x...',_11 paymasterTokenAddress: '0x...',_11 amountToApprove: 123n_11 }_11)
paymasterOptions.paymasterAddress
(Optional)
- Type:
string
The address of the paymaster.
_11safeOperations(_11 { bundlerUrl: 'https://...' },_11 {_11 isSponsored: true,_11 paymasterUrl: 'https://...',_11 sponsorshipPolicyId: 'abc',_11 paymasterAddress: '0x...',_11 paymasterTokenAddress: '0x...',_11 amountToApprove: 123n_11 }_11)
paymasterOptions.paymasterTokenAddress
(Optional)
- Type:
string
The address of the ERC-20 token used to pay for the user operation.
_11safeOperations(_11 { bundlerUrl: 'https://...' },_11 {_11 isSponsored: true,_11 paymasterUrl: 'https://...',_11 sponsorshipPolicyId: 'abc',_11 paymasterAddress: '0x...',_11 paymasterTokenAddress: '0x...',_11 amountToApprove: 123n_11 }_11)
paymasterOptions.amountToApprove
(Optional)
- Type:
bigint
The amount of ERC-20 tokens to approve to the paymaster to pay for the user operation.
_11safeOperations(_11 { bundlerUrl: 'https://...' },_11 {_11 isSponsored: true,_11 paymasterUrl: 'https://...',_11 sponsorshipPolicyId: 'abc',_11 paymasterAddress: '0x...',_11 paymasterTokenAddress: '0x...',_11 amountToApprove: 123n_11 }_11)