Skip to main content
Get your API key at hackathon-apikey.vercel.app.

Read balances

const { balances } = await unlink.getBalances();
Filter by token:
const { balances } = await unlink.getBalances({ token: "0xTokenAddress" });

Read transactions

const { transactions } = await unlink.getTransactions({
  status: "processed",   // optional
  type: "transfer",      // optional: "deposit" | "transfer" | "withdraw" | "execute"
  limit: 20,             // optional
  cursor: "...",         // optional, for pagination
});

Poll transaction status

Poll until a transaction reaches a terminal state (relayed, processed, or failed).
const result = await unlink.pollTransactionStatus(txId, {
  intervalMs: 2000,   // optional, default 2s
  timeoutMs: 60000,   // optional, default 60s
});
Throws if the timeout is reached before a terminal status.

Get address

Get the Unlink address (Bech32m) for this account.
const address = await unlink.getAddress();
// "unlink1..."

Get public key

Get the spending public key (EdDSA on BabyJubJub).
const [x, y] = await unlink.getPublicKey();

Register user

Explicitly register the user with Unlink. Called automatically on first operation (deposit, transfer, withdraw, execute, or requestPrivateTokens), but can be called manually.
await unlink.ensureRegistered();

Error handling

import { UnlinkApiError, UnlinkCapabilityError } from "@unlink-xyz/sdk";

try {
  await unlink.deposit({ token, amount });
} catch (err) {
  if (err instanceof UnlinkApiError) {
    // Unlink returned an error
    console.error(err.code, err.message);
  }
  if (err instanceof UnlinkCapabilityError) {
    // Missing EVM provider capability (e.g. no sendTransaction)
    console.error(err.message);
  }
}