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.
Smart Contract Addresses
The following contracts are deployed and verified. All source code is available on the public repository.
BLT Token
ERC-200x0000000000000000000000000000000000000000
0x0000000000000000000000000000000000000000
BLT Staking
Staking0x0000000000000000000000000000000000000000
0x0000000000000000000000000000000000000000
BLT Governor
Governance0x0000000000000000000000000000000000000000
0x0000000000000000000000000000000000000000
BLT Treasury
Treasury0x0000000000000000000000000000000000000000
0x0000000000000000000000000000000000000000
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
- Your application initiates a payment request through the BlackLab API or SDK.
- The user approves the transaction in their connected wallet or BlackLab account.
- The token rail settles the transaction on-chain and notifies your application via webhook.
- Your application delivers the purchased service or product.
Payment Flow
// 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
<!-- 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.
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.