Fiber Cheat Code
Quick reference for common Fiber CLI commands, RPC calls, channel operations, and configuration
A quick-reference cheat sheet for Fiber developers and node operators. Keep this page bookmarked for everyday operations.
Node Quick Start
Use Run a Fiber Node for installation and startup steps. This page focuses on command, RPC, and configuration quick references after a node is running.
The default RPC endpoint is http://127.0.0.1:8227. Use --url with fnn-cli to target a different node (e.g. ./fnn-cli --url http://127.0.0.1:8237 info).
HTTP Proxy Issues
If you encounter 503 errors with fnn-cli, run:
export NO_PROXY=127.0.0.1,localhostCaller Perspective
Fiber RPC and CLI commands act on the node you target. In a two-node payment flow, create invoices on the receiver/payee node and send payments from the sender/payer node. Channel balances and configuration are also returned or updated from the local node's perspective.
Common CLI Commands
Node & Peer
| Category | Operation | Run on | Command |
|---|---|---|---|
| Node | List available commands | Any shell | fnn-cli --help |
| Node | View node info | Node being inspected | fnn-cli info |
| Peer | Connect to a peer (by pubkey) | Node initiating the connection | fnn-cli peer connect_peer --pubkey <pubkey> |
| Peer | Connect to a WSS peer (by pubkey) | Browser/WASM-facing or WSS-capable node | fnn-cli peer connect_peer --pubkey <pubkey> --addr-type wss |
| Peer | Connect to a peer (by address) | Node initiating the connection | fnn-cli peer connect_peer --address "/ip4/<ip>/tcp/<port>" |
| Peer | List connected peers | Node being inspected | fnn-cli peer list_peers |
| Peer | Disconnect a peer | Node dropping the connection | fnn-cli peer disconnect_peer --pubkey <pubkey> |
Channel
| Category | Operation | Run on | Command |
|---|---|---|---|
| Channel | Open a CKB channel | Channel initiator / funder | fnn-cli channel open_channel --pubkey <pubkey> --funding-amount <shannons> |
| Channel | Open a UDT channel | Channel initiator / funder | fnn-cli channel open_channel --pubkey <pubkey> --funding-amount <base_units> --funding-udt-type-script '<json>' |
| Channel | List all channels | Node whose local channel state you want | fnn-cli channel list_channels |
| Channel | List pending opens only | Node whose local pending channel state you want | fnn-cli channel list_channels --only-pending true |
| Channel | Close a channel | Either channel participant; caller initiates close | fnn-cli channel shutdown_channel --channel-id <id> --force true |
| Channel | Update channel config | Node whose local forwarding config you want to change | fnn-cli channel update_channel --channel-id <id> --tlc-minimum-value <base_units> |
Invoice & Payment
| Category | Operation | Run on | Command |
|---|---|---|---|
| Invoice | Create a CKB invoice | Receiver / payee | fnn-cli invoice new_invoice --amount 10000000000 --currency Fibt --description "Test" |
| Invoice | Create a UDT invoice | Receiver / payee | fnn-cli invoice new_invoice --amount <base_units> --currency Fibt --udt-type-script '<json>' |
| Invoice | Parse an invoice | Any node or shell targeting a node | fnn-cli invoice parse_invoice --invoice "fibt1..." |
| Payment | Send payment | Sender / payer; not the node that created the invoice | fnn-cli payment send_payment --invoice "fibt1..." |
| Payment | Send keysend payment | Sender / payer | fnn-cli payment send_payment --target-pubkey <pubkey> --amount <shannons> --keysend true |
| Payment | Check payment status | Sender / payer that created the payment session | fnn-cli payment get_payment --payment-hash 0x... |
| Payment | List all payments | Sender / payer whose payment sessions you want | fnn-cli payment list_payments |
Amount encoding differs between CLI and RPC: fnn-cli accepts decimal integers in the underlying unit, while RPC JSON uses hex strings for integer fields. For CKB, the underlying unit is shannons (100000000 = 1 CKB). For UDTs, use the token's base units. fnn-cli does not treat 1000 as 1000 CKB.
RPC Quick Reference
The default RPC endpoint is http://127.0.0.1:8227. All calls use JSON-RPC 2.0.
Node & Peer
| Method | Run on | Description | Key Params |
|---|---|---|---|
node_info | Node being inspected | Get node identity & config | — |
connect_peer | Node initiating the connection | Connect to a remote peer | pubkey, address, save, addr_type |
disconnect_peer | Node dropping the connection | Disconnect from a peer | pubkey |
list_peers | Node being inspected | List connected peers | — |
Channel
| Method | Run on | Description | Key Params |
|---|---|---|---|
open_channel | Channel initiator / funder | Open a new channel | pubkey, funding_amount, public, one_way, funding_fee_rate, funding_udt_type_script |
open_channel_with_external_funding | Initiator whose external wallet controls funding_lock_script | Negotiate a channel funded by an external wallet | pubkey, funding_amount, shutdown_script, funding_lock_script, funding_lock_script_cell_deps |
submit_signed_funding_tx | Same node that called open_channel_with_external_funding | Submit the externally signed funding transaction | channel_id, signed_funding_tx |
accept_channel | Acceptor / node that received the pending open request | Manually accept a pending channel | temporary_channel_id, funding_amount |
list_channels | Node whose local channel state you want | List channels; balances are local perspective | pubkey, include_closed, only_pending |
shutdown_channel | Either channel participant; caller initiates close | Close a channel | channel_id, close_script, fee_rate, force |
update_channel | Node whose local forwarding config you want to change | Update channel parameters | channel_id, tlc_fee_proportional_millionths, tlc_minimum_value, tlc_expiry_delta |
Invoice & Payment
| Method | Run on | Description | Key Params |
|---|---|---|---|
new_invoice | Receiver / payee | Create an invoice and store its preimage locally | amount, currency, description, expiry, udt_type_script |
parse_invoice | Any node | Decode an invoice string | invoice |
send_payment | Sender / payer; not the node that created the invoice | Send a payment | invoice or target_pubkey + amount + keysend |
build_router | Sender / payer route source | Build an explicit route | hops_info, amount, udt_type_script |
send_payment_with_router | Sender / payer route source | Send with a manually supplied route | router, invoice or keysend |
get_payment | Sender / payer that created the payment session | Get payment status | payment_hash |
list_payments | Sender / payer whose payment sessions you want | List payments | status, limit, after |
Example RPC Call
curl -s -X POST -H "Content-Type: application/json" \
-d '{"id": 42, "jsonrpc": "2.0", "method": "node_info", "params": []}' \
http://127.0.0.1:8227Channel Lifecycle
NegotiatingFunding -> CollaboratingFundingTx -> SigningCommitment
SigningCommitment -> AwaitingTxSignatures -> AwaitingChannelReady
AwaitingChannelReady -> ChannelReady -> ShuttingDown -> Closed| State | Description |
|---|---|
| NegotiatingFunding | Peers are negotiating channel parameters; external funding may be waiting for user-signed tx submission |
| CollaboratingFundingTx | Peers are collaborating on the funding transaction |
| SigningCommitment | Funding collaboration is complete; peers are exchanging commitment signatures |
| AwaitingTxSignatures | Commitment signatures are exchanged; peers are finalizing funding transaction signatures |
| AwaitingChannelReady | Funding transaction is submitted/confirmed and peers are exchanging channel-ready messages |
| ChannelReady | Channel is open and operational; off-chain payments are possible |
| ShuttingDown | A cooperative shutdown has started |
| Closed | Channel is fully settled on-chain |
Use fnn-cli channel list_channels to check the state of your channels. JSON-RPC returns states as {"state_name":"ChannelReady"} and similar PascalCase names. Each side must reserve 99 CKB (98 for commitment lock + 1 for shutdown fee).
Payment Lifecycle
Created ──▶ Inflight ──┬──▶ Success
└──▶ Failed| State | Description |
|---|---|
| Created | Payment session initialized; no TLC has been dispatched yet |
| Inflight | At least one payment attempt is active or waiting for settlement/retry |
| Success | Payment settled; preimage revealed, funds transferred |
| Failed | Payment terminated after failures or exhausted retries |
Fiber uses a two-level state machine: a high-level PaymentSession represents the intent, and one or more PaymentAttempts handle actual routing. An attempt can move through Created, Inflight, Retrying, Success, and Failed.
Fee Calculation
The forwarding fee for a TLC (Timelock Contract) is calculated as:
fee = ⌈(amount × tlc_fee_proportional_millionths) / 1,000,000⌉Example: With tlc_fee_proportional_millionths = 1000 (0.1%), forwarding 1,000 CKB earns the relay node 1 CKB.
The fee is calculated using the outbound channel's configuration. For a path A → B → C, the fee B charges is based on the channel between B and C, not A and B.
Important Constants & Parameters
| Parameter | Purpose | Default / Typical Value |
|---|---|---|
| Reserved CKB | Channel reserve for lock and fees | 99 CKB (98 commitment + 1 shutdown fee) |
tlc_fee_proportional_millionths | Forwarding fee rate | 1000 (= 0.1%) |
tlc_min_value | Minimum TLC value to forward | 0 (any amount) |
tlc_expiry_delta | TLC expiry window (milliseconds) | 14400000 (4 hours) |
commitment_delay_epoch | Commitment delay / to-self delay | 1 epoch (~4 hours) |
max_tlc_value_in_flight | Max total TLC value in flight | u128::MAX by default; set at channel open, not updatable |
max_tlc_number_in_flight | Max number of TLCs in flight | 125 |
pending_channels_number_limit | Global max pending channel openings | 100 |
to_be_accepted_channels_number_limit | Max pending channel openings from one peer | 20 |
open_channel_auto_accept_min_ckb_funding_amount | Min CKB funding for auto-accept | Built-in default: 10000000000 (100 CKB); public nodes commonly require 499 CKB funding |
auto_accept_channel_ckb_funding_amount | Auto-accept contribution | Built-in default: 9900000000 (99 CKB); public nodes commonly contribute 25000000000 (250 CKB) |
Capacity Formula
For CKB channels, each side must reserve CKB for on-chain operations:
Available Balance = Funded Amount − 99 CKBExample: Fund 499 CKB → 499 − 99 = 400 CKB available for off-chain payments.
The 99 CKB reserve is per side. In a two-party CKB channel, both sides must reserve this amount. This reserve is not available for CKB payments — it covers the commitment transaction lock and the shutdown transaction fee. For UDT channels, the channel balance is in token base units, but the funding transaction still needs enough CKB capacity and fees.
Testnet Resources
| Resource | URL | Notes |
|---|---|---|
| CKB Testnet Faucet | faucet.nervos.org | Get testnet CKB |
| RUSD Stablecoin | testnet0815.stablepp.xyz | Mint testnet RUSD |
| CKB Explorer | explorer.nervos.org | Testnet block explorer |
| Fiber Dashboard | dashboard.fiber.channel | Network topology & stats |
| Fiber Releases | GitHub Releases | Download latest binary |
Public Testnet Nodes
| Name | Pubkey | Auto-accept CKB | Auto-accept UDT |
|---|---|---|---|
| fiber-testnet-public-bottle | 02b6d4e3ab86a2ca2fad6fae0ecb2e1e559e0b911939872a90abdda6d20302be71 | ≥ 499 CKB | RUSD ≥ 20 |
| fiber-testnet-public-bracer | 0291a6576bd5a94bd74b27080a48340875338fff9f6d6361fe6b8db8d0d1912fcc | ≥ 499 CKB | RUSD ≥ 20 |
Common Patterns
Multi-Hop Routing
You don't need a direct channel to every peer. Fiber automatically discovers paths through intermediate relay nodes:
┌───────┐ ┌───────┐ ┌───────┐ ┌───────┐
│ nodeA │ ─────▶ │ node1 │ ─────▶ │ node2 │ ─────▶ │ nodeB │
│:8227 │ │public │ │public │ │:8237 │
└───────┘ └───────┘ └───────┘ └───────┘
sender relay node 1 relay node 2 receiverLocal nodes do not need a public IP — they connect through public relay nodes. See Multi-Hop Routing for full details.
Channel Rebalancing
When one side of a channel is depleted, rebalance by sending a payment back to yourself:
Automatic — use send_payment with allow_self_payment: true:
{
"jsonrpc": "2.0",
"method": "send_payment",
"params": [{
"target_pubkey": "<your_own_pubkey>",
"amount": "0x5F5E100",
"keysend": true,
"allow_self_payment": true
}],
"id": 1
}Manual — use build_router + send_payment_with_router for control over the exact path. See Channel Rebalancing for details.
Keysend Payments
Send a payment without an invoice by specifying the recipient's pubkey directly:
fnn-cli payment send_payment --target-pubkey <recipient_pubkey> --amount 100000000 --keysend trueKeysend is useful for spontaneous payments, tipping, and machine-to-machine transactions where the recipient cannot pre-generate an invoice. For CKB payments, the CLI amount is in shannons (100000000 = 1 CKB).
Further reading:
- Channel Lifecycle — detailed channel state transitions
- Payment Lifecycle — payment session and attempt states
- HTTP RPC Reference — full RPC API reference
- Network Resources — public nodes, faucets, and explorers
- Channel Rebalancing — liquidity management