Integrate Gasless SDK
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
-
The app must be registered. The unique Client ID assigned to the registered app will be required for SDK integration.
-
Gas tanks must be configured on one or more supported blockchain networks. Some funds must be deposited there to sponsor gas fees. App operations need to be whitelisted for sponsoring gas fees.
-
The Arcana Gasless (Standalone) SDK should be installed.
Integrate
import { scw } from @arcana/scw;
const scw = new arcana.scw.SCW();
await scw.init("<app_id>", window.ethereum);
The init
method is used to initialize the Arcana Gasless (Standalone) SDK with the unique app identifier obtained via the Arcana Developer Dashboard after registering the app. After init
you can call other methods of the scw
object.
During initialization, an SCW account is associated with the EoA account. All gasless transactions must use this SCW account address.
Use the getSCWAddress
to get the logged-in user's smart contract address (SCW Address). Call getPaymasterBalance
to check if the gas tank is adequately funded.
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 + ""),
]);
console.log("Address: " + scw.getSCWAddress());
// Check balance
console.log("Paymaster Balance: " + (await scw.getPaymasterBalance()) / 1e18);
What's Next?
Add code in the authenticated user's context to perform gasless transactions via the third-party wallets.
See also
'Gasless' integration example: See sample-gasless-metamask-only
submodule in Auth Examples
Arcana Gasless (Standalone) SDK Quick Links