Node.js & Bare 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:
Prerequisites
Before we start, make sure you have:
Node.js
20+
To run JavaScript code
npm
Latest
To install packages
Code Editor
Any
To write code
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 -yThen install necessary WDK modules
npm install @tetherto/wdk @tetherto/wdk-wallet-evm @tetherto/wdk-wallet-tron @tetherto/wdk-wallet-btcStep 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'
async function main() {
console.log('Starting WDK App...')
try {
// Your code will go here
} catch (error) {
console.error('Application error:', error.message)
}
}
// Run the application
main()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)
}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, {
provider: 'https://blockstream.info/api'
})
console.log('Wallets registered for Ethereum, TRON, and Bitcoin')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'
async function main() {
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, {
provider: 'https://blockstream.info/api'
})
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!')
} catch (error) {
console.error('Application error:', error.message)
}
}
// Run the application
main()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:
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, {
provider: 'https://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 SwapveloraEvm from '@tetherto/wdk-protocol-swap-velora-evm'
wdk.registerProtocol('swap-velora-evm', SwapveloraEvm)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

