Rally Protocol
Search
K
Comment on page

Full API Reference

claimRLY

Use the RLY token faucet on Mumbai to claim RLY token directly to a crypto account created by the SDK
React Native
Flutter
import { RlyMumbaiNetwork } from '@rly-network/mobile-sdk';
// redeem 10 RLY to a crypto account
await RlyMumbaiNetwork.claimRly();
import 'package:rly_network_flutter_sdk/network.dart';
// claim 10 test RLY tokens gaslessly for testing
await rlyMumbaiNetwork.claimRly();

createAccount

Generate an EOA wallet on-device at device + application level that's backed up to the cloud. Read about key persistence here.
React Native
Flutter
import { createAccount } from '@rly-network/mobile-sdk';
const newAccount = await createAccount();
// use storage options to configure whether keys are synced to the cloud
const newAccount = await createAccount({ storageOptions: { saveToCloud: false, rejectOnCloudSaveFailure: false } })
import 'package:rly_network_flutter_sdk/wallet_manager.dart';
// create an account
final account = await WalletManager.getInstance().createWallet();
// use storage options to configure whether keys are synced to the cloud
final account = await WalletManager.getInstance().createWallet(
storageOptions: KeyStorageConfig(saveToCloud: false, rejectOnCloudSaveFailure: false)
);

getAccount

Get the public address of crypto account
React Native
Flutter
import { getAccount } from '@rly-network/mobile-sdk';
/// get current user account address
const account = await getAccount();
import 'package:rly_network_flutter_sdk/wallet_manager.dart';
//To get a wallet object that can be used to sign transactions
final wallet = await WalletManager.getInstance().getWallet();
//Get the public address of the current user
final address = await WalletManager.getInstance().getPublicAddress();

getBalance

Deprecated, see getDisplayBalance

getDisplayBalance

Get the balance of the crypto account for a specified token in a human readable format for display purposes. This may have rounding issues; for use on chain see getExactBalance instead.
React Native
Flutter
import {
RlyMumbaiNetwork,
getAccount,
} from '@rly-network/mobile-sdk';
// get current account
const account = await getAccount();
// token contract address
const erc20TokenAddress = '0x...';
//get balance
const balance = await RlyMumbaiNetwork.getDisplayBalance(erc20TokenAddress);
import 'package:rly_network_flutter_sdk/network.dart';
final tokenAddress = "0x...." //hex address of token contract.
// get balance of any ERC20 token on Mumbai testnet
await rlyMumbaiNetwork.getBalance(tokenAddress);
// to switch networks between Mumbai and mainnet Polygon get the config from:
// https://github.com/rally-dfs/rly-network-flutter-sdk/blob/main/lib/network.dart
Parameters:
  • erc20TokenAddress: Token contract address

getExactBalance

Get the balance of the crypto account for a specified token as an integer string number of wei.
React Native
Flutter
import {
RlyMumbaiNetwork,
getAccount,
} from '@rly-network/mobile-sdk';
// get current account
const account = await getAccount();
// token contract address
const erc20TokenAddress = '0x...';
//get balance
const balance = await RlyMumbaiNetwork.getExactBalance(erc20TokenAddress);
import 'package:rly_network_flutter_sdk/network.dart';
final tokenAddress = "0x...." //hex address of token contract.
// get balance of any ERC20 token on Mumbai testnet
await rlyMumbaiNetwork.getExactBalance(tokenAddress);
// to switch networks between Mumbai and mainnet Polygon get the config from:
// https://github.com/rally-dfs/rly-network-flutter-sdk/blob/main/lib/network.dart

getAccountPhrase

Get the seed phrase for the private key
React native
Flutter
import { getAccountPhrase } from '@rly-network/mobile-sdk';
const mnemonic = await getAccountPhrase();
import 'package:rly_network_flutter_sdk/wallet_manager.dart';
final mnemonic = WalletManager.getInstance().getAccountPhrase();

importExistingAccount

Import a mnemonic string of an existing account and store it on the user's device
React Native
Flutter
import { importExistingAccount } from '@rly-network/mobile-sdk';
const existingMnemonic = 'huge remain palm vanish ...';
const walletAddress = await importExistingAccount(existingMnemonic);
Coming soon

transfer

