runicRPC Logo
runicRPCv0.1
Documentation

Getting Started

Get up and running with runicRPC in 5 minutes.

Installation

Install runicRPC and its peer dependency:

npm install @runic-rpc/sdk @solana/web3.js

Or with pnpm:

pnpm add @runic-rpc/sdk @solana/web3.js

Quick Start

The easiest way to get started is to use RunicRPC.create() which auto-loads configuration from your environment or config file:

import { RunicRPC } from '@runic-rpc/sdk';

// Auto-loads from .env or runic.config.json
const rpc = RunicRPC.create();

const slot = await rpc.request('getSlot');
console.log('Current slot:', slot);

Then add your API keys to a .env file:

HELIUS_API_KEY=your-helius-api-key
ALCHEMY_API_KEY=your-alchemy-api-key

Or create a runic.config.json:

{
  "providers": {
    "helius": { "apiKey": "your-helius-api-key" },
    "alchemy": { "apiKey": "your-alchemy-api-key" }
  },
  "strategy": "latency-based"
}

Configuration Priority

runicRPC loads configuration from multiple sources with this priority (highest first):

  1. Code config - Passed directly to create() or constructor
  2. Environment variables - .env file or system env vars
  3. Config file - runic.config.json
// Override specific settings while using auto-loaded config
const rpc = RunicRPC.create({
  strategy: 'round-robin',  // Override strategy
  logLevel: 'debug'
});

Direct Configuration

You can also configure directly in code without auto-loading:

const rpc = new RunicRPC({
  providers: {
    helius: { apiKey: 'your-helius-api-key' }
  }
});

With Multiple Providers

Configure multiple providers for automatic failover:

const rpc = RunicRPC.create({
  providers: {
    helius: { apiKey: 'helius-key' },
    alchemy: { apiKey: 'alchemy-key' },
  },
  strategy: 'latency-based',
});

Drop-in Replacement

runicRPC is designed as a drop-in replacement for Connection:

// Before
import { Connection } from '@solana/web3.js';
const connection = new Connection('https://api.mainnet-beta.solana.com');

// After
import { RunicRPC } from '@runic-rpc/sdk';
const rpc = RunicRPC.create();

Next Steps