@realmint/sdk
v0.3.0
Published
TypeScript SDK for the Realmint API — list, buy, and sell tokenized RWAs (non-custodial; the partner's signer signs).
Maintainers
Readme
@realmint/sdk
TypeScript SDK for the Realmint API — list, buy, sell, and withdraw tokenized real-world assets. Non-custodial: you inject the signer, the SDK never holds keys. Gas is sponsored in USDC (no native gas needed), and funding is over x402.
npm install @realmint/sdkYou bring your own EVM signer (viem account or an EIP-1193 provider). For Solana
sells you also bring a Solana signer. Node 18+ (native fetch).
Quick start
import { RealmintClient, signerFromViemAccount } from "@realmint/sdk";
import { privateKeyToAccount } from "viem/accounts";
const client = new RealmintClient({ apiKey: process.env.REALMINT_API_KEY! });
// The user's EVM account (the partner manages this key, not Realmint).
const account = privateKeyToAccount(userPrivateKey);
const sign = signerFromViemAccount(account);List
const assets = await client.listAssets({ roots: true });
const paxg = await client.getAsset("paxg");
const score = await client.getScore("paxg");
const venues = await client.getRouteSupport("paxg");
const holdings = await client.getPortfolio(account.address);Buy
buy() runs the whole lifecycle: create → prepare → sign the UserOp →
submit to the bundler → execute → poll to completion. The user's smart account
must already hold USDC (fund it with fundWithX402 first).
const intent = await client.buy(
{
asset_id: "paxg",
source_token: "USDC",
amount_in: 100, // 100 USDC
agent_wallet: account.address,
},
sign,
);
console.log(intent.status); // "completed"Sell
EVM-deployed assets sell with zero signatures (the protocol executes the swap via a session key):
const sold = await client.sellEvm({
asset_id: "paxg",
source_token: "USDC",
amount_in: 0.05, // asset quantity to sell
agent_wallet: account.address,
});Solana-deployed assets take one Solana signature on the prepared wire:
import { SignSolanaWire } from "@realmint/sdk";
const signWire: SignSolanaWire = async (wireBase64) => {
// co-sign the base64 V0 transaction with the user's Solana key, return base64
};
const sold = await client.sellSolana(
{ asset_id: "tslax", source_token: "USDC", amount_in: 1, agent_wallet: account.address },
signWire,
);Withdraw / send
Move funds out of your smart account to any address — gasless (paymaster-sponsored),
one UserOp signature (same signer as buy). Works for both the keyless agent
identity and Privy human identity.
const res = await client.withdraw(
{
chain_id: 1776, // Injective
owner_eoa: account.address,
token_address: "0xa00C59fF5a080D2b954d0c75e46E22a0c371235a", // native USDC
recipient: "0x…",
amount_raw: "4800000", // 4.8 USDC (6 decimals)
},
signUserOpHash,
);
// res.mode === "bundler", res.user_op_hash setFund with x402
import { fundWithX402 } from "@realmint/sdk";
await fundWithX402(
client,
{ owner_eoa: account.address, amount_usdc: 100 },
async (paymentRequirements) => {
// settle the requirements with your x402 client (e.g. the Coinbase x402 SDK
// with a viem account on Base) and return the encoded X-PAYMENT header value
},
);
// USDC is bridged to the user's Injective smart account, ready for buy().Keyless agent auth
An autonomous agent holding only its own EVM key can authenticate without an API
key: agentLogin exchanges an EOA signature for a bearer and returns a ready
client.
import { agentLogin, fundWithX402, signerFromViemAccount } from "@realmint/sdk";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY!);
const { client } = await agentLogin({
ownerEoa: account.address,
signMessage: (m) => account.signMessage({ message: m }),
});
await fundWithX402(client, { owner_eoa: account.address, amount_usdc: 5, asset_id: "tslax" }, payX402);
await client.buy(
{ asset_id: "tslax", source_token: "USDC", amount_in: 5, agent_wallet: account.address },
signerFromViemAccount(account),
);The bearer only authorizes quoting/creating intents for the EOA's own smart accounts; moving funds still requires the EOA's UserOp signature. See the reference agent.
Signing model
buy() signs an ERC-4337 UserOp v0.7 digest as an EIP-191 personal_sign
over the 32-byte hash — that's what signerFromViemAccount /
signerFromEip1193 produce. Don't use an EIP-712 typed sign or a raw ECDSA
sign; the smart account validates the personal_sign form.
Lower-level methods (accountStatus, createIntent, prepareIntent,
executeIntent, getIntent, reconcileIntent, waitForSettlement,
submitUserOp) are exposed if you need to drive the lifecycle yourself.
See the full API reference at https://api.realmint.io/docs.
