Generate your API key
Navigate to app.rallyprotocol.com to generate API keys for
both Amoy and production Polygon.
Environments
Unity
{c#}
// Amoy Network (Polygon Testnet Amoy)
var amoy = NetworkProvider.RlyAmoy;
// Polygon Network (Polygon Mainnet)
var mainnet = NetworkProvider.RlyPolygon;
Initiating a Gasless Transaction
Once you have installed RallyMobile SDK, initialize it with your Amoy API Key.
Unity
{c#}
// 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
);
Calling Contracts Not Natively Supported by the SDK
Supported Contracts
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
Using the Relay Function to Call 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.
Unity
{c#}
// 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)
References
View the community libraries
for more gasless transaction references.