Getting Started with the Universal SDK
The Universal SDK handles quote requests, signing, and order submission. Viem-compatible, fully typed.
The Universal SDK is a TypeScript library that simplifies API integration. It handles quote requests, EIP-712 signing, and order submission.
Install
npm install universal-sdk viemQuick start
import { UniversalRelayerSDK, generateTypedData } from "universal-sdk";
import { privateKeyToAccount } from "viem/accounts";
import { parseUnits } from "viem";
const universal = new UniversalRelayerSDK();
const account = privateKeyToAccount(process.env.PRIVATE_KEY);
// Get quote
const quote = await universal.getQuote({
type: "BUY",
token: "BTC",
pair_token: "USDC",
blockchain: "BASE",
slippage_bips: 20,
user_address: account.address,
pair_token_amount: parseUnits("100", 6).toString(),
});
// Sign and submit
const { typedData } = await generateTypedData(quote);
const signature = await account.signTypedData(typedData);
const result = await universal.submitOrder({ ...quote, signature });
console.log("Transaction:", result.transaction_hash);Key methods
getQuote() - Request a price quote from the API
generateTypedData() - Generate EIP-712 typed data for signing
submitOrder() - Submit a signed order for execution
With referral fees
const quote = await universal.getQuote({
type: "BUY",
token: "SOL",
pair_token: "USDC",
blockchain: "BASE",
slippage_bips: 20,
user_address: account.address,
pair_token_amount: parseUnits("50", 6).toString(),
referrer_address: "0x...",
referrer_bps: "10",
});Full documentation
Read the complete SDK reference
Support
Email dev@universal.xyz or join Discord
Introducing the Universal V4 Hook
The most capital-efficient way to enable trading of wrapped assets on your app. Atomic swaps via Uniswap V4.
Integrate the Universal API
Add 80+ cross-chain assets to your app. The Universal API provides just-in-time liquidity via an RFQ system.
Universal Protocol Architecture
A technical overview of Universal: uAssets, Merchants, Coinbase Prime custody, and the just-in-time liquidity model.