@blondfrogs/veil-wasm-wrapper
v1.1.0
Published
TypeScript wrapper for Veil blockchain - transaction builder, wallet management, and RPC client using WASM cryptography
Maintainers
Readme
Veil WASM Wrapper
TypeScript wrapper for Veil blockchain - transaction builder, wallet management, and RPC client
🎯 Overview
This package provides a comprehensive TypeScript wrapper for the Veil blockchain, enabling transaction building, wallet management, and blockchain interaction in both browser and Node.js environments. Powered by @blondfrogs/secp256k1-wasm - a pure Rust WASM cryptographic library.
Features:
- ✅ Type-safe TypeScript API
- ✅ WASM-powered cryptography (no C dependencies!)
- ✅ Stealth address generation and management
- ✅ RingCT transaction building
- ✅ Pedersen commitments & range proofs
- ✅ MLSAG ring signatures
- ✅ Wallet key generation and restoration
- ✅ RPC client for blockchain communication
- ✅ Output scanning and UTXO management
- ✅ Transaction serialization/deserialization
📦 Installation
npm install @blondfrogs/veil-wasm-wrapperThis will automatically install the required @blondfrogs/secp256k1-wasm dependency.
🚀 Quick Start
Basic Usage
import { initWasm, createCommitment, generateRangeProof } from '@blondfrogs/veil-wasm-wrapper';
async function example() {
// Initialize WASM module (call once at startup)
await initWasm();
// Create a Pedersen commitment
const value = 1000000n; // Amount in satoshis
const blind = crypto.getRandomValues(new Uint8Array(32));
const commitment = createCommitment(value, blind);
// Generate a range proof
const proof = generateRangeProof({
commitment,
value,
blind,
nonce: commitment, // Use commitment as nonce
});
console.log('Proof size:', proof.proof.length, 'bytes');
}Transaction Building
import { initWasm, createWallet, TransactionBuilder } from '@blondfrogs/veil-wasm-wrapper';
async function sendVeil() {
await initWasm();
// Create or restore wallet
const wallet = createWallet();
console.log('Address:', wallet.stealthAddress);
// Build transaction
const txBuilder = new TransactionBuilder(wallet);
const result = await txBuilder.send(
wallet.spendSecret,
wallet.scanSecret,
[{ address: 'sv1qqxxx...', amount: 100_000_000n }], // 1 VEIL
myUTXOs
);
console.log('Transaction ID:', result.txid);
console.log('Fee:', result.fee);
}📚 API Reference
See API.md for complete documentation.
Quick reference:
Wallet Management
createWallet()- Create new walletrestoreWallet()- Restore from keysvalidateAddress()- Validate stealth addresses
Transaction Building
TransactionBuilder- Build RingCT transactionsfetchDecoyOutputs()- Get decoys for ring signatures
Scanning
scanTransaction()- Scan for your outputsparseWatchOnlyTransactions()- Parse watch-only RPC data
RPC Client
RpcRequester- Interact with Veil nodescheckKeyImages()- Check spent status
Cryptography
createCommitment()- Pedersen commitmentsgenerateRangeProof()- BulletproofsrewindRangeProof()- Extract valuesgenerateKeyImage()- Prevent double-spending
🧪 Examples
See the examples/ directory for complete working examples:
create-wallet.ts- Wallet creationbuild-transaction.ts- Transaction buildingscan-outputs.ts- Blockchain scanningblockchain-integration.ts- RPC usage
🛠️ Development
Build
npm run buildTest
npm test
npm run test:watchLint
npm run lint⚠️ Security Warning
⚠️ USE AT YOUR OWN RISK ⚠️
This library has not been formally audited. Use caution with real funds.
🤝 Contributing
Contributions welcome! Please open an issue or submit a pull request.
📄 License
MIT License - See LICENSE file for details
🔗 Links
- Crypto Library: @blondfrogs/secp256k1-wasm
- Veil Project: https://veil-project.com/
- Discord: https://discord.veil-project.com/
Built with 🦀 Rust + TypeScript for the Veil community
