A comprehensive guide for testing the MOTO Bitcoin wallet application using ckTESTBTC (testnet) instead of real BTC, allowing safe experimentation without spending money.
- Localhost Setup
- Testnet Configuration
- Getting Testnet Bitcoin
- Testing Workflows
- Monitoring and Debugging
- Switching to Mainnet
- Troubleshooting
- Resources
Before you begin, ensure you have the following installed:
- dfx (ICP SDK) version 0.29.2 or later
- Node.js 18+ and npm/yarn
- A terminal with bash or zsh
Ensure you're in the project root (the directory containing dfx.json).
dfx --versionIf dfx is not found, add it to your PATH:
# For bash
source ~/.profile
# For zsh
source ~/.zshenvOpen Terminal 1 and run:
dfx startKeep this terminal running. This starts:
- Local Internet Computer network
- Internet Identity canister (for authentication)
- Available at
http://localhost:4943
Note: You'll see output indicating the network is running. Don't close this terminal.
Open Terminal 2 (new terminal window, from project root) and run:
dfx deployThis will:
- Deploy the
motobackend canister (Motoko) - Deploy the
moto_frontendfrontend canister - Generate canister IDs
Still in Terminal 2, run:
dfx generateThis creates TypeScript types from the Motoko backend that your frontend uses.
Get your canister ID:
dfx canister id motoCreate a .env file in the frontend/ directory:
cd frontend
echo "VITE_CANISTER_ID_MOTO=$(cd .. && dfx canister id moto)" > .envOr manually create frontend/.env with:
VITE_CANISTER_ID_MOTO=YOUR_CANISTER_ID_HERE
VITE_DFX_NETWORK=localIf you haven't already:
cd frontend
npm installOpen Terminal 3 (new terminal window) and run:
cd frontend
npm run devThe frontend should now be running, typically at http://localhost:5173 (or another port if 5173 is busy).
- Open your browser and navigate to the frontend URL (e.g.,
http://localhost:5173) - You should see the login screen
- Click "Login" and you should be redirected to Internet Identity
- For local development, Internet Identity is available at:
http://localhost:4943/?canisterId=rdmx6-jaaaa-aaaah-qcayq-cai
- Create a new Internet Identity or use an existing one
- After authentication, you should be redirected back to the app
✅ Setup Complete! Your local development environment is now running.
To use ckTESTBTC (testnet) instead of real ckBTC, you need to enable testnet mode.
- Edit the
.envfile in thefrontend/directory:
cd frontend
nano .env
# or use your preferred editor- Add the testnet flag:
VITE_USE_TESTNET=true
VITE_CANISTER_ID_MOTO=YOUR_CANISTER_ID_HERE
VITE_DFX_NETWORK=local- Restart the frontend dev server:
# Stop the current dev server (Ctrl+C in Terminal 3)
# Then restart it:
npm run devWhen testnet mode is enabled, you should see:
-
Yellow banner at the top of the app:
⚠️ TESTNET MODE - Using ckTESTBTC (not real BTC) -
Console logs showing:
Network mode: TESTNET (ckTESTBTC) -
Testnet canister IDs in console:
- Minter:
ml52i-qqaaa-aaaar-qaaba-cai - Ledger:
mc6ru-gyaaa-aaaar-qaaaq-cai
- Minter:
| Feature | Testnet (ckTESTBTC) | Mainnet (ckBTC) |
|---|---|---|
| Token | ckTESTBTC (test tokens) | ckBTC (real tokens) |
| Bitcoin Network | Bitcoin Testnet | Bitcoin Mainnet |
| Address Prefix | tb1, m, or n |
bc1 |
| Cost | Free (from faucets) | Real BTC |
| Minter Canister | ml52i-qqaaa-aaaar-qaaba-cai |
mqygn-kiaaa-aaaar-qaadq-cai |
| Ledger Canister | mc6ru-gyaaa-aaaar-qaaaq-cai |
mxzaz-hqaaa-aaaar-qaada-cai |
- Open your app (with testnet enabled)
- Sign in with Internet Identity
- Navigate to the Receive screen
- Copy the Bitcoin address shown (this is a testnet address when testnet mode is enabled)
- The address will typically start with
tb1,m, orn(testnet prefixes)
Important: Make sure you're using the address from the app, not from NNS. The app generates an address specific to your app's principal ID.
Use one or more of these Bitcoin testnet faucets:
- Bitcoin Testnet Faucet - https://bitcoinfaucet.uo1.net/
- Mempool Testnet Faucet - https://testnet-faucet.mempool.co/
- CoinFaucet - https://coinfaucet.eu/en/btc-testnet/
- Testnet Faucet - https://testnet-faucet.com/btc-testnet/
Process:
- Paste your testnet Bitcoin address
- Complete any captcha or verification
- Request TestBTC (usually 0.001-0.01 TestBTC per request)
- Wait for the transaction to confirm (usually 1-10 minutes)
Note: Faucets have rate limits. You may need to:
- Wait between requests
- Use multiple faucets
- Request from different IP addresses if needed
-
Send TestBTC to your app's address:
- Use a testnet Bitcoin wallet (e.g., Electrum in testnet mode)
- Send a small amount (0.001-0.01 TestBTC) to the address from your app
- Wait for the transaction to confirm on Bitcoin testnet
-
Wait for ckBTC Minter to process:
- The ckBTC minter monitors Bitcoin testnet for deposits
- Processing usually takes 10-30 minutes
- The minter converts TestBTC to ckTESTBTC automatically
-
Verify the deposit:
- Check your app's balance (should show ckTESTBTC)
- Look for the yellow "TESTNET MODE" banner
- Check browser console logs for balance updates
-
In the app:
- Your balance should update automatically
- Check the transaction history for the deposit
-
In browser console:
- Look for logs like:
✅✅✅ BALANCE FOUND! ✅✅✅ Balance: [amount] satoshis Balance: [amount] BTC
- Look for logs like:
-
On testnet dashboard:
- Visit: https://dashboard.internetcomputer.org/testbtc
- Check your principal ID's balance
-
Generate a new receive address:
- Open the app
- Go to "Receive" screen
- Copy the address or scan the QR code
-
Send TestBTC to the address:
- Use a testnet Bitcoin wallet
- Send a small amount (0.001 TestBTC)
- Wait for confirmation
-
Verify receipt:
- Check balance updates in the app
- Verify transaction appears in history
- Check console logs for confirmation
-
Ensure you have ckTESTBTC balance:
- You need a positive balance to send
-
Get a recipient address:
- Use another testnet address (can be from another app instance or a test wallet)
- Or generate a new address in your app
-
Send transaction:
- Open "Send" screen
- Enter recipient address
- Enter amount
- Confirm transaction
-
Verify send:
- Check balance decreases
- Verify transaction appears in history
- Check console logs for transaction details
-
Very small amounts:
- Send 0.00001 TestBTC
- Verify it appears correctly
-
Maximum balance:
- Send your entire balance
- Verify transaction succeeds
-
Insufficient balance:
- Try to send more than your balance
- Verify error handling works correctly
-
Invalid addresses:
- Try sending to an invalid address
- Verify error messages are clear
-
Multiple transactions:
- Send multiple transactions in quick succession
- Verify all appear in history correctly
-
Network errors:
- Temporarily disconnect internet
- Verify error messages appear
- Reconnect and verify recovery
-
Timeout handling:
- Test with slow network
- Verify timeouts are handled gracefully
-
Principal mismatch:
- Check console for principal verification warnings
- Verify error messages explain the issue
The app includes comprehensive logging. Open browser DevTools (F12) and check the Console tab.
On App Load:
useCkBTCMinter: Network mode: TESTNET (ckTESTBTC)
useCkBTCLedger: Network mode: TESTNET (ckTESTBTC)
Principal Information:
⚠️ IMPORTANT: This address is generated for the app-specific principal ID
Principal: [your-principal-id]
This principal is DIFFERENT from your NNS top-level principal
Balance Queries:
useCkBTCLedger: Querying balance for default subaccount...
useCkBTCLedger: Default subaccount balance: [amount] satoshis
Success Messages:
✅✅✅ BALANCE FOUND! ✅✅✅
Balance: [amount] satoshis
Balance: [amount] BTC
Principal: [your-principal-id]
Warning Messages:
⚠️⚠️⚠️ BALANCE IS ZERO ⚠️⚠️⚠️
Important: Internet Identity creates a unique principal ID for each app. This means:
-
App-specific principal (shown in app menu):
- Different for each app you use
- Used for address generation and balance queries
- Shown in the app's menu under "MOTO Principal ID"
-
NNS top-level principal (shown in NNS):
- Your master principal ID
- Different from app-specific principals
- Used for NNS governance
Verification Steps:
-
Check principal in app:
- Open menu in the app
- Note the "MOTO Principal ID"
- This is the principal used for your wallet
-
Check console logs:
- Look for principal IDs in console
- Verify they match between:
- Address generation (minter)
- Balance query (ledger)
-
Principal mismatch warning:
- If you see a warning about principal mismatch, it means:
- The address was generated with one principal
- The balance is being queried with a different principal
- Solution: Sign out and sign in again with the same Internet Identity
- If you see a warning about principal mismatch, it means:
-
Real-time updates:
- Balance polls every 10 seconds
- Check console for polling messages
-
Balance verification:
- Compare app balance with console logs
- Verify amounts match
-
Transaction history:
- Check transaction list in app
- Verify transactions appear correctly
- Check timestamps and amounts
-
Send transactions:
- Check console for transaction initiation
- Verify transaction ID is generated
- Check for success/error messages
-
Receive transactions:
- Monitor for new balance updates
- Check transaction appears in history
- Verify amounts are correct
When you're ready to use real ckBTC:
Edit frontend/.env:
VITE_USE_TESTNET=false
# or remove the line entirely
VITE_CANISTER_ID_MOTO=YOUR_CANISTER_ID_HERE
VITE_DFX_NETWORK=local# Stop the current dev server (Ctrl+C)
# Then restart:
npm run dev- Yellow banner should disappear
- Console logs should show:
Network mode: MAINNET (ckBTC) - Canister IDs should be mainnet:
- Minter:
mqygn-kiaaa-aaaar-qaadq-cai - Ledger:
mxzaz-hqaaa-aaaar-qaada-cai
- Minter:
- Get a real Bitcoin address from the app
- Send real BTC to that address
- Wait for conversion to ckBTC (10-30 minutes)
- Your balance will show real ckBTC
Symptoms:
- App shows 0 balance
- Console shows "BALANCE IS ZERO" warning
Possible Causes:
-
Principal ID Mismatch:
- You sent BTC to an address generated with a different principal
- Solution: Sign out and sign in again. Make sure you're using the same Internet Identity.
-
Deposit Not Processed:
- Bitcoin deposit hasn't been converted to ckBTC yet
- Solution: Wait 10-30 minutes. Check the ckBTC minter status.
-
Wrong Network:
- Sent mainnet BTC to testnet address (or vice versa)
- Solution: Verify you're using the correct network mode.
-
Wrong Subaccount:
- Balance might be on a different subaccount
- Solution: Check console logs for subaccount information.
Debugging Steps:
- Check console logs for principal ID
- Verify the address you sent to matches the one in the app
- Check if testnet/mainnet mode matches your transaction
- Verify the deposit on Bitcoin blockchain explorer
- Check ckBTC minter status
Symptoms:
- No yellow testnet banner
- Console shows mainnet canister IDs
Solution:
- Check
.envfile hasVITE_USE_TESTNET=true - Restart the dev server
- Clear browser cache
- Hard refresh the page (Ctrl+Shift+R or Cmd+Shift+R)
Symptoms:
- Faucets say "rate limited" or "out of funds"
Solutions:
- Try different faucets
- Wait 24 hours and try again
- Use a VPN to change IP address
- Request smaller amounts
- Check faucet status pages
Symptoms:
- Error when trying to get receive address
- Console shows minter errors
Solutions:
- Check internet connection
- Verify testnet canister ID is correct
- Check console for specific error messages
- Try refreshing the page
- Sign out and sign in again
Symptoms:
- Sent transaction but it doesn't show in history
- Balance doesn't update
Solutions:
- Wait a few minutes (transactions can be slow)
- Check console for errors
- Verify transaction on blockchain explorer
- Refresh the page
- Check if transaction is pending
Symptoms:
dfx: command not found
Solutions:
- Restart terminal
- Run:
source ~/.profileorsource ~/.zshenv - Verify dfx is installed:
dfx --version - Check dfx is in PATH:
which dfx
Symptoms:
- Can't authenticate
- Redirects fail
Solutions:
- Make sure
dfx startis running - Check Internet Identity canister is deployed
- Allow popups in browser
- Check browser console for errors
- Try clearing browser cache
- ckBTC Overview: https://internetcomputer.org/docs/defi/chain-key-tokens/ckbtc/overview
- ckBTC API Reference: https://internetcomputer.org/docs/references/ckbtc-reference
- ICP Bitcoin Integration: https://internetcomputer.org/docs/current/developer-docs/integrations/bitcoin/overview
- Internet Identity: https://internetcomputer.org/docs/current/tokenomics/identity-auth/auth-how-to/
- ckTESTBTC Dashboard: https://dashboard.internetcomputer.org/testbtc
- Bitcoin Testnet Explorer: https://blockstream.info/testnet/
- Testnet Faucets:
- dfx SDK: https://internetcomputer.org/docs/current/developer-docs/setup/install/
- Motoko Language: https://internetcomputer.org/docs/current/motoko/main/motoko/
- Candid Interface: https://internetcomputer.org/docs/current/developer-docs/backend/candid/
- Bitcoin Mainnet: https://blockstream.info/
- Bitcoin Testnet: https://blockstream.info/testnet/
- ICP Explorer: https://dashboard.internetcomputer.org/
- Testnet addresses are different from mainnet addresses
- Never send real BTC to a testnet address
- Never send testnet BTC to a mainnet address
- Always verify which network mode you're in
- Each app gets a unique principal ID
- The principal in NNS is different from your app's principal
- Make sure you send BTC to the address shown in the app, not from NNS
- Bitcoin deposits take 10-30 minutes to convert to ckBTC
- Be patient and check console logs for updates
- Don't send multiple deposits if the first one is still processing
- Testnet faucets have rate limits
- Testnet transactions can be slower
- Some testnet services may be unreliable
- When using mainnet, you're dealing with real BTC
- Always double-check addresses before sending
- Start with small amounts to test
- Never share your private keys or seed phrases
# Enable testnet mode
VITE_USE_TESTNET=true
# Your canister ID (from dfx canister id moto)
VITE_CANISTER_ID_MOTO=YOUR_CANISTER_ID_HERE
# Network (local for development)
VITE_DFX_NETWORK=localMainnet:
- Minter:
mqygn-kiaaa-aaaar-qaadq-cai - Ledger:
mxzaz-hqaaa-aaaar-qaada-cai
Testnet:
- Minter:
ml52i-qqaaa-aaaar-qaaba-cai - Ledger:
mc6ru-gyaaa-aaaar-qaaaq-cai
Note: The testnet minter and ledger use different canister IDs. If you encounter issues, verify the canister IDs at https://dashboard.internetcomputer.org/testbtc
- Yellow Banner: Testnet mode is active
- Console Logs: Show network mode and principal IDs
- Address Prefixes:
tb1,m,n= testnet;bc1= mainnet
# Start local network
dfx start
# Deploy canisters
dfx deploy
# Generate TypeScript bindings
dfx generate
# Get canister ID
dfx canister id moto
# Start frontend
cd frontend && npm run devIf you encounter issues not covered in this guide:
- Check browser console for error messages
- Review the troubleshooting section above
- Check the official ICP documentation
- Verify your setup matches the steps in this guide
- Check that all services (dfx, Internet Identity) are running
Happy Testing! 🚀
Remember: Testnet is for testing. Always verify you're in the correct mode before handling real BTC.