trustid-sdk
v1.1.11
Published
[](https://www.npmjs.com/package/trustid-sdk) [](https://opensource.org/licenses/MIT)
Readme
🔐 TrustId SDK
A JavaScript SDK to connect with the TrustId browser extension, perform KYC checks, create/import wallets using Bech32, and interact with the TrustId blockchain.
✨ Features
- 🔗 Connect with TrustId browser extension
- 🧾 Request user KYC data
- 🔐 Retrieve secure access tokens
- 💳 Create/Import wallets with Bech32 (
trustprefix) - 🧬 Register and verify KYC data on the TrustId chain
- 📦 Sign and send transactions
- 🔍 Fetch block, transaction, and account data
📦 Installation
npm install trustid-sdk
🚀 Quick Start
1. Initialize SDK
import TrustIdSDK from "trustid-sdk";
const trustId = new TrustIdSDK({
apiKey: "YOUR_API_KEY",
apiUrl: "https://your-backend.com",
});
2. Connect to TrustId Extension
await trustId.connect();
if (trustId.isConnected) {
console.log("Connected to TrustId");
}
3. Get KYC Data
const kycResult = await trustId.getKYCData();
console.log(kycResult);
4. Get Access Token
const tokenResult = await trustId.getAccessToken();
console.log(tokenResult);
💳 Wallet Management (Bech32)
Create New Wallet
const wallet = await trustId.createWallet();
console.log(wallet);
/*
{
mnemonic,
privateKey,
publicKey,
address,
}
*/
Import Wallet (Mnemonic or Private Key)
// Use either mnemonic or private key
const wallet = await trustId.importWallet("your mnemonic or privateKey");
console.log(wallet);
🧾 Chain Actions (TrustId Chain)
Method Description
createWallet() Create wallet using Bech32 address (prefix: trust)
importWallet() Import wallet using private key or mnemonic
registerWallet() Register KYC data on-chain with the wallet
verifyRegister() Verify wallet-KYC connection
getUserInfo() Get user info via extension or gRPC
getTransactions() Get all transactions from a given block number
getTransactionInfo() Get transaction detail using hash
getCurrentBlock() Get latest block number
signTransaction() Sign transaction with private key
personal.sign() Sign data without exposing private key
sendTransaction() Broadcast signed transaction to the chain
account() Get full account info (balances, etc.)
🧪 React Usage Example
import React, { useEffect } from "react";
import TrustIdSDK from "trustid-sdk";
const trustId = new TrustIdSDK({
apiKey: "YOUR_API_KEY",
apiUrl: "https://your-backend.com",
});
export default function WalletConnect() {
useEffect(() => {
trustId.connect().then(() => {
if (trustId.isConnected) console.log("Connected to TrustId");
});
}, []);
const createWallet = async () => {
const wallet = await trustId.createWallet();
console.log(wallet);
};
return (
<button onClick={createWallet}>Create Wallet</button>
);
}
🛡️ Error Handling
Use try/catch with all SDK calls:
try {
const wallet = await trustId.createWallet();
} catch (err) {
console.error("Wallet creation failed:", err.message);
}
📄 License
MIT
🙋 Support
For bugs, suggestions, or contributions, open an issue on GitHub or contact the maintainers.
🔢 Error Code Format
Based on character positions of trustid:
t=20, r=18, u=21, s=19, t=20, i=9, d=4 → 201821192094
Last 3 digits represent action:
Wallet Creation: 201821192094-233
Wallet Import: 201821192094-239
🧼 Deprecated Features (Removed)
The following features were present in older versions and have been removed:
Camera detection
Face detection and liveness check
Face-based login using face-api.js
You can now:
1. **Replace your existing `README.md`** with the content above.
2. Run `npm version patch` or `npm version minor` depending on your change.
3. Run `npm publish` to upload the new version of your SDK.
Let me know if you want to include a `CHANGELOG.md` or auto-generate GitHub documentation pages.