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

@thetanuts-test/core

v0.1.0

Published

Core utilities, types, and provider management for Thetanuts SDK

Readme

@thetanuts-test/core

Core utilities, types, and client management for the Thetanuts SDK.

Installation

# pnpm
pnpm add @thetanuts-test/core

# npm
npm install @thetanuts-test/core

# yarn
yarn add @thetanuts-test/core

Quick Start

import { createThetanutsClient, formatAmount, parseAmount } from '@thetanuts-test/core'

// Create a read-only client
const client = createThetanutsClient({
  chainId: 8453, // Base
})

// With custom RPC URL
const clientCustomRpc = createThetanutsClient({
  chainId: 8453,
  rpcUrl: 'https://your-rpc-endpoint.com',
})

Adding Wallet Support

For write operations (transactions), provide a wallet client:

import { createThetanutsClient } from '@thetanuts-test/core'
import { createWalletClient, http } from 'viem'
import { base } from 'viem/chains'
import { privateKeyToAccount } from 'viem/accounts'

const account = privateKeyToAccount('0x...')
const walletClient = createWalletClient({
  account,
  chain: base,
  transport: http(),
})

const client = createThetanutsClient({
  chainId: 8453,
  walletClient,
})

// Now you can use write operations
console.log('Connected address:', client.address)

API Reference

createThetanutsClient(config)

Creates a new Thetanuts client instance.

const client = createThetanutsClient({
  chainId: 8453,           // Required: Chain ID
  rpcUrl: 'https://...',   // Optional: Custom RPC URL
  walletClient: wallet,    // Optional: Viem wallet client
})

Returns: ThetanutsClient

| Property | Type | Description | |----------|------|-------------| | chainId | number | Connected chain ID | | chain | Chain | Viem chain object | | publicClient | PublicClient | For read operations | | walletClient | WalletClient | For write operations (if provided) | | address | Address | Connected wallet address (if wallet provided) |


Utility Functions

formatAmount(value, decimals)

Format a bigint value to human-readable string.

import { formatAmount } from '@thetanuts-test/core'

formatAmount(1000000n, 6)        // "1"
formatAmount(1500000000000000000n, 18) // "1.5"

parseAmount(value, decimals)

Parse a human-readable string to bigint.

import { parseAmount } from '@thetanuts-test/core'

parseAmount("1", 6)    // 1000000n
parseAmount("1.5", 18) // 1500000000000000000n

truncateAddress(address, chars?)

Truncate address for display.

import { truncateAddress } from '@thetanuts-test/core'

truncateAddress("0x1234567890abcdef1234567890abcdef12345678")
// "0x1234...5678"

truncateAddress("0x1234567890abcdef1234567890abcdef12345678", 6)
// "0x123456...345678"

isValidAddress(address)

Check if a string is a valid Ethereum address.

import { isValidAddress } from '@thetanuts-test/core'

isValidAddress("0x1234567890abcdef1234567890abcdef12345678") // true
isValidAddress("invalid") // false

Chain Configuration

SUPPORTED_CHAINS

Map of supported chain configurations.

import { SUPPORTED_CHAINS } from '@thetanuts-test/core'

const baseConfig = SUPPORTED_CHAINS[8453]
// { chainId: 8453, name: 'Base', symbol: 'ETH', ... }

isSupportedChain(chainId)

Check if a chain ID is supported.

import { isSupportedChain } from '@thetanuts-test/core'

isSupportedChain(8453)  // true
isSupportedChain(99999) // false

getChainConfig(chainId)

Get configuration for a chain.

import { getChainConfig } from '@thetanuts-test/core'

const config = getChainConfig(8453)
// { chainId: 8453, name: 'Base', rpcUrl: '...', ... }

Constants

MAX_UINT256

Maximum uint256 value for unlimited approvals.

import { MAX_UINT256 } from '@thetanuts-test/core'

// 2^256 - 1

SUPPORTED_CHAIN_IDS

Array of all supported chain IDs.

import { SUPPORTED_CHAIN_IDS } from '@thetanuts-test/core'

// [1, 8453, 42161, 56, 137, 43114, 5000]

Error Classes

import {
  ThetanutsError,
  UnsupportedChainError,
  WalletNotConnectedError,
  TransactionError,
} from '@thetanuts-test/core'

try {
  // SDK operation
} catch (error) {
  if (error instanceof UnsupportedChainError) {
    console.error('Chain not supported')
  } else if (error instanceof WalletNotConnectedError) {
    console.error('Please connect wallet')
  } else if (error instanceof TransactionError) {
    console.error('Transaction failed:', error.cause)
  }
}

Supported Chains

| Chain | Chain ID | Symbol | |-------|----------|--------| | Ethereum | 1 | ETH | | Base | 8453 | ETH | | Arbitrum | 42161 | ETH | | BNB Smart Chain | 56 | BNB | | Polygon | 137 | MATIC | | Avalanche | 43114 | AVAX | | Mantle | 5000 | MNT |

TypeScript

This package is fully typed. Import types as needed:

import type {
  ThetanutsClient,
  ThetanutsClientConfig,
  SupportedChainId,
  ChainConfig,
  TransactionResult,
  TokenInfo,
} from '@thetanuts-test/core'

License

MIT