Navigate to app.rallyprotocol.com to generate API keys for both Amoy and production Polygon.
// Amoy Network (Polygon Testnet Amoy)
var amoy = NetworkProvider.RlyAmoy;
// Sepolia Network (Base Testnet Sepolia)
var sepolia = NetworkProvider.RlySepolia;
// Polygon Network (Polygon Mainnet)
var mainnet = NetworkProvider.RlyPolygon;
Once you have installed RallyMobile SDK, initialize it with your Amoy API Key.
// get Amoy config for Rally Protocol SDK
var amoy = NetworkProvider.RlyAmoy;
// add your API Key (can also be chained)
amoy.WithApiKey(env.API_KEY);
// claim 10 test RLY tokens gaslessly for testing
await amoy.ClaimRly();
// get balance of specified token
await amoy.GetBalance(tokenAddress);
// transfer an ERC20 token
await amoy.Transfer(
transferAddress,
new BigInteger(1),
MetaTxMethod.ExecuteMetaTransaction
);
The SDK allows sending transactions to the relayer API for contracts not supported by the SDK. The paymaster accepts two types of contracts:
- ERC2771 compatible contracts
- Non ERC2771 compatible contracts
To gaslessly execute a transaction on a supported contract, create a GSN transaction object for your transaction and use the relay()
method to send the transaction to our relayer.
// Example Unity code for relaying a transaction
...
var gsnTx = new GsnTransactionDetails(
from: accountAddress,
data: tx.data,
value: "0",
to: contractAddress,
gas: gas.ToString(),
maxFeePerGas: maxFeePerGas.ToString(),
maxPriorityFeePerGas: maxPriorityFeePerGas.ToString(),
);
await amoy.Relay(gsnTx)
View the community libraries for more gasless transaction references.