Skip to content

Dev Environment

This guide walks you through setting up a development environment for trading with the Darkfibre SDK.

The SDK requires Node.js version 20 or higher.

  1. Go to nodejs.org
  2. Download the LTS version
  3. Run the installer
  4. Verify the installation:
Terminal window
node --version
# Should output v20.x.x or higher

Create a new directory for your trading project:

Terminal window
mkdir darkfibre-trader
cd darkfibre-trader
npm init -y

Install the Darkfibre SDK and required packages:

Terminal window
npm install @darkfibre/sdk dotenv
npm install -D typescript tsx @types/node

This installs:

  • @darkfibre/sdk - The official Darkfibre TypeScript SDK
  • dotenv - For loading environment variables from .env
  • typescript - TypeScript compiler
  • tsx - TypeScript execution (run .ts files directly)
  • @types/node - TypeScript types for Node.js

Create a tsconfig.json file in your project root:

{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "Node",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"outDir": "dist"
},
"include": ["*.ts"]
}

Create your main file:

Terminal window
touch index.ts

Or create it in your IDE.

Create a .env file in your project root to store your credentials:

.env
DARKFIBRE_API_KEY=your_api_key_here
SOLANA_PRIVATE_KEY=your_private_key_here

Replace the placeholder values after you complete the next steps.

Create or update your .gitignore:

Terminal window
*.env

Your project structure should look like this:

darkfibre-trader/
├── node_modules/
├── index.ts
├── .env
├── .gitignore
├── package-lock.json
├── package.json
└── tsconfig.json

Next: Register for an API key