TypeScript SDK for interacting with the Setra settlement protocol — the canonical settlement layer for tokenized equities on Robinhood Chain.
npm install @setra/sdk viemimport { createSetraClient, buildDVPIntent, formatUSDC } from "@setra/sdk";
// Initialize client
const client = createSetraClient({
chainId: 278611,
rpcUrl: "https://rpc.robinhoodchain.com",
privateKey: "0x...",
});
// Build a DVP intent
const intent = client.buildIntent({
seller: "0xSeller...",
buyer: "0xBuyer...",
token: "0xsAAPL...",
amount: 100n, // 100 sAAPL tokens
payment: 15_000_000n, // 15.00 USDC
deadline: 1717200000n,
nonce: 0n,
});
// Sign the intent (as seller)
const sellerSig = await client.signIntent(intent);
// After collecting buyer signature, settle on-chain
const signed = client.createSignedIntent(intent, sellerSig, buyerSig);
const result = await client.settle(signed);
console.log(`Settled in block ${result.blockNumber}`);Create a new SDK client instance.
const client = createSetraClient({
chainId: 278611, // Robinhood Chain
rpcUrl: "https://rpc.robinhoodchain.com",
privateKey: "0x...", // Optional - needed for signing/settling
dvpEngineAddress: "0x...", // Optional override
registryAddress: "0x...", // Optional override
nettingAddress: "0x...", // Optional override
});| Method | Description |
|---|---|
client.buildIntent(params) |
Build a DVP intent with auto-computed hash |
client.buildBatch(intents, deadline) |
Build a batch from multiple intents |
client.computeHash(intent) |
Compute an intent's deterministic hash |
buildDVPIntent(params) |
Standalone intent builder |
buildBatchIntent(intents, deadline) |
Standalone batch builder |
computeIntentHash(intent) |
Standalone hash computation |
| Method | Description |
|---|---|
client.signIntent(intent) |
Sign an intent with EIP-712 |
client.createSignedIntent(intent, sellerSig, buyerSig) |
Bundle signatures |
signIntent(walletClient, intent) |
Standalone signer using any viem wallet |
verifyIntentSignature(sig, intent, signer) |
Basic signature verification |
| Method | Description |
|---|---|
client.settle(signedIntent) |
Settle a single DVP intent |
client.settleBatch(signedIntents) |
Settle a batch atomically |
client.isSettled(intentId) |
Check if an intent is settled |
client.getNonce(address) |
Get current nonce for replay protection |
client.domainSeparator() |
Get the EIP-712 domain separator |
| Method | Description |
|---|---|
client.getAsset(token) |
Get asset info (ISIN, CUSIP, etc.) |
client.getTokenByISIN(isin) |
Look up token by ISIN code |
client.isRegistered(token) |
Check if asset is registered |
client.totalAssets() |
Get count of registered assets |
| Method | Description |
|---|---|
client.getNettingPosition(epoch, participant) |
Get net position |
client.getCurrentEpoch() |
Get current netting epoch |
client.isEpochFinalized(epoch) |
Check epoch finalization |
import {
formatUSDC,
parseUSDC,
formatAmount,
parseAmount,
isValidAddress,
shortenAddress,
nowSeconds,
deadlineFromTTL,
} from "@setra/sdk";
formatUSDC(15_000_000n); // "15"
parseUSDC("15"); // 15000000n
shortenAddress("0x1234...5678"); // "0x1234...5678"
deadlineFromTTL(86400); // now + 24h as bigintAll contract ABIs are exported for direct use with viem:
import { dvpEngineAbi, sEquityAbi, registryAbi, nettingAbi } from "@setra/sdk";import { robinhoodChain, robinhoodTestnet } from "@setra/sdk";
import { createPublicClient, http } from "viem";
const client = createPublicClient({
chain: robinhoodChain,
transport: http(),
});import {
CHAIN_ID, // 278611
CONTRACT_ADDRESSES, // { DVP_ENGINE, REGISTRY, NETTING, USDC, TIMELOCK }
EIP712_DOMAIN, // EIP-712 domain config
EIP712_TYPES, // EIP-712 type definitions
MAX_BATCH_SIZE, // 64
FINALITY_BLOCKS, // 12
DEFAULT_INTENT_TTL, // 86400 (24h)
} from "@setra/sdk";The SDK provides typed error classes:
import {
SetraError,
IntentExpiredError,
InvalidSignatureError,
BatchSizeError,
AssetNotRegisteredError,
AlreadySettledError,
} from "@setra/sdk";
try {
await client.settle(signedIntent);
} catch (err) {
if (err instanceof AlreadySettledError) {
console.log(`Intent ${err.intentId} was already settled`);
}
}MIT