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

Network

Unlink is live on Base Sepolia.
ResourceValue
NetworkBase Sepolia
Chain ID84532
API URLhttps://staging-api.unlink.xyz
Pool Address0x647f9b99af97e4b79DD9Dd6de3b583236352f482

Faucet

Get testnet tokens for development.

Base Sepolia faucet

Get testnet ETH for gas.

Prerequisites

Make sure you have:
  • Node.js v18 or later
  • A package manager (npm, pnpm, yarn, or bun)
  • A TypeScript project
mkdir my-app && cd my-app
npm init -y
npm install typescript tsx
1

Install

npm install @unlink-xyz/sdk viem
2

Create a client

createUnlink() returns a client bound to one Unlink account. Every operation (deposit, transfer, withdraw) acts on behalf of that account.
Use a private key and viem for backends, scripts, bots, or AI agents. In a multi-user setup, instantiate one client per user request.
import { createUnlink, unlinkAccount, unlinkEvm } from "@unlink-xyz/sdk";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { baseSepolia } from "viem/chains";

const evmAccount = privateKeyToAccount(
  process.env.EVM_PRIVATE_KEY as `0x${string}`,
);

const walletClient = createWalletClient({
  account: evmAccount,
  chain: baseSepolia,
  transport: http(process.env.RPC_URL),
});

const unlink = createUnlink({
  engineUrl: "https://staging-api.unlink.xyz",
  apiKey: process.env.UNLINK_API_KEY!,
  // BIP-39 mnemonic that derives the user's Unlink account keys.
  // Generate one with: npx @scure/bip39 or any BIP-39 library.
  // A different mnemonic produces a different Unlink account.
  account: unlinkAccount.fromMnemonic({
    mnemonic: process.env.UNLINK_MNEMONIC!,
  }),
  evm: unlinkEvm.fromViem({ walletClient }),
});
Use unlinkAccount.fromSeed(...) or unlinkAccount.fromKeys(...) when you already manage seed material or raw account keys outside the SDK.What each piece does:
ConceptRole
createWalletClient (viem) / BrowserProvider (ethers)Standard EVM wallet — signs on-chain transactions (deposits, approvals). Not Unlink-specific.
unlinkAccount.fromMnemonic()Derives your Unlink account (private spending & viewing keys) from a BIP-39 mnemonic. A different mnemonic = a different Unlink identity.
unlinkEvm.fromViem() / unlinkEvm.fromEthers()Bridges your EVM wallet into the SDK so Unlink can submit on-chain transactions on your behalf.
createUnlink()Combines everything into a single client. Every SDK operation goes through this client.
3

Get your Unlink address

Your Unlink address (unlink1...) is your identity inside the privacy pool. Share it to receive private transfers — it does not reveal your EVM wallet.
const address = await unlink.getAddress();
console.log(address); // "unlink1..."
This address is deterministically derived from your mnemonic. The same mnemonic always produces the same address.
4

Get test tokens

Fund your Unlink account directly via the faucet. No EVM approval or gas needed.
const seeded = await unlink.faucet.requestPrivateTokens({
  token: "0x7501de8ea37a21e20e6e65947d2ecab0e9f061a7",
});
You can verify the balance arrived:
const { balances } = await unlink.getBalances();
console.log(balances);
See Faucet for other options like minting public ERC-20 tokens to an EVM wallet.
5

Transfer

Send tokens privately to another Unlink address. pollTransactionStatus polls until the transaction reaches a terminal state; see Utilities for options.
const transfer = await unlink.transfer({
  recipientAddress: "unlink1recipient...",
  token: "0x7501de8ea37a21e20e6e65947d2ecab0e9f061a7",
  amount: "250000000000000000",
});

const confirmed = await unlink.pollTransactionStatus(transfer.txId);
See Transfer for multi-recipient transfers.
6

Withdraw

Move tokens back to any EVM address:
const withdrawal = await unlink.withdraw({
  recipientEvmAddress: "0xRecipient",
  token: "0x7501de8ea37a21e20e6e65947d2ecab0e9f061a7",
  amount: "500000000000000000",
});

const confirmed = await unlink.pollTransactionStatus(withdrawal.txId);
See Withdraw for all parameters.

Going further

Deposit from an EVM wallet

To move ERC-20 tokens from an on-chain wallet into the unlink contract, use deposit(). This requires a one-time Permit2 approval per token and an EVM provider with publicClient for receipt polling.
import { createPublicClient, http } from "viem";
import { baseSepolia } from "viem/chains";

const publicClient = createPublicClient({
  chain: baseSepolia,
  transport: http(process.env.RPC_URL),
});

const approval = await unlink.ensureErc20Approval({
  token: "0x7501de8ea37a21e20e6e65947d2ecab0e9f061a7",
  amount: "1000000000000000000",
});

if (approval.status === "submitted") {
  await publicClient.waitForTransactionReceipt({
    hash: approval.txHash as `0x${string}`,
  });
}

const deposit = await unlink.deposit({
  token: "0x7501de8ea37a21e20e6e65947d2ecab0e9f061a7",
  amount: "1000000000000000000",
});

const confirmed = await unlink.pollTransactionStatus(deposit.txId);
See Deposit for the full parameter reference, approval helpers, and EVM provider setup.