@stochain/wallet-sdk
v1.0.3
Published
Blockchain wallet SDK for BSC and Cosmos networks
Maintainers
Readme
@stochain/wallet-sdk
Blockchain wallet SDK for BSC and Cosmos networks with React Native support.
Installation
npm install @stochain/wallet-sdk ethersFeatures
- 🔐 Generate BSC wallets
- 🌌 Generate Cosmos wallets
- 🔑 Import from private key or mnemonic
- ✅ Address validation
- 💰 Balance queries
- 📤 Transaction handling
- 🔄 Provider management
Usage
BSC Wallet
import { generateBscWallet, importBscWalletFromMnemonic } from '@stochain/wallet-sdk';
// Generate new wallet
const wallet = await generateBscWallet();
console.log(wallet.address);
console.log(wallet.privateKey);
console.log(wallet.mnemonic);
// Import from mnemonic
const importedWallet = importBscWalletFromMnemonic(
'your twelve word mnemonic phrase here'
);Cosmos Wallet
import { generateCosmosWallet } from '@stochain/wallet-sdk';
// Generate new wallet
const wallet = await generateCosmosWallet('cosmos');
console.log(wallet.address);
console.log(wallet.privateKey);
console.log(wallet.mnemonic);Transaction Management
import {
fromMnemonic,
getBalance,
sendTransaction
} from '@stochain/wallet-sdk';
import { ethers } from 'ethers';
const provider = new ethers.providers.JsonRpcProvider('YOUR_RPC_URL');
const wallet = await fromMnemonic(['your', 'mnemonic', 'words'], provider);
// Get balance
const balance = await getBalance(wallet);
// Send transaction
const tx = {
to: '0x...',
value: ethers.utils.parseEther('0.1'),
gasLimit: 21000
};
const response = await sendTransaction(wallet, tx);API Reference
BSC Functions
generateBscWallet(): Generate new BSC walletimportBscWalletFromPrivateKey(privateKey): Import from private keyimportBscWalletFromMnemonic(mnemonic, path?): Import from mnemonicisValidBscAddress(address): Validate BSC address
Cosmos Functions
generateCosmosWallet(prefix?): Generate new Cosmos walletimportCosmosWalletFromMnemonic(mnemonic, path?): Import from mnemonicisValidCosmosAddress(address, prefix?): Validate Cosmos address
Wallet Functions
generateMnemonics(): Generate random mnemonicfromMnemonic(mnemonics, provider): Create wallet from mnemonicfromPrivateKey(privateKey, provider): Create wallet from private keygetBalance(wallet): Get wallet balancesendTransaction(wallet, tx): Send transactiongetGasPrice(provider): Get current gas priceestimateGas(provider, tx): Estimate gas for transaction
License
MIT
