Dev Environment
This guide walks you through setting up a development environment for trading with the Darkfibre SDK.
Install Node.js
Section titled “Install Node.js”The SDK requires Node.js version 20 or higher.
- Go to nodejs.org
- Download the LTS version
- Run the installer
- Verify the installation:
node --version# Should output v20.x.x or higherCreate Your Project
Section titled “Create Your Project”Create a new directory for your trading project:
mkdir darkfibre-tradercd darkfibre-tradernpm init -yInstall Dependencies
Section titled “Install Dependencies”Install the Darkfibre SDK and required packages:
npm install @darkfibre/sdk dotenvnpm install -D typescript tsx @types/nodeThis installs:
@darkfibre/sdk- The official Darkfibre TypeScript SDKdotenv- For loading environment variables from.envtypescript- TypeScript compilertsx- TypeScript execution (run.tsfiles directly)@types/node- TypeScript types for Node.js
Create tsconfig.json
Section titled “Create tsconfig.json”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 Project Structure
Section titled “Create Project Structure”Create your main file:
touch index.tsOr create it in your IDE.
Set Up Environment Variables
Section titled “Set Up Environment Variables”Create a .env file in your project root to store your credentials:
DARKFIBRE_API_KEY=your_api_key_hereSOLANA_PRIVATE_KEY=your_private_key_hereReplace the placeholder values after you complete the next steps.
Create or update your .gitignore:
*.envVerify Setup
Section titled “Verify Setup”Your project structure should look like this:
darkfibre-trader/├── node_modules/├── index.ts├── .env├── .gitignore├── package-lock.json├── package.json└── tsconfig.jsonNext: Register for an API key