Skip to content

Instantly share code, notes, and snippets.

@austin-sa-wang
Last active September 15, 2025 13:07
Show Gist options
  • Select an option

  • Save austin-sa-wang/1d5386afdf0094600bd66e1b3d21f9c0 to your computer and use it in GitHub Desktop.

Select an option

Save austin-sa-wang/1d5386afdf0094600bd66e1b3d21f9c0 to your computer and use it in GitHub Desktop.
smart wallet tx failed with pay-by-any-token policy
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