Getting Started

Installation

To interact with the V3 SDK we recommend installing though npm/yarn:

yarn add @storyhunt/wrapper-sdk

Initialization

Before using any of the routing or swap functions, you must initialize the SDK using initClient.

Parameters

  • options: An object containing the initialization parameters.

    • privateKey (optional, string): A private key used to initialize a viem wallet client for write operations.

    • ethersSigner (optional, Signer): An ethers.js signer used for write operations if privateKey is not provided.

    • graph_url (required, string): The GraphQL URL for querying the subgraph.

Example

import { initClient, defaultChain } from '@storyhunt/wrapper-sdk';

// Option A: Using Private Key (loaded from environment, for example)
await initClient({
  privateKey: process.env.TEST_PRIVATE_KEY,
});

// Option B: Using ethers Signer
const provider = new ethers.JsonRpcProvider(defaultChain);
const signer = new ethers.Wallet(process.env.TEST_PRIVATE_KEY, provider);
await initClient({ ethersSigner: signer });

console.log('SDK initialized!');

Once initClient is called, the SDK’s internal clients are ready for use by other functions.