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

basemint-sdk

v0.0.14

Published

An SDK for interacting with Basemint Protocol

Readme

BaseMint SDK

A TypeScript SDK for interacting with the BaseMint Protocol - a decentralized NFT collection deployment and management platform.

Overview

BaseMint SDK provides a simple and type-safe way to interact with the BaseMint Protocol. It enables:

Collection Management

  • Deploy new ERC721 and ERC1155 collections
  • Customize collection parameters (name, symbol, supply, pricing)
  • Set minting timeframes and limits
  • Manage collection metadata and URIs

Secure Deployment

  • Two-step signature verification process
  • Creator signature validation
  • Deployer signature validation
  • Collection address prediction

Token Operations

  • Mint ERC721 and ERC1155 tokens
  • Automatic price calculation
  • Built-in parameter validation
  • Gas-efficient transactions

Reward Distribution

  • Track creator rewards
  • Distribute accumulated rewards
  • Monitor reward distribution events
  • Query historical distributions

Developer Experience

  • Full TypeScript support
  • Comprehensive type definitions
  • Built-in validation
  • Error handling
  • Event tracking
  • Frontend-ready with wallet integration

Technical Features

  • Modern viem-based architecture
  • Gas-optimized contract interactions
  • Automatic ABI handling
  • Built-in type safety

Installation

npm install @basemint/sdk

Usage

Initialize Clients

First, set up the blockchain clients. In a frontend environment, the wallet client comes from the user's wallet connection.

import { createPublicClient, http, WalletClient } from 'viem'
import { sepolia } from 'viem/chains'

// Public client for reading blockchain data
const publicClient = createPublicClient({
  chain: sepolia,
  transport: http('YOUR_SEPOLIA_RPC_URL')
})

// Wallet client comes from user's wallet connection (e.g., MetaMask)
declare const walletClient: WalletClient

Deploy Collection

Deploy a new NFT collection with signature verification:

import { 
  BaseMintFactory, 
  FACTORY_ADDRESS,
  generateCreatorSignature,
  generateDeployerSignature,
  CollectionMetadata 
} from '@basemint/sdk'
import { parseEther } from 'viem'

// Initialize factory
const factory = new BaseMintFactory(
  publicClient,
  FACTORY_ADDRESS[sepolia.id],
  walletClient
)

// Prepare collection metadata
const metadata: CollectionMetadata = {
  name: 'My Collection',
  symbol: 'MC',
  baseURI: 'ipfs://YOUR_CID/',
  creator: walletClient?.account?.address,
  maxSupply: 1000n,
  mintPrice: parseEther('0.1'),
  startTime: BigInt(Math.floor(Date.now() / 1000) + 3600),
  endTime: BigInt(Math.floor(Date.now() / 1000) + 86400)
}

// Generate signatures
const creatorSignature = await generateCreatorSignature(
  walletClient,
  publicClient,
  FACTORY_ADDRESS[sepolia.id],
  metadata
)

const deployerSignature = await generateDeployerSignature(
  walletClient,
  publicClient,
  FACTORY_ADDRESS[sepolia.id],
  metadata,
  creatorSignature
)

// Deploy collection
const tx = await factory.deployCollection(
  metadata,
  creatorSignature,
  deployerSignature,
  false // isERC1155: false for ERC721
)

// Wait for deployment
const receipt = await publicClient.waitForTransactionReceipt({ hash: tx })
console.log('Collection deployed at:', receipt.contractAddress)

Mint Tokens

Mint tokens from a deployed collection:

import { BaseMintCollection, calculateMintCost } from '@basemint/sdk'

// Initialize collection
const collection = new BaseMintCollection(
  publicClient,
  '0x0000000000000000000000000000000000000000', // collection address
  false, // isERC1155: false
  walletClient
)

// Get collection info
const info = await collection.getCollectionInfo()
console.log('Collection Info:', info)

// Calculate mint cost
const amount = 1n
const mintCost = await calculateMintCost(collection, amount)

// Mint token
const tx = await collection.mint(amount, undefined, mintCost)

console.log('Mint transaction:', tx)

// Wait for mint
const receipt = await publicClient.waitForTransactionReceipt({ hash: tx })
console.log('Token minted:', receipt)

Manage Rewards

Handle creator rewards distribution:

import { 
  BaseMintEscrow, 
  ESCROW_ADDRESS,
  getRewardDistributionEvents 
} from '@basemint/sdk'
import { formatEther } from 'viem'

// Initialize escrow contract
const escrow = new BaseMintEscrow(
  publicClient,
  ESCROW_ADDRESS[sepolia.id],
  walletClient
)

// Get collection rewards
const collectionAddress = '0x0000000000000000000000000000000000000000' // Your collection address
const rewards = await escrow.getPendingRewards(collectionAddress)
console.log('Available rewards:', formatEther(rewards), 'ETH')

// Get distribution events
const latestBlock = await publicClient.getBlockNumber()
const events = await getRewardDistributionEvents(
  publicClient,
  ESCROW_ADDRESS[sepolia.id],
  latestBlock - 1000n, // Last 1000 blocks
  latestBlock
)
console.log('Recent distributions:', events)

Signature Verification

Verify signatures and predict collection addresses:

import { BaseMintFactory, FACTORY_ADDRESS } from '@basemint/sdk'

// Verify signatures and predict collection address
const predictedAddress = await factory.predictCollectionAddress(
  metadata,
  creatorSignature,
  deployerSignature,
  false // isERC1155: false for ERC721
)

// Verify signatures
const verifiedAddress = await factory.checkSignature(
  metadata,
  creatorSignature,
  deployerSignature
)

Type Definitions

Collection Metadata

import { CollectionMetadata } from '@basemint/sdk'

interface CollectionMetadata {
  name: string
  symbol: string
  baseURI: string
  creator: Address
  maxSupply: bigint
  mintPrice: bigint
  startTime: bigint
  endTime: bigint
}

Mint Parameters

import { MintParams } from '@basemint/sdk'

interface MintParams {
  amount: bigint
  value: bigint
  tokenId?: bigint // Required for ERC1155
}

Error Handling

The SDK includes built-in validation and error handling:

import { validateDeploymentConfig, validateMintParams } from '@basemint/sdk'

// Validate deployment config
const error = validateDeploymentConfig(metadata)
if (error) {
  console.error('Invalid deployment config:', error)
}

// Validate mint parameters
const mintError = validateMintParams(params, isERC1155)
if (mintError) {
  console.error('Invalid mint parameters:', mintError)
}

Development

# Install dependencies
npm install

# Build
npm run build

# Test
npm test

# Lint
npm run lint

Contributing

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

License

MIT