npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

board-coin-sdk

v0.1.0

Published

SDK for interacting with Phi Board Coin protocol

Readme

Board Coin SDK

A TypeScript SDK for interacting with the Phi Protocol, enabling seamless integration with board tokens, trading, and FusedETH operations.

Features

  • 🪙 Board Token Management
  • 💱 Trading Operations
  • 🔄 FusedETH Integration
  • 🔍 Metadata Handling
  • 🔐 Secure Contract Interactions
  • ⚠️ Comprehensive Error Handling

Installation

npm install board-coin-sdk
# or
yarn add board-coin-sdk

Quick Start

import { PhiClient } from "board-coin-sdk";
import { createPublicClient, createWalletClient, http } from "viem";
import { mainnet } from "viem/chains";

// Initialize the client
const publicClient = createPublicClient({
  chain: mainnet,
  transport: http(),
});

const walletClient = createWalletClient({
  chain: mainnet,
  transport: http(),
});

const phiClient = new PhiClient({
  publicClient,
  walletClient,
  chain: mainnet,
});

// Example: Get board token metadata
try {
  const boardMetadata = await phiClient.getBoardMetadata(boardAddress);
  console.log("Board metadata:", boardMetadata);
} catch (error) {
  if (error instanceof ValidationError) {
    console.error("Invalid input:", error.message);
  } else if (error instanceof ContractError) {
    console.error("Contract interaction failed:", error.message);
  } else if (error instanceof NetworkError) {
    console.error("Network error:", error.message);
  } else {
    console.error("Unexpected error:", error);
  }
}

Core Functionality

Board Token Operations

The SDK provides comprehensive functionality for managing board tokens:

  • Get board token metadata
  • View token balances
  • Transfer tokens
  • Manage allowances
  • Cross-chain operations

Trading

Execute trades with board tokens:

try {
  // Buy board tokens
  const buyResult = await phiClient.buyBoard({
    boardAddress: "0x...",
    amount: BigInt(1000000),
    maxPrice: BigInt(1000000),
  });
  console.log("Buy successful:", buyResult);

  // Sell board tokens
  const sellResult = await phiClient.sellBoard({
    boardAddress: "0x...",
    amount: BigInt(1000000),
    minPrice: BigInt(1000000),
  });
  console.log("Sell successful:", sellResult);
} catch (error) {
  if (error instanceof AllowanceError) {
    console.error("Allowance error:", error.message);
  } else if (error instanceof TransactionError) {
    console.error("Transaction failed:", error.message);
  } else if (error instanceof ContractError) {
    console.error("Contract error:", error.message);
  } else {
    console.error("Unexpected error:", error);
  }
}

FusedETH Integration

Manage FusedETH operations:

  • Deposit ETH
  • Withdraw ETH
  • View balances
  • Monitor yield

Error Handling

The SDK provides comprehensive error handling with custom error classes for different types of errors:

Error Classes

  • PhiSDKError: Base error class for all SDK errors
  • WalletClientError: Thrown when wallet client is not configured
  • ContractError: Thrown when contract interaction fails
  • ValidationError: Thrown when input validation fails
  • MetadataError: Thrown when token metadata parsing fails
  • TransactionError: Thrown when transaction fails
  • NetworkError: Thrown when network/chain operations fail
  • AllowanceError: Thrown when allowance operations fail
  • PriceError: Thrown when price operations fail

Error Handling Example

import {
  PhiSDKError,
  WalletClientError,
  ContractError,
  ValidationError,
  MetadataError,
  TransactionError,
  NetworkError,
  AllowanceError,
  PriceError
} from 'board-coin-sdk';

try {
  // Your SDK operation here
  await phiClient.buyBoard({...});
} catch (error) {
  if (error instanceof ValidationError) {
    // Handle invalid input
    console.error('Invalid input:', error.message);
  } else if (error instanceof WalletClientError) {
    // Handle missing wallet client
    console.error('Wallet not connected:', error.message);
  } else if (error instanceof ContractError) {
    // Handle contract interaction errors
    console.error('Contract error:', error.message);
    if (error.originalError) {
      console.error('Original error:', error.originalError);
    }
  } else if (error instanceof TransactionError) {
    // Handle transaction failures
    console.error('Transaction failed:', error.message);
    console.error('Transaction hash:', error.txHash);
  } else if (error instanceof NetworkError) {
    // Handle network issues
    console.error('Network error:', error.message);
  } else if (error instanceof AllowanceError) {
    // Handle allowance issues
    console.error('Allowance error:', error.message);
  } else if (error instanceof PriceError) {
    // Handle price-related errors
    console.error('Price error:', error.message);
  } else if (error instanceof PhiSDKError) {
    // Handle other SDK errors
    console.error('SDK error:', error.message);
  } else {
    // Handle unexpected errors
    console.error('Unexpected error:', error);
  }
}

API Reference

PhiClient

The main client class for interacting with the protocol.

Constructor

new PhiClient(config: PhiSdkConfig)

Configuration options:

  • publicClient: Viem PublicClient instance
  • walletClient: Optional Viem WalletClient instance
  • chain: Chain configuration

Methods

  • getBoardMetadata(address: Address): Get metadata for a board token
  • getBoardPrice(address: Address): Get current price of a board token
  • buyBoard(params: TradeParams): Buy board tokens
  • sellBoard(params: TradeParams): Sell board tokens
  • getPhiToken(): Get PHI token contract instance
  • getFusedETH(): Get FusedETH contract instance

Types

The SDK exports various TypeScript types for type safety:

  • PhiSdkConfig: Configuration for the SDK client
  • BoardToken: Board token metadata structure
  • TradeParams: Parameters for trading operations
  • TradeResult: Result of trading operations

Security

  • All contract interactions are handled through the Viem library
  • Proper error handling and type safety
  • Support for various wallet providers
  • Secure transaction signing
  • Input validation for all operations
  • Comprehensive error handling with detailed error messages

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License