Get Started: Gasless (3rd-party Wallets)
Estimated time to read: 3 minutes
Integrate Web3 apps with Arcana Gasless (Standalone) SDK and enable third-party browser-based wallet users to sign blockchain transactions with zero gas fees.
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
-
App must be registered via the Arcana Developer Dashboard: https://dashboard.arcana.network
-
The unique Client ID assigned to the registered app in the default Testnet configuration profile will be required for SDK integration.
1. Configure Gasless
Configure gasless transactions for the registered app through the Arcana Developer Dashboard. Set up gas tanks for one or more supported chains. Fund gas tanks, and provide smart contract ABI details to whitelist selected app operations.
Gasless Transaction Limitations
- Gasless transactions are available only for ERC-20 tokens.
- To ensure smooth gasless operations, the gas tank must have at least a 0.1 ETH (or native chain token) balance.
2. Install SDK
npm i @arcana/scw
yarn add @arcana/scw
<script src="https://cdn.jsdelivr.net/npm/@arcana/scw"></script>
<script src="https://unpkg.com/@arcana/scw"></script>
3. Integrate App
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);
4. Use DoTx()
Enable gasless transactions for third-party wallets by calling the doTx()
method of the Arcana Gasless (Standalone) SDK in the authenticated user's context.
Before calling DoTx()
The Web3 app must be connected with third-party wallets before initiating `DoTx() in the authenticated user's context.
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.")
}
That's all!
The 'Gasless' app is ready to onboard users and allow them to sign blockchain transactions.
See Also
'Gasless' integration example: See sample-gasless-metamask-only
submodule in Auth Examples
Arcana Gasless (Standalone) SDK Quick Links