Skip to main content
Subscriptions are synchronous wallet transactions. The shareholder approves the vault to spend USDC, then deposits USDC and receives ERC-20 MicroVault shares.

Prerequisites

  • An active MicroVault and its contract address
  • A shareholder wallet connected to Ethereum Sepolia (chainId: 11155111)
  • Sepolia USDC in that wallet
  • An active shareholder proof
  • A Viem publicClient and walletClient
Fetch the proof immediately before constructing the wallet transaction.

1. Fetch the shareholder proof

A 404 means the wallet is not yet on the active allowlist. Complete shareholder approval before enabling the subscribe action.

2. Define the required contract calls

3. Approve USDC

Convert the human amount using the base asset’s decimals. USDC uses six decimals.
Skip this transaction only when the existing allowance is at least assets.

4. Submit the subscription

Quote the expected shares immediately before submission and apply your minimum-output policy. This example permits up to 0.5% quote movement.
The example uses the connected wallet as both caller and share recipient, so the same proof is supplied twice. If they differ, fetch and supply an active proof for each address.

Confirm the subscription

After the receipt succeeds, refresh the vault detail and activity endpoints. The new subscription should appear in activity, totalAssetsUnits and idleAssetsUnits should include the deposit, and the wallet’s ERC-20 share balance should increase. The MicroVault contract address is also its share-token address. Compatible wallets can add it with wallet_watchAsset using the vault address, share symbol, and 18 decimals. If the USDC approval succeeds but the deposit fails, do not repeat the approval unless the allowance is insufficient. Re-fetch the active proof and share quote, then submit a new deposit transaction.