Skip to Content

Setup

In this step, we will initialize the Nord SDK and create a user instance.

Initialize the Client

First, create a Nord instance to interact with the 01 Exchange. You will need the 01 Exchange App Key and a Solana RPC connection.

Note: For this guide, we are connecting to the Devnet.

import { Nord } from "@n1xyz/nord-ts"; import { Connection } from "@solana/web3.js"; // 1. Setup Solana Connection const connection = new Connection("https://api.devnet.solana.com"); // 2. Initialize Nord Client const nord = await Nord.new({ app: "zoau54n5U24GHNKqyoziVaVxgsiQYnPMx33fKmLLCT5", // 01 Exchange App Key solanaConnection: connection, webServerUrl: "https://zo-devnet.n1.xyz", // Devnet URL }); console.log("Nord client initialized!");

Create a User

To perform actions like trading or successful deposits, you need a NordUser. The easiest way to get started programmatically is using a private key.

import { NordUser } from "@n1xyz/nord-ts"; import { Keypair } from "@solana/web3.js"; import bs58 from "bs58"; // requires 'bs58' package if using string key // Replace with your actual private key (Uint8Array or base58 string) // WARNING: Never commit real private keys to version control! const privateKey = "YOUR_PRIVATE_KEY_HERE"; const user = NordUser.fromPrivateKey(nord, privateKey); // Update local state to ensure we have the latest account info await user.updateAccountId(); await user.fetchInfo(); console.log("User initialized:", user.address.toString());
Last updated on