Gasless Transactions
Estimated time to read: 2 minutes
Only for Third-party Wallets
The Arcana Gasless (Standalone) SDK is not meant to enable gasless transactions via the Arcana wallet.
To enable gasless transactions via the in-app Arcana wallet, integrate the app with the Arcana Auth SDK and use the built-in gasless feature. See Gasless Quick Start Guide for details.
Prerequisites
-
Register the app and obtain the unique Client ID assigned to registered apps used during the SDK integration.
-
Configure gas tanks on one or more supported blockchain networks and deposit funds to sponsor gas fees.
-
The Arcana Gasless (Standalone) SDK is installed and the app is integrated with the SDK.
-
While adding code for gasless transactions, ensure that only the authenticated users can access gasless transactions.
Add Gasless Transactions
const erc20abi = [...];
let amount = 0.1;
const erc20Address = "0x2d7aC0907961c7.......45f981Ed8373b5dF86";
const toAddress = "0x723455665060698....87689dA78E25";
const Erc20Interface = new ethers.utils.Interface(erc20abi);
const encodedData = Erc20Interface.encodeFunctionData("transfer", [
toAddress,
ethers.utils.parseEther(amount + ""),
]);
// You need to create transaction objects of the following interface
const tx1 = {
from: scw.getSCWAddress(),
to: erc20Address, // destination smart contract address
data: encodedData,
};
// Check balance
// Use scw.getPaymaster() to check whether gas tanks are adequately funded
console.log("Paymaster Balance: " + (await scw.getPaymasterBalance()) / 1e18);
if (await scw.getPaymasterBalance()/1e18) > 0 {
let tx = await scw.doTx(tx1);
await tx.wait();
console.log(`Transfer done ${tx.userOpHash}`)
} else {
console.log("Insufficient funds in the gas tank.")
}
What's Next?
The app is successfully integrated with the Arcana Gasless (Standalone) SDK and ready to deploy on the Testnet. Learn more...
See also
'Gasless' integration example: See sample-gasless-metamask-only
submodule in Auth Examples
Arcana Gasless (Standalone) SDK Quick Links