useWriteContracts
and useCapabilities
hooks used below rely on new wallet RPC and are not yet supported in most wallets.
It is recommended to have a fallback function if your app supports wallets other than Smart Wallet.
willSponsor
function to add some extra validation if needed.
willSponsor
can be simplified or removed entirely if your paymaster service supports allowlisting which
contracts and function calls should be sponsored. Coinbase Developer Platform supports this.paymasterServiceUrl
in the TransactWithPaymaster
component.
useWriteContracts
hook.
TransactWithPaymaster
component that uses the useWriteContracts
hook to send a transaction with a paymaster.
The TransactWithPaymaster
component is used in the page.tsx
file.
That’s it! Smart Wallet will handle the rest. If your paymaster service is able to sponsor the transaction,
in the UI Smart Wallet will indicate to your user that the transaction is sponsored.