Interactive Playground
Test pools, quotes, premium preview, and referral flow snippets with @layercover/sdk
Use this playground to test discovery and pricing with the SDK in read-only mode (no wallet connection required).
This page is intentionally read-only. It does not execute purchases. Use the copyable purchase snippet in your product UI where users connect their own wallet.
What You Can Test
- Initialize
LayerCoverSDK.create(...)with a public RPC provider - Discover pools and fetch active quotes
- Preview premium calculations for amount + duration
- Attach a referral code for partner attribution
- Copy a production purchase snippet for your embedded flow
SDK Playground (Read-Only)
No login requiredMode: read-only discovery and quote preview (API proxied via this docs server)
Upstream API: https://app.layercover.com
Status: Initialize read-only SDK to begin (no wallet needed).
Loaded quotes: 0
Quotes
Load a pool to view quotes.
Purchase Inputs
Referral not set
Purchase execution is intentionally disabled in this docs playground. Use the copied snippet in your app where users connect their own wallet.
Code Snippets (Copy/Paste)
Initialize Read-Only SDK
import { JsonRpcProvider } from 'ethers';
import { LayerCoverSDK } from '@layercover/sdk';
const provider = new JsonRpcProvider('https://sepolia.base.org');
const sdk = await LayerCoverSDK.create(provider, {
apiBaseUrl: 'https://app.layercover.com',
});
const pools = await sdk.listPools();Load Active Quotes
const poolId = 1;
const quotes = await sdk.getActiveQuotes(poolId);
const bestQuote = quotes[0] ?? null;
if (!bestQuote) {
throw new Error('No active quotes for this pool');
}Preview Premium
import { parseUnits, formatUnits } from 'ethers';
const amount = parseUnits('1000', 6);
const weeks = 4;
const durationSeconds = weeks * 7 * 24 * 60 * 60;
const premium = sdk.calculatePremium(
amount,
500,
durationSeconds
);
console.log('Premium:', formatUnits(premium, 6), 'USDC');Purchase Flow (Embed In Your App)
import { encodeBytes32String, parseUnits } from 'ethers';
function normalizeReferralCode(value) {
if (!value) return undefined;
if (/^0x[a-fA-F0-9]{64}$/.test(value)) return value.toLowerCase();
return encodeBytes32String(value);
}
const poolId = 1;
const amount = parseUnits('1000', 6);
const weeks = 4;
const maxRateBps = 500;
const referralInput = '';
const referralCode = normalizeReferralCode(referralInput);
const result = await sdk.purchase(poolId, amount, weeks, maxRateBps, referralCode);
console.log('tx:', result.txHash, 'policy:', result.policyId);Recommended Setup
- Use a Base Sepolia RPC URL (default:
https://sepolia.base.org) - Select a pool with active quotes for realistic results
- Ensure your docs app can reach
https://app.layercover.comfrom server-side proxy routes