Node.js & Bare Runtime Quickstart
Get started with WDK in Node.js or Bare runtime environments in 3 minutes
What You'll Build
In this quickstart, you'll create a simple application that:
- Sets up WDK with multiple blockchain wallets (EVM, Bitcoin, TRON)
- Generates a new secret phrase (seed phrase)
- Resolves addresses across different chains
- Checks balances and estimates transaction costs
- Sends transactions on multiple blockchains
Want to build faster? Connect your AI coding assistant to WDK docs for context-aware help. Learn how →
Prerequisites
Before we start, make sure you have:
| Tool | Version | Why You Need It |
|---|---|---|
| Node.js | 20+ | To run JavaScript code |
| npm | Latest | To install packages |
| Code Editor | Any | To write code |
You can try all features without real funds required. You can use the Pimlico or Candide faucets to get some Sepolia USD₮.
Get mock/test USD₮ on Pimlico Get mock/test USD₮ on Candide
See the configuration for quick setup and Sepolia testnet configuration.
Step 1: Set Up Your Project
First, we need to create a folder and initialize the project
mkdir wdk-quickstart && cd wdk-quickstart && npm init -y && npm pkg set type=moduleThen install necessary WDK modules
npm install @tetherto/wdk @tetherto/wdk-wallet-evm @tetherto/wdk-wallet-tron @tetherto/wdk-wallet-btcLearn more about WDK modules:
- @tetherto/wdk - The main SDK module
- @tetherto/wdk-wallet-evm - Ethereum and EVM-compatible chains support
- @tetherto/wdk-wallet-tron - TRON blockchain support
- @tetherto/wdk-wallet-btc - Bitcoin blockchain support
Step 2: Create Your First Wallet
Create a file called app.js:
import WDK from '@tetherto/wdk'
import WalletManagerEvm from '@tetherto/wdk-wallet-evm'
import WalletManagerTron from '@tetherto/wdk-wallet-tron'
import WalletManagerBtc from '@tetherto/wdk-wallet-btc'
console.log('Starting WDK App...')
try {
// Your code will go here
} catch (error) {
console.error('Application error:', error.message)
process.exit(1)
}Now, add the following code to generate a seed phrase:
try {
const seedPhrase = WDK.getRandomSeedPhrase()
console.log('Generated seed phrase:', seedPhrase)
} catch (error) {
console.error('Application error:', error.message)
process.exit(1)
}Now, let's register wallets for different blockchains:
// Add this code after the seed phrase generation
console.log('Registering wallets...')
const wdkWithWallets = new WDK(seedPhrase)
.registerWallet('ethereum', WalletManagerEvm, {
provider: 'https://eth.drpc.org'
})
.registerWallet('tron', WalletManagerTron, {
provider: 'https://api.trongrid.io'
})
.registerWallet('bitcoin', WalletManagerBtc, {
network: 'mainnet',
host: 'electrum.blockstream.info',
port: 50001
})
console.log('Wallets registered for Ethereum, TRON, and Bitcoin')To learn more about configuring the wallet modules:
Step 3: Check Balances
To check balances, we first need to get accounts and addresses. Let's get accounts and addresses for all blockchains:
// Add this code after the wallet registration
console.log('Retrieving accounts...')
const accounts = {
ethereum: await wdkWithWallets.getAccount('ethereum', 0),
tron: await wdkWithWallets.getAccount('tron', 0),
bitcoin: await wdkWithWallets.getAccount('bitcoin', 0)
}
console.log('Resolving addresses:')
for (const [chain, account] of Object.entries(accounts)) {
const address = await account.getAddress()
console.log(` ${chain.toUpperCase()}: ${address}`)
}Now, let's check balances across all chains:
// Add this code after the address resolution
console.log('Checking balances...')
for (const [chain, account] of Object.entries(accounts)) {
const balance = await account.getBalance()
console.log(` ${chain.toUpperCase()}: ${balance.toString()} units`)
}Here is the complete app.js file:
import WDK from '@tetherto/wdk'
import WalletManagerEvm from '@tetherto/wdk-wallet-evm'
import WalletManagerTron from '@tetherto/wdk-wallet-tron'
import WalletManagerBtc from '@tetherto/wdk-wallet-btc'
console.log('Starting WDK App...')
try {
const seedPhrase = WDK.getRandomSeedPhrase()
console.log('Generated seed phrase:', seedPhrase)
console.log('Registering wallets...')
const wdkWithWallets = new WDK(seedPhrase)
.registerWallet('ethereum', WalletManagerEvm, {
provider: 'https://eth.drpc.org'
})
.registerWallet('tron', WalletManagerTron, {
provider: 'https://api.trongrid.io'
})
.registerWallet('bitcoin', WalletManagerBtc, {
network: 'mainnet',
host: 'electrum.blockstream.info',
port: 50001
})
console.log('Wallets registered for Ethereum, TRON, and Bitcoin')
const accounts = {
ethereum: await wdkWithWallets.getAccount('ethereum', 0),
tron: await wdkWithWallets.getAccount('tron', 0),
bitcoin: await wdkWithWallets.getAccount('bitcoin', 0)
}
console.log('Resolving addresses:')
for (const [chain, account] of Object.entries(accounts)) {
const address = await account.getAddress()
console.log(` ${chain.toUpperCase()}: ${address}`)
}
console.log('Checking balances...')
for (const [chain, account] of Object.entries(accounts)) {
const balance = await account.getBalance()
console.log(` ${chain.toUpperCase()}: ${balance.toString()} units`)
}
console.log('Application completed successfully!')
process.exit(0)
} catch (error) {
console.error('Application error:', error.message)
process.exit(1)
}Step 4: Run Your App
Execute your app:
node app.jsYou should see an output similar to this:
Starting WDK App...
Generated seed phrase: abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about
Registering wallets...
Wallets registered for Ethereum, TRON, and Bitcoin
Resolving addresses:
ETHEREUM: 0x742d35Cc6634C0532925a3b8D9C5c8b7b6e5f6e5
TRON: TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH
BITCOIN: 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
Checking balances...
ETHEREUM: 0 units
TRON: 0 units
BITCOIN: 0 units
Application completed successfully!What Just Happened?
Congratulations! You've successfully created your first multi-chain WDK application that works in both Node.js and Bare runtime environments. Here's what happened:
- You generated a single seed phrase that works across all blockchains
- You registered wallets for Ethereum, TRON, and Bitcoin
- You created accounts derived from the same seed phrase using BIP-44
- You used the same API to interact with different blockchains
- You checked balances across multiple chains with consistent methods
Next Steps
Now that you have a basic multi-chain wallet running, here's what you can explore:
Add More Blockchains
For example, to add Solana support:
npm install @tetherto/wdk-wallet-solanaimport WalletManagerSolana from '@tetherto/wdk-wallet-solana'
// New or existing WDK instance
const wdk = new WDK(seedPhrase)
wdk.registerWallet('solana', WalletManagerSolana, {
rpcUrl: 'https://api.mainnet-beta.solana.com',
wsUrl: 'wss://api.mainnet-beta.solana.com'
})Estimate Transaction Costs
for (const [chain, account] of Object.entries(accounts)) {
try {
const quote = await account.quoteSendTransaction({
to: await account.getAddress(),
value: chain === 'bitcoin' ? 100000000n : chain === 'tron' ? 1000000n : 1000000000000000000n
})
console.log(` ${chain.toUpperCase()}: ${quote.fee.toString()} units`)
} catch (error) {
console.log(` ${chain.toUpperCase()}: Unable to estimate`)
}
}Send Transactions
const result = await ethAccount.sendTransaction({
to: '0x742d35Cc6634C05...a3b8D9C5c8b7b6e5f6e5',
value: 1000000000000000000n // 1 ETH
})
console.log('Transaction hash:', result.hash)Use DeFi Protocols
npm install @tetherto/wdk-protocol-swap-velora-evmimport VeloraProtocolEvm from '@tetherto/wdk-protocol-swap-velora-evm'
wdk.registerProtocol('ethereum', 'swap-velora-evm', VeloraProtocolEvm, {
provider: 'https://eth.drpc.org'
})Troubleshooting
Common Issues
"Provider not connected"
- Check your API keys and network connections
- Ensure you're using the correct provider URLs
"Insufficient balance"
- This is normal for new addresses
- Use testnet faucets to get test tokens
"Module not found"
- Make sure you've installed all required packages
- Check your import statements