Skip to main content
In this guide you wrap native tBOT into WBOT, an ERC-20 token, and unwrap it again, using a viem script on testnet.
Everything on this page uses testnet (chain 968). Get free test tokens from the faucet.

Why wrap

BOT is the native coin, so it has no ERC-20 functions such as approve and transferFrom. DeFi contracts like BDEX pools work with ERC-20 tokens. WBOT is BOT inside an ERC-20 contract: you deposit BOT and get the same amount of WBOT, and you can withdraw it 1:1 at any time. WBOT has 18 decimals and lives at 0xD5452816194a3784dBa983426cCe7c122F4abd30 on both mainnet and testnet.
You don’t always need to wrap by hand. Routers can wrap for you: BDEX V2 has ETH functions such as swapExactETHForTokens, and the V3 SwapRouter wraps the value you send. See Swaps on BDEX.

Prerequisites

  • Node.js 22 or later.
  • At least 0.003 tBOT in your testnet wallet. See Get testnet tokens.

Steps

1

Create the project

2

Add your testnet key

.env
Only put a testnet key in .env, and add .env to .gitignore before your first commit.
3

Write the script

wrap-bot.ts
  • deposit() is payable. The value you send becomes WBOT.
  • withdraw(amount) burns WBOT and sends you the same amount of tBOT.
  • wbotAbi comes from @uzolabs/sdk/contracts. Any standard WETH9-style ABI works too.
4

Run it

Verify it worked

Output
You wrapped 0.002 and unwrapped 0.001, so you keep 0.001 WBOT. Your tBOT went down by 0.002 plus gas for the two transactions.

Troubleshooting

You need tBOT for both the deposit and gas. Lower the amount or top up from the faucet.
You tried to unwrap more WBOT than you hold. Check the WBOT balance first.
Import it as a custom token with the address above, symbol WBOT and 18 decimals.

Next steps

Swap on BDEX V2

Swap your WBOT for USDT.

USDT and decimals

Avoid the most common amount bug.
Last modified on October 2, 2026