Installation

You can install Fibrous Router SDK using npm, yarn, or pnpm: Latest stable version: 0.6.1
npm install fibrous-router-sdk

Quick Start

Check out the detailed example in the Fibrous SDK Github Repository section for a simple example of how to initialize and use the SDK. Here’s a simple example of how to initialize and use the SDK:
import { Router as FibrousRouter } from "fibrous-router-sdk";
import { parseUnits } from "ethers";

// Create a new router instance
const fibrous = new FibrousRouter();
const chainId = fibrous.supportedChains.find(chain => chain.chain_name == "hyperevm")?.chain_id;
if (!chainId) {
    throw new Error("Chain not supported");
}

// Build route options
const tokens = await fibrous.supportedTokens(chainId);
// Get input token from tokens map
const inputToken = tokens.get("hype");
if (!inputToken) {
    throw new Error("Input token not found");
}
// Get output token by address (for unverified tokens)
const outputToken = await fibrous.getToken(
    "0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb",
    chainId,
);
if (!outputToken) {
    throw new Error("Output token not found");
}
const tokenInAddress = inputToken.address;
const tokenOutAddress = outputToken.address;
const tokenInDecimals = Number(inputToken.decimals);
const inputAmount = BigInt(parseUnits("1", tokenInDecimals)); // 1 Hype

const route = await fibrous.getBestRoute(
    inputAmount,
    tokenInAddress,
    tokenOutAddress,
    "hyperevm", // chainName will be deprecated in the future, use chainId instead
    {
        reverse: false,
    },
    chainId,
);

Requirements

  • Node.js version 18.x or higher
  • A Web3 provider (like ethers.js) for transaction signing
  • Access to supported blockchain networks (Base, Scroll,HyperEVM or Starknet)

Next Steps

After installation, check out these guides to learn more about specific features: