Token Developer Docs

Integrate the BlackLab Token (BLT) into your applications. This guide covers smart contract interaction, the token rail payment integration, and the JavaScript/TypeScript SDK.

Testnet First - Always develop and test on the testnet before deploying to mainnet. Testnet BLT is free and can be obtained from the faucet.

Smart Contract Addresses

The following contracts are deployed and verified. All source code is available on the public repository.

BLT Token

ERC-20
Mainnet 0x0000000000000000000000000000000000000000
Testnet 0x0000000000000000000000000000000000000000

BLT Staking

Staking
Mainnet 0x0000000000000000000000000000000000000000
Testnet 0x0000000000000000000000000000000000000000

BLT Governor

Governance
Mainnet 0x0000000000000000000000000000000000000000
Testnet 0x0000000000000000000000000000000000000000

BLT Treasury

Treasury
Mainnet 0x0000000000000000000000000000000000000000
Testnet 0x0000000000000000000000000000000000000000
Placeholder Addresses - Contract addresses above are placeholders. Actual addresses will be published after deployment and audit completion.

Networks

Network Chain ID RPC URL Explorer
Mainnet -- TBA TBA
Testnet -- TBA TBA

Network details will be finalized and published before the Token Generation Event.

Token Rail Integration Guide

The token rail is BlackLab's payment infrastructure that enables BLT transactions within your application. It handles wallet management, transaction signing, and settlement.

How It Works

  1. Your application initiates a payment request through the BlackLab API or SDK.
  2. The user approves the transaction in their connected wallet or BlackLab account.
  3. The token rail settles the transaction on-chain and notifies your application via webhook.
  4. Your application delivers the purchased service or product.

Payment Flow

payment-flow.js
// 1. Create a payment intent via the API
const response = await fetch('https://api.blacklab.studio/v1/token/payments', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer sk_live_xxx',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    amount: '100.00',          // BLT amount
    currency: 'BLT',
    description: 'Mastering credit pack (10)',
    metadata: { order_id: 'ord_12345' },
    webhook_url: 'https://yourapp.com/webhooks/payment',
  }),
});

const payment = await response.json();
// { id: "pay_abc123", status: "pending", approval_url: "..." }

// 2. Redirect user to approval_url or embed the payment widget
window.location.href = payment.approval_url;

// 3. Handle the webhook callback
// POST to your webhook_url with payment confirmation

Accept BLT Payments

Enable BLT payments in your application using the embedded payment widget or direct API integration.

Embedded Widget

widget.html
<!-- Include the BlackLab payment script -->
<script src="https://js.blacklab.studio/v1/payment.js"></script>

<!-- Create a payment button -->
<div id="blt-payment"></div>

<script>
  BlackLab.Payment.create({
    container: '#blt-payment',
    clientId: 'your_client_id',
    amount: '50.00',
    currency: 'BLT',
    description: '5 Mastering Credits',
    onSuccess: (payment) => {
      console.log('Payment confirmed:', payment.id);
    },
    onError: (error) => {
      console.error('Payment failed:', error.message);
    },
  });
</script>

Staking Integration

Interact with the BLT staking contract to allow users to stake tokens and earn rewards directly from your application.

staking.js
import { BlackLabSDK } from '@blacklab/sdk';

const sdk = new BlackLabSDK({
  apiKey: 'sk_live_xxx',
  network: 'mainnet',
});

// Check staking balance
const stakeInfo = await sdk.staking.getPosition(walletAddress);
console.log('Staked:', stakeInfo.amount, 'BLT');
console.log('Rewards:', stakeInfo.pendingRewards, 'BLT');
console.log('Tier:', stakeInfo.tier);

// Stake tokens (requires user wallet approval)
const tx = await sdk.staking.stake({
  amount: '1000.00',
  lockPeriod: 90, // days
});

// Claim rewards
const claimTx = await sdk.staking.claimRewards();

SDK Installation

The BlackLab SDK provides a typed, ergonomic interface for token rail operations.

Install

# npm
npm install @blacklab/sdk

# yarn
yarn add @blacklab/sdk

# pnpm
pnpm add @blacklab/sdk

Requirements

  • Node.js 18+ or modern browser with ES2020 support
  • A BlackLab API key (obtain from Developer Portal)
  • For on-chain operations: a compatible wallet provider (MetaMask, WalletConnect, etc.)

Usage Examples

Initialize the SDK

import { BlackLabSDK } from '@blacklab/sdk';

const sdk = new BlackLabSDK({
  apiKey: process.env.BLACKLAB_API_KEY,
  network: 'mainnet', // or 'testnet'
});

Check Token Balance

const balance = await sdk.token.balanceOf(walletAddress);
console.log(`Balance: ${balance.formatted} BLT`);

Transfer Tokens

const tx = await sdk.token.transfer({
  to: recipientAddress,
  amount: '500.00',
});
console.log(`TX Hash: ${tx.hash}`);

Listen for Events

sdk.token.on('Transfer', (from, to, amount) => {
  console.log(`${from} sent ${amount} BLT to ${to}`);
});

SDK API Reference

Module Method Description
sdk.token balanceOf(address) Get BLT balance for an address.
sdk.token transfer({ to, amount }) Transfer BLT to another address.
sdk.token approve({ spender, amount }) Approve spending allowance.
sdk.staking stake({ amount, lockPeriod }) Stake BLT tokens.
sdk.staking unstake(amount) Unstake BLT tokens.
sdk.staking claimRewards() Claim pending staking rewards.
sdk.staking getPosition(address) Get staking position and rewards.
sdk.payments create({ amount, ... }) Create a payment intent.
sdk.payments get(paymentId) Retrieve payment status.
sdk.governance propose({ ... }) Create a governance proposal.
sdk.governance vote(proposalId, support) Cast a vote on a proposal.

Full SDK documentation and TypeScript types are available in the package README and inline JSDoc.