Aarc SDK
The Aarc SDK is a TypeScript library that makes it easy for developers to transfer assets from Externally Owned Accounts (EOA) to any destination address. It simplifies the asset transfer process by supporting various token standards, such as ERC20 and ERC721, and offering custom flows like batched transactions, gasless transactions, and paying gas fees with the same asset being moved. Additionally, it enables custom contract interaction within the same transaction using permit2(), allowing for direct swaps and bridge functionality.
Features of the SDK
- Batch transactions on EoA with Uniswap’s Permit2 contract.
- ERC20Permit support for streamlined token approvals.
- Gasless transactions using Relayers (EIP2771).
Prerequisites
- Node.js (v12.x or later)
- Basic understanding of Ethereum and smart contracts.
Installation
Install ethers.js and Aarc SDK using npm:
npm install ethers@5.7.2 aarc-sdk
Getting Started
Get the API Key
To use Aarc SDK, an API key is required. Fill out this form to get the API Key on your email instantly!
Initialise the SDK
Import and initialise the Aarc SDK in your project.
import { AarcSDK } from "aarc-sdk";
let aarcSDK = new AarcSDK({
rpcUrl: rpcUrl,
chainId: chainId,
apiKey: "YOUR_API_KEY",
});
Usage
Fetching token balances
Retrieve balances of all tokens in an EOA wallet:
let balances = await aarcSDK.fetchBalances(
eoaAddress: string,
fetchBalancesOnly: true,
tokenAddress: string[]
);
Moving Assets
Transfer tokens from EOA to any receiver wallet address:
await aarcSDK.executeMigration({
senderSigner: signer,
receiverAddress:'RECEIVER_WALLET_ADDRESS',
transferTokenDetails:
[
{
tokenAddress:TOKEN1_ADDRESS,
amount?:TOKEN1_AMOUNT,
tokenIds?: string[]
},
...
]
})
Output:
[
{
tokenAddress,
amount,
message,
txHash,
tokenId
},
...
]
Moving Assets without gas
Transfer tokens from EOA to any receiver wallet address without gas fees. Please note that we use Gelato Relayer to provide the gasless functionality. Please get the Gelato API Key to use the gasless functionality.
await aarcSDK.executeMigrationGasless({
senderSigner: signer,
receiverAddress:RECEIVER_WALLET_ADDRESS,
transferTokenDetails:
[
{
tokenAddress:TOKEN1_ADDRESS,
amount?:TOKEN1_AMOUNT,
tokenIds?: string[]
},
...
],
gelatoApiKey: GELATO_RELAYER_API_KEY
})
Output:
[
{
tokenAddress,
amount,
message,
txHash,
tokenId
},
...
]
Moving Native Tokens and Wallet Deployment
The following code snippet demonstrates a method to transfer native tokens while simultaneously deploying a wallet using the aarcSDK.
This code snippet illustrates a process to transfer native tokens and deploy a wallet concurrently using the aarcSDK. Essential parameters such as the owner's address (EOA_ADDRESS), the type of wallet to deploy (WALLET_TYPE), the signer (ethers.signer object), the receiver's wallet address (RECEIVER_WALLET_ADDRESS), an optional amount of tokens to transfer (amount), and an index for deploying multiple wallets under the same EOA (deploymentWalletIndex) are included.
NOTE
If the wallet corresponding to the provided owner address (EOA_ADDRESS) and index (deploymentWalletIndex) is already deployed, the deployment process will not occur, and only the token transfer will be executed.
import { WALLET_TYPE } from "aarc-sdk/dist/utils/AarcTypes";
await aarcSDK.transferNativeAndDeploy({
owner: EOA_ADDRESS,
walletType: WALLET_TYPE,
signer: signer,
receiverAddress: RECEIVER_WALLET_ADDRESS,
amount: BigNumber,
deploymentWalletIndex: 0
})
Smart Wallet Integration
The Aarc SDK seamlessly integrates with different smart wallets. It currently supports Safe and Biconomy smart wallets and will add more options in the future.
Safe smart wallet
Fetching Existing Safes:
Retrieve a list of all Safe smart wallets associated with the user's EOA:
const safes = await aarcSDK.getAllSafes(owner: string);
Creating a New Safe Wallet:
Generate a new Safe smart wallet. The address returned is a counterfactual address, and the wallet needs to be deployed later. Asset migration can be directed to this address even before deployment.
const newSafeAddress = await aarcSDK.generateSafeSCW(
config: {owners: string[], threshold: number},
saltNonce?: number
);
Biconomy Smart Wallet
Fetching Biconomy Smart Wallets:
Retrieve a list of all Biconomy smart wallets associated with the user's EOA:
const biconomySWs = await aarcSDK.getAllBiconomySCWs(owner: string);
Creating a New Biconomy Wallet:
Similar to the Safe wallet, you can create a Biconomy smart wallet. The address provided is also a counterfactual address, requiring later deployment. The migration process can target this address immediately.
const newBiconomySCWAddress = await aarcSDK.generateBiconomySCW(
signer
);
Wallet Deployment
You have the capability to deploy Biconomy or Safe wallets by utilizing the provided code snippets.
The code snippet below showcases how to deploy a wallet using the AarcSDK. It involves specifying essential parameters such as the owner's address (EOA_ADDRESS), the type of wallet to deploy (WALLET_TYPE.BICONOMY or WALLET_TYPE.SAFE), the signer (ethers.signer object), and an optional index for deploying multiple wallets under the same EOA.
NOTE
If the wallet corresponding to the provided owner address (EOA_ADDRESS) and index (deploymentWalletIndex) is already deployed, the deployment process will not occur.
import { WALLET_TYPE } from "aarc-sdk/dist/utils/AarcTypes";
await aarcSDK.deployWallet({
owner: EOA_ADDRESS,
walletType: WALLET_TYPE,
signer: signer,
deploymentWalletIndex: 0
})
More coming soon
License
This project is licensed under the MIT License - see the LICENSE for details.
Support and Feedback
For support or to share feedback, please schedule a call with us here. You can also share your ideas and feedback on our community forum.