|
| 1 | +You can send additional metadata in the paymaster context to supply whatever information the |
| 2 | +Paymaster needs to process user operations. For instance, you might include the type of Paymaster |
| 3 | +(e.g., a Sponsored Paymaster versus an ERC-20-based Paymaster), references to specific tokens used |
| 4 | +for gas sponsorship, custom gas policies or limits, and any other parameters relevant to your |
| 5 | +sponsorship logic. |
| 6 | + |
| 7 | +To configure the paymaster context, you can use the `paymasterContext` property in the |
| 8 | +`bundlerConfig`. |
| 9 | + |
| 10 | +```ts |
| 11 | +import { |
| 12 | + AccountAbstractionProvider, |
| 13 | + SafeSmartAccount, |
| 14 | +} from "@web3auth/account-abstraction-provider"; |
| 15 | + |
| 16 | +const chainConfig = { |
| 17 | + chainNamespace: CHAIN_NAMESPACES.EIP155, |
| 18 | + chainId: "0xaa36a7", |
| 19 | + rpcTarget: "https://rpc.ankr.com/eth_sepolia", |
| 20 | + displayName: "Ethereum Sepolia Testnet", |
| 21 | + blockExplorerUrl: "https://sepolia.etherscan.io", |
| 22 | + ticker: "ETH", |
| 23 | + tickerName: "Ethereum", |
| 24 | + logo: "https://cryptologos.cc/logos/ethereum-eth-logo.png", |
| 25 | +}; |
| 26 | + |
| 27 | +const accountAbstractionProvider = new AccountAbstractionProvider({ |
| 28 | + config: { |
| 29 | + chainConfig, |
| 30 | + bundlerConfig: { |
| 31 | + // Get the pimlico API Key from dashboard.pimlico.io |
| 32 | + url: `https://api.pimlico.io/v2/${chainId}/rpc?apikey=${pimlicoAPIKey}`, |
| 33 | + // focus-start |
| 34 | + // This is just an example of how you can configure the paymaster context. |
| 35 | + // Please refer to the documentation of the paymaster you are using |
| 36 | + // to understand the required parameters. |
| 37 | + paymasterContext: { |
| 38 | + token: "SUPPORTED_TOKEN_CONTRACT_ADDRESS", |
| 39 | + sponsorshipPolicyId: "sp_my_policy_id", |
| 40 | + }, |
| 41 | + // focus-end |
| 42 | + }, |
| 43 | + smartAccountInit: new SafeSmartAccount(), |
| 44 | + paymasterConfig: { |
| 45 | + // Get the pimlico API Key from dashboard.pimlico.io |
| 46 | + url: `https://api.pimlico.io/v2/${chainId}/rpc?apikey=${pimlicoAPIKey}`, |
| 47 | + }, |
| 48 | + }, |
| 49 | +}); |
| 50 | +``` |
0 commit comments