Last active
September 15, 2025 13:07
-
-
Save austin-sa-wang/1d5386afdf0094600bd66e1b3d21f9c0 to your computer and use it in GitHub Desktop.
smart wallet tx failed with pay-by-any-token policy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { getClientForChain } = useSmartWallets(); | |
| const chainClient = await getClientForChain(chain); | |
| // Send the transaction using chain-specific smart wallet client | |
| const txResult = await chainClient.sendTransaction( | |
| { | |
| paymasterContext: { | |
| token: usdcAddress as `0x${string}`, | |
| }, | |
| calls: [ | |
| // Approve transaction | |
| { | |
| to: usdcAddress as `0x${string}`, | |
| data: encodeFunctionData({ | |
| abi: erc20Abi, | |
| functionName: 'approve', | |
| args: [ | |
| '0x2cc0c7981D846b9F2a16276556f6e8cb52BfB633', // Alchemy paymaster constract address | |
| transferAmount, | |
| ], | |
| }) | |
| }, | |
| // Transfer transaction | |
| { | |
| to: usdcAddress as `0x${string}`, | |
| data: encodeFunctionData({ | |
| abi: erc20Abi, | |
| functionName: 'transfer', | |
| args: [smartWallet.address as `0x${string}`, transferAmount], | |
| }), | |
| }, | |
| ], | |
| }, | |
| { | |
| uiOptions: { | |
| description: `Sending 0.1 USDC to ${smartWallet.address} on ${chain.name}`, | |
| buttonText: 'Confirm Transaction', | |
| }, | |
| } | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment