SDK guide - `@concrete-xyz/sdk`
Level: Advanced · Based on the official Earn V2 SDK docs. Method names/versions can change - confirm at docs.concrete.xyz/Developers/SDK.
What it provides
Install
npm install @concrete-xyz/sdk
# vanilla usage also needs: npm install ethers
# React: import { useVault } from "@concrete-xyz/sdk/react"
# Wagmi: import { useVault, useVaultQuery } from "@concrete-xyz/sdk/wagmi"Prerequisites
| Need | Why |
|---|---|
| Vault address | Every call targets a specific vault contract. |
| Supported chain | The vault must live on one of the chains above. |
| Signer (writes only) | Approve/deposit/redeem. Reads need only a provider. |
Vanilla (ethers)
import { getVault } from "@concrete-xyz/sdk";
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider("https://ethereum-rpc.publicnode.com");
const vault = getVault("v1", "0xVaultAddress", 1, provider); // read-only
const details = await vault.getVaultDetails();
console.log(details.vaultAsset.symbol);Add a signer as the 5th argument for writes.
React & Wagmi
Sections in the official docs
Setup Configuration · Migrating from 1.x · Read Methods (e.g. balanceOf) · Write Methods (e.g. approve) · Decimals & Conversion Helpers · Examples · Troubleshooting & Error Handling. There is also a documented REST read for vault transparency: GET /v1/vault:transparency/stats (params: vault address + chain ID) returning totalPortfolioAssetsOffchainUsd, byAsset, byProtocol, byPlatform, timestamp (data ~24 h delayed).
Integration best practices
See examples/typescript/ for runnable-shape samples (not executed against a live chain by this repo's author).