TBC Rust SDK
Rust SDK for constructing and signing TuringBitChain transactions and implemented contracts.
Install
[]
= "0.7.0"
The Cargo package name is tbc-sdk; the Rust import name is tbc_sdk.
0.7.0 release
MultiSig supports TBC and ordinary Token across legacy FT v1–v4, intermediate TBC20 and TBC20 Standard. Builders, proposal validation, signing and finalization reject Stablecoin, LP and locked LP. This stricter asset policy is why the release increments the minor version before 1.0. Ordinary single-signature contract operations remain available. See scope and migration and designated 2/3 testnet verification.
Implemented modules
- Base transactions, scripts, keys, sighashes, and API access
- Random private keys, WIF import, English BIP39 mnemonics, and BIP32 xprv/xpub keys
- FT mint, transfer, batch transfer, and merge
- NFT collection creation, mint, batch mint, and transfer
- StableCoin creation, mint, transfer, batch transfer, and merge
- OrderBook buy/sell order creation, matching, and cancellation
- TBC-native MultiSig wallet creation plus distributed TBC/FT build, sign, and finish flows for ordinary Token only: legacy FT v1–v4, intermediate TBC20 and TBC20 Standard. Legacy/modern Stablecoin, LP and locked LP are excluded from MultiSig construction/signing/finalization (token generations, surface and security model, testnet evidence)
- PoolNFT v2 creation, liquidity, swaps, FTLP lifecycle, and query-backed explicit-context resolution (API mapping and creation authority, testnet evidence); PoolNFT v1 is not supported
- TBC20 source/genesis mint, transfer/change, merge, address and contract controllers (API)
- TBC20/FT source-graph validation with strict and relaxed-metadata policies, including automatic network API resolution (API)
Core primitives implement current TBC version-10 transactions, with
tbc-lib-js@1.0.31 as the JavaScript reference: raw serialization/deserialization,
TBC header-based txids, ForkID signing, keys/addresses, and HD wallet derivation.
Transaction::txid() always uses the TBC header hash. It does not implement the
JavaScript library's legacy full-raw hashing branch for transaction versions below
10. The transaction version is independent of the contract package version.
New-generation builders target tbc-contract@1.7.4: TBC20 Standard,
TBC721 Standard, Stablecoin, AMM/LP, LOP, HTLC and Timelock. Existing contract
modules remain available. HTLC deployments now use v2 with exactly 32-byte
preimages; existing v1 outputs remain spendable. See the 1.7.4 migration and
offline verification report. The
1.7.3 compatibility matrix and actual testnet
evidence describes supported operations and remaining
facade/indexer limitations; this is not a claim of complete JS API parity.
For historical Pool/MultiSig example tests, run
node scripts/setup-reference-165.js once to install the pinned reference in
isolated worktrees, then run cargo test --all-targets.
Stablecoin pools and deprecated PoolNFT v1 are outside the supported scope.
See the Pool verification report for the
parameter matrix, historical locked-LP failures, and successful testnet rechecks.
Minimal usage
use ;
let api = main;
let tx = new;
assert_eq!;
assert!;
Wallets and HD keys
Create a standalone random private key directly from the operating system's secure random source:
use PrivateKey;
Generate or restore an English BIP39 mnemonic, then derive the default TBC
account path m/44'/236'/0'/1/0:
use ;
HdNetwork::Mainnet serializes xprv/xpub and HdNetwork::Testnet serializes
tprv/tpub. An extended public key can derive only non-hardened children;
hardened derivation requires the extended private key.
Development
In 0.3.0, every supported signed builder finalizes the fee from the exact post-signature transaction size at 80 sat/KB. Signature-length changes are handled with a non-decreasing target, and a builder returns an explicit error instead of an under-target fallback if finalization cannot converge.
License
MIT