Transfer tokens gaslessly
Gasless transactions with RLY token
In this section, we leverage the RLY token (polygonscan) and our faucet to enable developers to complete a gasless token transfer in just seconds. Use the following code to claim test RLY tokens and transfer it to a destination wallet of your choosing.
import 'package:rly_network_flutter_sdk/network.dart';
//get Amoy config
final amoy = rlyAmoyNetwork;
//add your API Key
amoy.setApiKey(env.API_KEY);
//claim 10 test RLY tokens gaslessly for testing
await amoy.claimRly();
//destination address for testing
final destinationAddress = "0x8D9F6c7Ab1316B613BDdcD1fDbac6025A1323569"
//transfer RLY token using ExecuteMetaTransaction
await amoy.transferExact(
destinationAddress,
BigInt.parse(1),
MetaTxMethod.ExecuteMetaTransaction
);
Getting started with your chosen ERC-20 token
Prerequisites
Contract is compatible with the RallyMobile SDK
Contracts that are ERC2771 compatible are natively supported by the RallyMobile SDK. Those that are not ERC2771 compatible must be whitelisted, view the guide here.
Contract natively supports gasless transactions
Contracts that have the
executeMetaTransaction
orPermit
method for gasless transactions are natively supported by our SDK. To determine which method is supported by your contract, view the guide here.
Gasless transactions with your chosen ERC-20 token
Use the following code to transfer your chosen token gaslessly.
import 'package:rly_network_flutter_sdk/network.dart';
//get Amoy config for rally protocol sdk
final amoy = rlyAmoyNetwork;
//add your API Key
amoy.setApiKey(env.API_KEY);
//destination address
final destinationAddress = "0x...."
//hex address of token contract
final tokenAddress = "0x...."
//transfer tokens if the token contract supports executeMetaTransaction
await amoy.transferExact(
destinationAddress,
BigInt.parse(1),
MetaTxMethod.ExecuteMetaTransaction,
{tokenAddress}
);
//transfer tokens if the token contract supports Permit
await amoy.transferExact(
destinationAddress,
BigInt.parse(1),
MetaTxMethod.Permit,
{tokenAddress}
);
Last updated