Ukiyo NetworkDeveloper Docs
Developer Guides

SDK Integration

Use the TypeScript SDK to verify scores, watch registries, and prepare allowlisted transactions.

Install

npm install @ukiyo/sdk viem

Verify a score

import { createPublicClient, http } from 'viem'
import { arbitrum } from 'viem/chains'
import { verifyScore, fetchLatestScore } from '@ukiyo/sdk'

const client = createPublicClient({ chain: arbitrum, transport: http(process.env.ARB_RPC_URL) })

const score = await fetchLatestScore(client, {
  registry: process.env.SCORE_REGISTRY,
  orderId: '0x…',
})

const ok = await verifyScore({
  score,
  signature: score.signature,
  authorizedOracle: process.env.ORACLE_SIGNER,
  domain: { name: 'UkiyoFulfillmentOracle', version: '1', chainId: 42161 },
  maxAgeSec: 300,
})

if (!ok) throw new Error('stale or unauthorized score')

Prepare an allowlisted action

import { prepareAdvance } from '@ukiyo/sdk'

const tx = await prepareAdvance({
  orderId: '0x…',
  amount: 1_000_000n, // stablecoin base units
  policyEngine: process.env.POLICY_ENGINE,
  spool: process.env.SPOOL,
})

// Simulate via agency first; only then sign/send with the execution key vault.
Do not

Do not send unbounded admin transactions from application wallets. Route mutating calls through the policy engine and simulation gate.

Error codes you should handle

CodeMeaning
SCORE_MISSINGNo publication for order — fail closed
SCORE_STALEOutside freshness window
SELECTOR_NOT_ALLOWEDPolicy engine rejected calldata
VALUE_EXCEEDS_LIMITPer-call value bound exceeded
SIMULATION_FAILEDFork dry-run reverted or diff out of bounds