Wallet Service
The WalletService
class in MessageKit provides a way to create agent wallets that can perform gasless payments and transfers in USDC.
- Gasless
- Onramp
- Offramp
- Swaps
- Transfers
Wallet Management
The getWallet
method will retrieve an existing wallet or create a new one if it doesn't exist:
// Get the wallet service
const { walletService } = context;
// Get or create a wallet
const wallet = await walletService.getWallet(identifier or address);
// Explicitly create a new wallet
const isCreated = await walletService.createWallet(identifier or address);
// Delete a wallet
await walletService.deleteWallet(identifier or address);
Actions
Perform actions on the Agent Wallet like transfers and swaps or checking the balance.
// Get the wallet service
const { walletService } = context;
// Check balance
const { address, balance } = await walletService.checkBalance(identifier or address);
// Transfer between wallets
await walletService.transfer(identifier or address, identifier or address, amount);
// Swap assets (USDC and ETH)
await walletService.swap(identifier or address, fromAssetId, toAssetId, amount);
Plugins
Currently messagekit supports Circle and CDP SDKs. Depending on your .env
variables, the wallet service will use the correct SDK.