Code Examples
Complete examples using the official @darkfibre/sdk npm package.
Prerequisites
Section titled “Prerequisites”- Node.js 20+
- Darkfibre API key (register here)
- Solana wallet private key (base58)
Examples
Section titled “Examples”| Example | Description |
|---|---|
| Quick Start | Minimal buy example in under 30 lines |
| Buy + Sell | Complete round-trip with error handling |
| Sniping Bot | WebSocket listener for new token launches |
Quick Clone
Section titled “Quick Clone”git clone https://github.com/darkfibre-dev/darkfibre-examples.gitcd darkfibre-examplesEach example is self-contained with its own package.json. Pick one and run:
cd 01-quick-start # or 02-buy-sell, 03-sniping-botnpm installcp .env.example .env# Edit .env with your credentialsnpm startEnvironment Variables
Section titled “Environment Variables”All examples use the same environment variables:
| Variable | Description |
|---|---|
DARKFIBRE_API_KEY | Your Darkfibre API key |
SOLANA_PRIVATE_KEY | Your wallet private key (base58) |
Your private key is used only locally for signing transactions - it is never sent to the API.