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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@blockia-pay/blockia-agent-sdk

v0.12.0

Published

> A TypeScript SDK for interacting with the Blockia Pay payment protocol, > supporting ERC-3009 token transfers with EIP-712 signatures.

Downloads

973

Readme

Blockia Pay SDK

A TypeScript SDK for interacting with the Blockia Pay payment protocol, supporting ERC-3009 token transfers with EIP-712 signatures.


Installation

npm install @blockia-pay/sdk

Quick Start

import { BlockiaAgent } from '@blockia-pay/sdk';

// Initialize the agent
const agent = new BlockiaAgent({
  apiUrl: 'https://api.blockia.pay',
  privateKey: '0x...', // Your private key
  chainId: 84532, // Base Sepolia (default)
});

// Get payment requirements for a payment
const requirements = await agent.getPaymentRecordInfo('recordId');

// Select preferred payment option (auto-prefers Base + USDC)
const requirement = await agent.selectPaymentRequirement(requirements);

// Make payment
const result = await agent.makePayment(requirement);
console.log('Payment successful:', result.txHash);

Examples

The examples/ directory contains runnable scripts demonstrating different usage patterns:

Simple Payment Script

cd examples
node simple-payment.ts <private-key> <payment-id>

Demonstrates the convenience makePayment() method that handles the entire payment flow automatically.

Fetch with Payment Script

cd examples
node fetch-with-payment.ts <private-key> <protected-url>

Demonstrates the fetchWithPayment() method that automatically handles X402 payment requirements when making HTTP requests to protected resources.

Create Payment Payload Script

cd examples
node create-payment-payload.ts <private-key> <payment-id>

Demonstrates how to create a base64url-encoded X402 payment payload for use in X-PAYMENT headers.


Core Features

  • Payment Flow

    • Fetch Requirements: Get available payment options for a payment
    • Select Option: Choose preferred network/asset (auto-prefers Base + USDC)
    • Check Balance: Verify sufficient funds
    • Sign & Submit: Create EIP-712 signature and submit payment
  • Supported Networks

    • Ethereum: Mainnet, Sepolia
    • Polygon: Mainnet, Amoy
    • Arbitrum: Mainnet, Sepolia
    • Optimism: Mainnet, Sepolia
    • Base: Mainnet, Sepolia (default)
    • BSC: Mainnet, Testnet
  • ERC-3009 Support

    • EIP-712 typed data signing
    • 1-hour validity window
    • Secure nonce generation
    • Batched contract calls for efficiency

API Reference

Constructor

new BlockiaAgent(config: BlockiaAgentConfig)

Key Methods

  • getBalance(tokenAddress, ownerAddress) – Check token balance
  • getPaymentRecordInfo(recordId) – Fetch payment requirements
  • makePayment(requirement) – Complete payment in one call

Convenience Methods

  • selectPaymentRequirement(requirements, options?) – Filter and sort payment options
  • selectByNetwork() – Filter by network (Base, Ethereum, etc.)
  • selectByScheme() – Filter by payment scheme
  • selectByAsset() – Filter by token address

Error Handling

import { NetworkError, ValidationError } from '@blockia-pay/sdk';

try {
  await agent.makePayment(requirement);
} catch (error) {
  if (error instanceof ValidationError) {
    // Handle validation issues
  } else if (error instanceof NetworkError) {
    // Handle API/network issues
  }
}

Advanced Usage

For more control, use the individual methods:

// Manual payment flow
const payload = await agent.createPaymentPayload(requirement);
const result = await agent.submitPayment(requirement, payload);

// Custom requirement selection
const requirement = await agent.selectPaymentRequirement(requirements, {
  network: 'base',
  asset: 'USDC',
});

Requirements

  • Node.js 18+
  • TypeScript 5.0+
  • EVM-compatible wallet with USDC balance

Security

  • Private keys never leave the client
  • All signatures generated locally
  • Secure nonce generation using crypto.getRandomValues
  • Input validation for all addresses and parameters