Open a Fiber Channel and Send a Payment
Fund your browser node, open a real Fiber Testnet channel, and send 1 CKB to a public peer. Testnet confirmations may take longer than the active tutorial time.
Need background on browser nodes? Review Connect to Fiber with a WASM Node.
Prepare node. Start and connect.
Fund address. Receive Testnet CKB.
Open channel. Commit the peer minimum on-chain.
Send payment. Send CKB to the peer.
—stateReady to startconnectionOfflineBehind the scenes
Follow the data and SDK calls that prepare the node, fund and open the channel, then confirm the payment.
Understand the channel payment flow
openChannel() locks a chosen amount of Testnet CKB on-chain. Once the channel is ready, pay() can make multiple off-chain payments without creating a new CKB transaction for every small amount.
Preparing the node starts it locally and connects it to the public peer. Opening the channel and sending payments are separate actions.
Start the node and derive its funding address
start() starts the browser node and reveals the Testnet address that must be funded. It calls startFiber(), reads the node information, and uses scriptToAddress() to convert default_funding_lock_script into its Testnet address.
The demo combines startup and connectToRouter() into one preparation action. The downloaded source keeps the helpers separate, so an application can expose more control when needed.
Node already in use: close the other tutorial tab to stop its saved node session, then select Prepare browser node here. Peer handshake timed out: the node is running; check your network and select Prepare browser node again to retry the connection. If timeouts continue, the public peer may be unavailable.
Detect sufficient Testnet funding
queryCkbBalance() calls CKB RPC get_cells_capacity to measure the address's available capacity. watchCkbBalance() repeats the check every five seconds while the page is visible, allowing the interface to unlock channel creation once the address can cover the funding amount.
The public peer accepts CKB channels at or above 499 CKB. Keep extra Testnet CKB available for the transaction fee.
Convert CKB amounts without losing precision
ckbToHex() converts the entered CKB amount into the exact hexadecimal shannon value expected by Fiber RPC. It uses BigInt to avoid floating-point rounding across CKB's eight decimal places.
499 CKB49,900,000,000 shannons0xb9e0ab300Open the channel
openCkbChannel() begins channel negotiation with the connected public peer. It calls node.openChannel() with the peer pubkey, the exact funding amount, and public: true.
Its temporary channel ID confirms negotiation started; it does not mean the channel can carry a payment yet.
lib/channel.ts · lines 7–19Wait for ChannelReady
watchChannelStates() keeps payment controls locked until the funding transaction and peer handshake complete. It polls listChannels() and reports each new state_name, displayed in the same uppercase format as the multi-hop tutorial, as the channel moves through the following states:
This may take up to 1 min. The progress display lists all six stages, highlights the current state, and marks earlier stages complete. Some transitions happen between polls, so the event log may skip a state. Keep the node running while it progresses. If it stays in one state for more than a minute, refresh the live state, check the peer connection, and inspect the funding transaction in the explorer when available. A longer Testnet confirmation wait does not by itself mean the operation failed; avoid opening another channel while this one is pending.
lib/channel.ts · lines 21–40Send and confirm the keysend payment
sendKeysend() sends a direct payment without first requesting an invoice. Fiber calls this a keysend payment because it does not require the receiving peer to create an invoice. The function calls sendPayment() with the recipient pubkey, amount, and keysend: true.
If the response is still in flight, waitForPayment() waits for Success or Failed. The demo then shows the payment hash and the channel's local balance before and after. Use the copy icons for the full channel ID, payment hash, or funding-transaction explorer link. A tooltip confirms successful copying. The funding link appears once the node reports the transaction outpoint.
Wire the complete flow into React
PayPage() turns SDK state into a guided interface. It keeps the node in a ref, renders funding and channel state from React state, and gates each state-changing button on the prerequisite it needs.
A production product should also encrypt keys, support backup and recovery, surface fees and timeouts, and use server-side verification when payments unlock orders or access.
Run the complete project locally
Select Download project in the top-right corner, or download here. The archive contains the Next.js application, Fiber integration, required browser headers, and the interface shown here.
npm install
npm run devThen open http://localhost:3000/pay in your browser.