Skip to main content

Radix Web3.js

A lightweight, type-safe JavaScript/TypeScript library for interacting with the Radix Network. Built to make Web3 development on Radix simple and intuitive.

Key Features

  • 🔑 Simplified Key Management - Create and manage Ed25519 keypairs
  • 💸 Transaction Building - Build, sign, and submit transactions with ease
  • 🔍 Account Management - Query balances and transaction history
  • 📝 Manifest Generation - Helper functions for common transaction manifests
  • 🌐 Network Support - Works with Mainnet, Stokenet, and other Radix networks
  • 🔒 Type Safety - Full TypeScript support with comprehensive types

Quick Start

Install the package:

npm install radix-web3.js

Example Usage

Here's a simple example of creating a wallet and sending XRD tokens:

import { createEd25519KeyPair, createRadixWeb3Client } from 'radix-web3.js'
import { sendResourceManifest } from 'radix-web3.js/manifests'
import { fromPublicKey } from 'radix-web3.js/account'

// Create a new keypair
const keyPair = createEd25519KeyPair()

// Initialize the client
const web3Client = createRadixWeb3Client({
networkId: 'Stokenet',
notaryPublicKey: keyPair.publicKey(),
notarizer: (hash) => keyPair.signToSignature(hash),
})

// Get your account address
const accountAddress = await fromPublicKey(keyPair.publicKey(), 2) // 2 = Stokenet

// Send 1 XRD to another address
const { transactionId } = await web3Client.submitTransaction(
sendResourceManifest({
resourceAddress:
'resource_tdx_2_1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxtfd2jc',
amount: '1',
fromAddress: accountAddress,
toAddress: 'account_tdx_2_12yf3qp4feqnw...',
}),
)

// Check your balances
const { fungibleTokens } = await web3Client.getBalances(accountAddress)
console.log('Balances:', fungibleTokens)