Installation
Arkiv provides an official TypeScript/JavaScript SDK — @arkiv-network/sdk — that works in Node.js, Bun, and the browser. It handles client creation, queries, mutations, event subscriptions, and payload encoding.
The SDK builds on viem and declares it as a peer dependency, so install viem alongside the SDK.
Install the SDK
Section titled “Install the SDK”npm install @arkiv-network/sdk viembun add @arkiv-network/sdk viemClient Setup
Section titled “Client Setup”WalletClient (read/write)
Section titled “WalletClient (read/write)”Requires a private key. Use for creating, updating, and deleting entities:
import { createWalletClient } from "@arkiv-network/sdk"import { braga } from "@arkiv-network/sdk/chains"import { http } from "viem"import { privateKeyToAccount } from "viem/accounts"
const walletClient = createWalletClient({ chain: braga, transport: http(), account: privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`),})PublicClient (read-only)
Section titled “PublicClient (read-only)”No private key needed. Use for queries — safe for frontend use:
import { createPublicClient } from "@arkiv-network/sdk"import { braga } from "@arkiv-network/sdk/chains"import { http } from "viem"
const publicClient = createPublicClient({ chain: braga, transport: http(),})Hello, World!
Section titled “Hello, World!”-
Create your project
Terminal window mkdir hello-arkiv && cd hello-arkivnpm init -ynpm pkg set type=modulenpm install @arkiv-network/sdk viem typescriptTerminal window mkdir hello-arkiv && cd hello-arkivbun init -ybun add @arkiv-network/sdk viem -
Add your private key
.env PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HEREArkiv chains use GLM as the native gas token. The Braga faucet went offline when Braga was retired on 12 August 2026 — see the Braga page for what’s next.
-
Write your first entity
hello.ts import { createWalletClient, createPublicClient } from '@arkiv-network/sdk';import { stringToPayload } from '@arkiv-network/sdk/utils';import { braga } from '@arkiv-network/sdk/chains';import { http } from 'viem';import { privateKeyToAccount } from 'viem/accounts';const walletClient = createWalletClient({chain: braga,transport: http(),account: privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`),});const publicClient = createPublicClient({chain: braga,transport: http(),});// Create an entityconst { entityKey, txHash } = await walletClient.createEntity({payload: stringToPayload('Hello, Arkiv!'),contentType: 'text/plain',attributes: [{ key: 'type', value: 'greeting' }],expiresIn: 3600,});console.log('Entity created:', entityKey);console.log('Transaction:', txHash);// Read it backconst entity = await publicClient.getEntity(entityKey);console.log('Retrieved:', entity.toText()); -
Run it
Run it with:
Terminal window npx tsx --env-file=.env hello.tsTerminal window bun run hello.tsWith Braga retired, this script has nowhere to send its transaction until the next public testnet ships.
Browser Usage (CDN)
Section titled “Browser Usage (CDN)”For static HTML/JS pages without a bundler:
import { createPublicClient } from 'https://esm.sh/@arkiv-network/sdk?target=es2022&bundle-deps'import { eq } from 'https://esm.sh/@arkiv-network/sdk/query?target=es2022&bundle-deps'import { braga } from 'https://esm.sh/@arkiv-network/sdk/chains?target=es2022&bundle-deps'import { http } from 'https://esm.sh/viem?target=es2022'