Skip to main content
Register a managed account, deposit USDC on one chain, and receive it on another — all through a few API calls.

Prerequisites

  • A Rhinestone API key
  • A wallet with testnet USDC on Optimism Sepolia (Circle faucet)
1

Configure your client

Set up gas sponsorship so deposit bridging is covered. This is a one-time call per API key.
const DEPOSIT_SERVICE_URL =
  "https://v1.orchestrator.rhinestone.dev/deposit-processor";
const API_KEY = "YOUR_RHINESTONE_API_KEY";

const response = await fetch(`${DEPOSIT_SERVICE_URL}/setup`, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "x-api-key": API_KEY,
  },
  body: JSON.stringify({
    params: {
      sponsorship: {
        "eip155:84532": { gas: "all" }, // Base Sepolia
        "eip155:11155420": { gas: "all" }, // Optimism Sepolia
      },
    },
  }),
});

console.log(`Setup: ${response.status}`);
You should see Setup: 200.
2

Register a managed account

Register a server-managed account with a target chain and token. The service creates a smart account deterministically from your API key and the salt you provide, and returns deposit addresses.
import { keccak256, toHex } from "viem";

// Use any unique identifier per user (e.g., internal user ID)
const salt = keccak256(toHex("user-123"));

const RECIPIENT = "0xYOUR_RECIPIENT_ADDRESS";
const TARGET_CHAIN = "eip155:84532"; // Base Sepolia
const TARGET_TOKEN = "0x036CbD53842c5426634e7929541eC2318f3dCF7e"; // USDC on Base Sepolia

const registerResponse = await fetch(
  `${DEPOSIT_SERVICE_URL}/register-managed`,
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "x-api-key": API_KEY,
    },
    body: JSON.stringify({
      account: {
        salt,
        target: {
          chain: TARGET_CHAIN,
          token: TARGET_TOKEN,
          recipient: RECIPIENT,
        },
      },
    }),
  },
);

const { evmDepositAddress, solanaDepositAddress } =
  await registerResponse.json();
console.log(`EVM deposit address: ${evmDepositAddress}`);
console.log(`Solana deposit address: ${solanaDepositAddress}`);
You should see two deposit addresses printed. The evmDepositAddress is where users send tokens on any supported EVM chain.
3

Verify registration

const check = await fetch(`${DEPOSIT_SERVICE_URL}/check/${evmDepositAddress}`);
const checkData = await check.json();
console.log(checkData);
You should see:
{
  "isRegistered": true,
  "targetChain": "eip155:84532",
  "targetToken": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
  "sourceChains": ["eip155:84532", "eip155:11155420", "eip155:421614"]
}
4

Deposit tokens

Transfer USDC to the deposit address on Optimism Sepolia. The deposit service detects it and bridges it to Base Sepolia automatically.
import {
  createWalletClient,
  http,
  encodeFunctionData,
  erc20Abi,
  parseUnits,
} from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { optimismSepolia } from "viem/chains";

const funder = privateKeyToAccount("0xYOUR_FUNDING_KEY");
const walletClient = createWalletClient({
  account: funder,
  chain: optimismSepolia,
  transport: http(),
});

// USDC on Optimism Sepolia
const USDC = "0x5fd84259d66Cd46123540766Be93DFE6D43130D7";

const txHash = await walletClient.sendTransaction({
  to: USDC,
  data: encodeFunctionData({
    abi: erc20Abi,
    functionName: "transfer",
    args: [evmDepositAddress, parseUnits("1", 6)],
  }),
});

console.log(`Deposit tx: ${txHash}`);
5

Check deposit status

Poll the deposits endpoint to track the bridging progress.
const deposits = await fetch(
  `${DEPOSIT_SERVICE_URL}/deposits?account=${evmDepositAddress}`,
  {
    headers: { "x-api-key": API_KEY },
  },
);
const data = await deposits.json();
console.log(data);
Once bridging completes, the deposit status changes to completed and includes the destination transaction hash. The USDC is now at the recipient address on Base Sepolia.

Next steps

Initial setup

Webhooks, sponsorship rules, and deposit whitelists.

Account registration

User-owned accounts, session configuration, and output token rules.

Deposit processing

Deposit lifecycle, retries, and status tracking.

Webhooks

Event types, payload format, and HMAC verification.