Transfer supported tokens gaslessly
React Native
Flutter
import { RlyMumbaiNetwork } from '@rly-network/mobile-sdk';
// token contract address
const erc20TokenAddress = '0x...';
// recipient address
const to = "0x..."
//transfer 5 tokens
await RlyMumbaiNetwork.transfer(
to,
5.0,
erc20TokenAddress
);
import 'package:rly_network_flutter_sdk/network.dart';
//get mumbai config for rally protocol sdk
final mumbai = rlyMumbaiNetwork;
// transfer an ERC20 token using ExecuteMetaTransaction, see supported tokens in the next section
await mumbai.transfer(
transferAddress,
double.parse(1),
MetaTxMethod.ExecuteMetaTransaction
);
// transfer an ERC20 token using Permit, see supported tokens in the next section
await mumbai.transfer(
transferAddress,
double.parse(1),
MetaTxMethod.Permit
);
Parameters:
  • to: Recipient address
  • Value: Number of tokens to send as a floating point number
  • erc20TokenAddress: Token contract address

transferExact

Transfer supported tokens gaslessly using an integer string exact number of tokens in wei.
React Native
Flutter
import { RlyMumbaiNetwork } from '@rly-network/mobile-sdk';
// token contract address
const erc20TokenAddress = '0x...';
// recipient address
const to = "0x..."
//transfer 5 tokens
await RlyMumbaiNetwork.transferExact(
to,
"5000000000000000000",
erc20TokenAddress
);
import 'package:rly_network_flutter_sdk/network.dart';
//get mumbai config for rally protocol sdk
final mumbai = rlyMumbaiNetwork;
// transfer an ERC20 token using ExecuteMetaTransaction, see supported tokens in the next section
await mumbai.transfer(
transferAddress,
BigInt.parse(1),
MetaTxMethod.ExecuteMetaTransaction
);
// transfer an ERC20 token using Permit, see supported tokens in the next section
await mumbai.transfer(
transferAddress,
BigInt.parse(1),
MetaTxMethod.Permit
);
Parameters
  • to: Recipient address
  • Value: Number of tokens to send as a big integer string number of wei
  • erc20TokenAddress: Token contract address

transfer specifying meta transaction method

Transfer supported tokens gaslessly
React Native
Flutter
import { RlyMumbaiNetwork,
MetTxMethod,
} from '@rly-network/mobile-sdk';
// token contract address
const erc20TokenAddress = '0x...';
// recipient address
const to = "0x..."
//transfer 5 tokens using the Permit method
await RlyMumbaiNetwork.transfer(
to,
5.0,
erc20TokenAddress,
MetaTxMethod.Permit
);
//transfer 5 tokens using the ExecuteMetaTransaction method
await RlyMumbaiNetwork.transfer(
to,
5.0,
erc20TokenAddress,
MetaTxMethod.ExecuteMetaTransaction
);
import 'package:rly_network_flutter_sdk/network.dart';
//get mumbai config for rally protocol sdk
final mumbai = rlyMumbaiNetwork;
// transfer an ERC20 token using ExecuteMetaTransaction, see supported tokens in the next section
await mumbai.transfer(
transferAddress,
double.parse(1),
MetaTxMethod.ExecuteMetaTransaction
);
// transfer an ERC20 token using Permit, see supported tokens in the next section
await mumbai.transfer(
transferAddress,
double.parse(1),
MetaTxMethod.Permit
);
Objects:
  • MetaTxMethod:
    • Permit
    • ExecuteMetaTransaction
Parameters:
  • to: Recipient address
  • Value: Number of tokens to send as a floating point number
  • erc20TokenAddress: Token contract address

relay

Relay a transaction from your custom contract gaslessly
React Native
Flutter
import { RlyMumbaiNetwork } from 'rly-network-mobile-sdk';
Import ethers from 'ethers';
....
//get web3 provider
const provider = new ethers.providers.JsonRpcProvider(providerUrl);
//get instance of your contract
const myContract = new ethers.Contract(contractAddress, contractAbi, signer);
//populate raw transaction object
const tx = await myContract.populateTransaction.myMethod.(
param1,
param2
);
// get gas estimate for transaction
const gas = await myContract.estimateGas.myMethod.(param1, param2);
// get current network fee data
const { maxFeePerGas, maxPriorityFeePerGas } = await provider.getFeeData();
//create relay tx object
const gsnTx = {
from: account.address,
data: tx.data,
to: tx.to,
gas: gas._hex,
maxFeePerGas: maxFeePerGas._hex,
maxPriorityFeePerGas: maxPriorityFeePerGas._hex,
} as GsnTransactionDetails;
// relay transaction
await RlyMumbaiNetwork.relay(gsnTx);
// relay arbitrary tx through our gasless relayer. see complete example at
// https://github.com/rally-dfs/flutter-example-app/tree/main/app/lib/services/nft.dart
...
final gsnTx = GsnTransactionDetails(
from: accountAddress,
data: tx.data,
value: "0",
to: contractAddress,
gas: gas.toString(),
maxFeePerGas: maxFeePerGas.toString(),
maxPriorityFeePerGas: maxPriorityFeePerGas.toString(),
);
await mumbai.relay(gsnTx)
Parameters:
  • gxnTx