Wallets & Transfers

Learn how to manage wallet addresses, check balances, and transfer crypto across chains.

Wallet Architecture

Each Sponge agent receives two wallets automatically:

  • One EVM wallet - Works across all EVM chains (Ethereum, Base, etc.)
  • One Solana wallet - Works on Solana mainnet and devnet

Address Reuse

Your EVM address is the same across all EVM chains. This means you can receive ETH on Ethereum and USDC on Base using the same address.

Getting Addresses

import { SpongeWallet } from "@spongewallet/sdk";
 
const wallet = await SpongeWallet.connect();
 
// Get all addresses
const addresses = await wallet.getAddresses();
 
console.log(addresses);
// {
//   evm: "0x1234567890abcdef1234567890abcdef12345678",
//   solana: "7nYBbHqfTMUFkJGzr4dcSZVqQFpNXkBMZJ7abcdefgh"
// }
 
// Get address for specific chain
const baseAddress = await wallet.getAddress("base");
const solanaAddress = await wallet.getAddress("solana");

Checking Balances

All Balances

const balances = await wallet.getBalances();
 
// Returns array of balances across all chains
// [
//   {
//     chain: "ethereum",
//     chainId: 1,
//     address: "0x...",
//     balance: "0.5",
//     symbol: "ETH",
//     usdValue: "1250.00"
//   },
//   {
//     chain: "base",
//     address: "0x...",
//     balance: "0.0",
//     symbol: "ETH",
//     usdValue: "0.00",
//     tokenBalances: [
//       {
//         symbol: "USDC",
//         balance: "100.0",
//         usdValue: "100.00"
//       }
//     ]
//   },
//   {
//     chain: "solana",
//     address: "7nYB...",
//     balance: "10.0",
//     symbol: "SOL",
//     usdValue: "450.00"
//   }
// ]

Single Chain Balance

const baseBalance = await wallet.getBalance("base");
 
console.log(baseBalance);
// {
//   chain: "base",
//   balance: "0.1",
//   symbol: "ETH",
//   usdValue: "250.00",
//   tokenBalances: [
//     { symbol: "USDC", balance: "100.0", usdValue: "100.00" }
//   ]
// }

Token Balances (Solana)

For Solana, you can discover all SPL tokens in your wallet:

const tokens = await wallet.getSolanaTokens();
 
// [
//   { mint: "EPjFWdd5...", symbol: "USDC", balance: "50.0" },
//   { mint: "So11111...", symbol: "SOL", balance: "10.0" }
// ]

Transfers

EVM Transfers (ETH, USDC)

// Transfer ETH on Ethereum
const tx = await wallet.transfer({
  chain: "ethereum",
  to: "0xRecipientAddress",
  amount: "0.1",
  currency: "ETH"
});
 
// Transfer USDC on Base
const usdcTx = await wallet.transfer({
  chain: "base",
  to: "0xRecipientAddress",
  amount: "50.0",
  currency: "USDC"
});
 
console.log(tx);
// {
//   id: "tx_123...",
//   hash: "0xabc...",
//   status: "confirmed",
//   explorerUrl: "https://etherscan.io/tx/0xabc..."
// }

Solana Transfers

// Transfer SOL
const solTx = await wallet.transfer({
  chain: "solana",
  to: "RecipientSolanaAddress",
  amount: "1.0",
  currency: "SOL"
});
 
// Transfer USDC on Solana
const solUsdcTx = await wallet.transfer({
  chain: "solana",
  to: "RecipientSolanaAddress",
  amount: "25.0",
  currency: "USDC"
});

Tempo Transfers (Testnet Only)

Tempo is a fast testnet with instant finality:

// Transfer pathUSD on Tempo (test keys only)
const tempoTx = await wallet.transfer({
  chain: "tempo",
  to: "0xRecipientAddress",
  amount: "100.0",
  currency: "pathUSD"
});

Swaps (Solana)

Swap tokens on Solana using Jupiter aggregator:

const swap = await wallet.swap({
  chain: "solana",
  fromToken: "SOL",
  toToken: "USDC",
  amount: "1.0",
  slippage: 0.5 // 0.5%
});
 
console.log(swap);
// {
//   id: "swap_123...",
//   signature: "5Uy...",
//   fromAmount: "1.0",
//   toAmount: "45.23",
//   status: "confirmed"
// }

Swap with Quote

Get a quote before executing:

// Get quote first
const quote = await wallet.getSwapQuote({
  chain: "solana",
  fromToken: "SOL",
  toToken: "USDC",
  amount: "1.0"
});
 
console.log(`1 SOL = ${quote.expectedOutput} USDC`);
console.log(`Price impact: ${quote.priceImpact}%`);
 
// Execute the swap
const swap = await wallet.executeSwap(quote);

Transaction History

const history = await wallet.getTransactionHistory({
  limit: 10,
  chain: "base" // optional filter
});
 
// [
//   {
//     id: "tx_123",
//     hash: "0x...",
//     chain: "base",
//     type: "transfer",
//     direction: "outgoing",
//     amount: "50.0",
//     symbol: "USDC",
//     to: "0x...",
//     status: "confirmed",
//     timestamp: "2024-01-15T10:30:00Z"
//   },
//   ...
// ]

Transaction Status

Check the status of a pending transaction:

// EVM transaction
const status = await wallet.getTransactionStatus({
  hash: "0xabc123...",
  chain: "base"
});
 
// Solana transaction
const solStatus = await wallet.getTransactionStatus({
  signature: "5UyZbK...",
  chain: "solana"
});
 
console.log(status);
// {
//   status: "confirmed",
//   confirmations: 12,
//   blockNumber: 12345678
// }

Request Funding

Request funds from the wallet owner (useful for AI agents that need to request budget):

const request = await wallet.requestFunding({
  chain: "base",
  amount: "100.0",
  currency: "USDC",
  reason: "Need funds for trading operations"
});
 
console.log(`Funding request created: ${request.id}`);
console.log(`Status: ${request.status}`); // "pending"

Withdraw to Main Wallet

Withdraw funds back to the owner's main wallet:

const withdrawal = await wallet.withdraw({
  chain: "base",
  amount: "50.0",
  currency: "USDC"
});

Error Handling

import { SpongeError, InsufficientFundsError, InvalidAddressError } from "@spongewallet/sdk";
 
try {
  await wallet.transfer({
    chain: "base",
    to: "0x...",
    amount: "1000.0",
    currency: "USDC"
  });
} catch (error) {
  if (error instanceof InsufficientFundsError) {
    console.log("Not enough funds:", error.available, error.required);
  } else if (error instanceof InvalidAddressError) {
    console.log("Invalid recipient address");
  } else if (error instanceof SpongeError) {
    console.log("Sponge error:", error.message);
  }
}

Next Steps

Was this page helpful? /