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.
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 as the channel moves through the following states:
Send 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.
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.