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

@reown/appkit-blockchain-api

v1.7.1-b-api-client.0

Published

A client library for interacting with the WalletConnect Blockchain API.

Readme

@reown/blockchain-api

A client library for interacting with the WalletConnect Blockchain API.

Installation

npm install @reown/blockchain-api

Usage

Basic Usage

import { BlockchainApiClient } from '@reown/blockchain-api'

// Create a client
const client = new BlockchainApiClient({
  projectId: 'YOUR_PROJECT_ID',
  sdkType: 'web-app',
  sdkVersion: '1.0.0'
})

// Get supported networks
const supportedNetworks = await client.getSupportedNetworks()

// Get account balance
const balance = await client.getBalance('0x123...', '1') // address, chainId

Advanced Configuration

You can configure the client with additional options:

import { BLOCKCHAIN_API_URL, BlockchainApiClient } from '@reown/blockchain-api'

const client = new BlockchainApiClient({
  baseUrl: BLOCKCHAIN_API_URL, // Defaults to 'https://rpc.walletconnect.org'
  projectId: 'YOUR_PROJECT_ID',
  clientId: 'YOUR_CLIENT_ID', // Optional
  sdkType: 'web-app',
  sdkVersion: '1.0.0'
})

// Update configuration later
client.setProjectId('NEW_PROJECT_ID')
client.setClientId('NEW_CLIENT_ID')
client.setSdkType('mobile-app')
client.setSdkVersion('1.1.0')

Features

Account Information

// Get account identity
const identity = await client.fetchIdentity({
  address: '0x123...',
  caipNetworkId: 'eip155:1',
  sender: '0x456...' // Optional
})

// Get account transactions
const transactions = await client.fetchTransactions({
  account: '0x123...',
  chainId: '1',
  cursor: 'next_page_cursor' // Optional, for pagination
})

// Get account balance
const balance = await client.getBalance('0x123...', '1')

Token Swaps

// Get available tokens for swapping
const tokens = await client.fetchSwapTokens({ chainId: '1' })

// Get token prices
const prices = await client.fetchTokenPrice({
  addresses: ['0x123...', '0x456...']
})

// Get swap quote
const quote = await client.fetchSwapQuote({
  amount: '1000000000000000000', // 1 ETH in wei
  userAddress: '0x123...',
  from: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', // ETH
  to: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' // USDC
})

// Check token allowance
const allowance = await client.fetchSwapAllowance({
  tokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  userAddress: '0x123...'
})

// Generate approve calldata
const approveCalldata = await client.generateApproveCalldata({
  userAddress: '0x123...',
  from: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
  to: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
})

// Generate swap calldata
const swapCalldata = await client.generateSwapCalldata({
  amount: '1000000000000000000',
  userAddress: '0x123...',
  from: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
  to: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
})

ENS

// Lookup ENS name
const ensInfo = await client.lookupEnsName('vitalik.eth')

// Reverse lookup ENS name
const ensNames = await client.reverseLookupEnsName({
  address: '0x123...',
  sender: '0x456...' // Optional
})

// Get name suggestions
const suggestions = await client.getEnsNameSuggestions('vitalik')

// Register ENS name
const registration = await client.registerEnsName({
  coinType: 60, // ETH
  address: '0x123...',
  message: 'Message to sign',
  signature: '0x456...'
})

On-ramp

// Get on-ramp options
const options = await client.getOnrampOptions()

// Get on-ramp quote
const quote = await client.getOnrampQuote({
  purchaseCurrency: { id: 'ETH', symbol: 'ETH' },
  paymentCurrency: { id: 'USD' },
  amount: '100',
  network: 'ethereum'
})

// Generate on-ramp URL
const url = await client.generateOnRampURL({
  destinationWallets: [{ address: '0x123...', blockchains: ['ethereum'] }],
  partnerUserId: 'user123',
  defaultNetwork: 'ethereum',
  purchaseAmount: '0.1', // Optional
  paymentAmount: '100' // Optional
})

Smart Sessions

// Get smart sessions
const sessions = await client.getSmartSessions('eip155:1:0x123...')

// Revoke smart session
const revocation = await client.revokeSmartSession('0x123...', 'pci_value', 'signature_value')

Utility Functions

import {
  formatAddress,
  formatCaipAddress,
  getChainIdFromCaipAddress,
  getPlainAddress
} from '@reown/blockchain-api'

// Extract plain address from CAIP format
const address = getPlainAddress('eip155:1:0x123...')
// Result: '0x123...'

// Get chain ID from CAIP address
const chainId = getChainIdFromCaipAddress('eip155:1:0x123...')
// Result: '1'

// Format CAIP address
const caipAddress = formatCaipAddress('0x123...', 'eip155', '1')
// Result: 'eip155:1:0x123...'

// Format address for display
const displayAddress = formatAddress('0x1234567890abcdef1234567890abcdef12345678')
// Result: '0x1234...5678'

License

MIT