Early release. This is published in
@uzolabs/sdk 0.2.0 on npm and you can use it today. The API may change before 1.0, so pin the version.What you’ll build
A script that connects ethers to BOT Chain testnet and quotes a WBOT to USDT swap on BDEX V2, using only data from the SDK.Prerequisites
- Node.js 20 or later.
npm install ethers@6 @uzolabs/sdk viem. viem is a peer dependency of the SDK, so it has to be installed, but your code doesn’t call it.
How the pieces fit
You lose viem’s type inference: ethers returns
any for contract calls unless you add your own types or use a generator such as TypeChain.
Steps
1
Create a provider
Pass the chain ID and name as a static network, so ethers doesn’t need to detect it on every start.
provider.ts
2
Read a quote
ethers-quote.ts
npx tsx ethers-quote.ts.3
Send a transaction
To write, connect a
Wallet that reads its key from the environment, and call the contract through it:signer.ts
new Contract(address, abi, signer) then sends transactions. Approvals and swaps follow the same steps as Swap on BDEX V2.Verify
The quote script prints a USDT amount for 1 tBOT. Compare it with the viem version in BDEX V2: both read the same router, so the numbers match when run in the same block.Troubleshooting
TypeError: invalid BytesLike value or missing ABI
TypeError: invalid BytesLike value or missing ABI
Check the import path. ABIs come from
@uzolabs/sdk/contracts, not the package root.Errors thrown by the SDK
Errors thrown by the SDK
getAddresses throws UnsupportedChainError for a chain ID other than 677 or 968. ethers’ own errors, such as CALL_EXCEPTION, come from ethers, not the SDK.Next steps
ABIs
Every ABI the SDK ships.
Addresses
What
getAddresses returns.