Fiber LogoFiber Docs

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,localhost

Caller 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

CategoryOperationRun onCommand
NodeList available commandsAny shellfnn-cli --help
NodeView node infoNode being inspectedfnn-cli info
PeerConnect to a peer (by pubkey)Node initiating the connectionfnn-cli peer connect_peer --pubkey <pubkey>
PeerConnect to a WSS peer (by pubkey)Browser/WASM-facing or WSS-capable nodefnn-cli peer connect_peer --pubkey <pubkey> --addr-type wss
PeerConnect to a peer (by address)Node initiating the connectionfnn-cli peer connect_peer --address "/ip4/<ip>/tcp/<port>"
PeerList connected peersNode being inspectedfnn-cli peer list_peers
PeerDisconnect a peerNode dropping the connectionfnn-cli peer disconnect_peer --pubkey <pubkey>

Channel

CategoryOperationRun onCommand
ChannelOpen a CKB channelChannel initiator / funderfnn-cli channel open_channel --pubkey <pubkey> --funding-amount <shannons>
ChannelOpen a UDT channelChannel initiator / funderfnn-cli channel open_channel --pubkey <pubkey> --funding-amount <base_units> --funding-udt-type-script '<json>'
ChannelList all channelsNode whose local channel state you wantfnn-cli channel list_channels
ChannelList pending opens onlyNode whose local pending channel state you wantfnn-cli channel list_channels --only-pending true
ChannelClose a channelEither channel participant; caller initiates closefnn-cli channel shutdown_channel --channel-id <id> --force true
ChannelUpdate channel configNode whose local forwarding config you want to changefnn-cli channel update_channel --channel-id <id> --tlc-minimum-value <base_units>

Invoice & Payment

CategoryOperationRun onCommand
InvoiceCreate a CKB invoiceReceiver / payeefnn-cli invoice new_invoice --amount 10000000000 --currency Fibt --description "Test"
InvoiceCreate a UDT invoiceReceiver / payeefnn-cli invoice new_invoice --amount <base_units> --currency Fibt --udt-type-script '<json>'
InvoiceParse an invoiceAny node or shell targeting a nodefnn-cli invoice parse_invoice --invoice "fibt1..."
PaymentSend paymentSender / payer; not the node that created the invoicefnn-cli payment send_payment --invoice "fibt1..."
PaymentSend keysend paymentSender / payerfnn-cli payment send_payment --target-pubkey <pubkey> --amount <shannons> --keysend true
PaymentCheck payment statusSender / payer that created the payment sessionfnn-cli payment get_payment --payment-hash 0x...
PaymentList all paymentsSender / payer whose payment sessions you wantfnn-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

MethodRun onDescriptionKey Params
node_infoNode being inspectedGet node identity & config
connect_peerNode initiating the connectionConnect to a remote peerpubkey, address, save, addr_type
disconnect_peerNode dropping the connectionDisconnect from a peerpubkey
list_peersNode being inspectedList connected peers

Channel

MethodRun onDescriptionKey Params
open_channelChannel initiator / funderOpen a new channelpubkey, funding_amount, public, one_way, funding_fee_rate, funding_udt_type_script
open_channel_with_external_fundingInitiator whose external wallet controls funding_lock_scriptNegotiate a channel funded by an external walletpubkey, funding_amount, shutdown_script, funding_lock_script, funding_lock_script_cell_deps
submit_signed_funding_txSame node that called open_channel_with_external_fundingSubmit the externally signed funding transactionchannel_id, signed_funding_tx
accept_channelAcceptor / node that received the pending open requestManually accept a pending channeltemporary_channel_id, funding_amount
list_channelsNode whose local channel state you wantList channels; balances are local perspectivepubkey, include_closed, only_pending
shutdown_channelEither channel participant; caller initiates closeClose a channelchannel_id, close_script, fee_rate, force
update_channelNode whose local forwarding config you want to changeUpdate channel parameterschannel_id, tlc_fee_proportional_millionths, tlc_minimum_value, tlc_expiry_delta

Invoice & Payment

MethodRun onDescriptionKey Params
new_invoiceReceiver / payeeCreate an invoice and store its preimage locallyamount, currency, description, expiry, udt_type_script
parse_invoiceAny nodeDecode an invoice stringinvoice
send_paymentSender / payer; not the node that created the invoiceSend a paymentinvoice or target_pubkey + amount + keysend
build_routerSender / payer route sourceBuild an explicit routehops_info, amount, udt_type_script
send_payment_with_routerSender / payer route sourceSend with a manually supplied routerouter, invoice or keysend
get_paymentSender / payer that created the payment sessionGet payment statuspayment_hash
list_paymentsSender / payer whose payment sessions you wantList paymentsstatus, 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:8227

Channel Lifecycle

NegotiatingFunding -> CollaboratingFundingTx -> SigningCommitment
SigningCommitment -> AwaitingTxSignatures -> AwaitingChannelReady
AwaitingChannelReady -> ChannelReady -> ShuttingDown -> Closed
StateDescription
NegotiatingFundingPeers are negotiating channel parameters; external funding may be waiting for user-signed tx submission
CollaboratingFundingTxPeers are collaborating on the funding transaction
SigningCommitmentFunding collaboration is complete; peers are exchanging commitment signatures
AwaitingTxSignaturesCommitment signatures are exchanged; peers are finalizing funding transaction signatures
AwaitingChannelReadyFunding transaction is submitted/confirmed and peers are exchanging channel-ready messages
ChannelReadyChannel is open and operational; off-chain payments are possible
ShuttingDownA cooperative shutdown has started
ClosedChannel 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
StateDescription
CreatedPayment session initialized; no TLC has been dispatched yet
InflightAt least one payment attempt is active or waiting for settlement/retry
SuccessPayment settled; preimage revealed, funds transferred
FailedPayment 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

ParameterPurposeDefault / Typical Value
Reserved CKBChannel reserve for lock and fees99 CKB (98 commitment + 1 shutdown fee)
tlc_fee_proportional_millionthsForwarding fee rate1000 (= 0.1%)
tlc_min_valueMinimum TLC value to forward0 (any amount)
tlc_expiry_deltaTLC expiry window (milliseconds)14400000 (4 hours)
commitment_delay_epochCommitment delay / to-self delay1 epoch (~4 hours)
max_tlc_value_in_flightMax total TLC value in flightu128::MAX by default; set at channel open, not updatable
max_tlc_number_in_flightMax number of TLCs in flight125
pending_channels_number_limitGlobal max pending channel openings100
to_be_accepted_channels_number_limitMax pending channel openings from one peer20
open_channel_auto_accept_min_ckb_funding_amountMin CKB funding for auto-acceptBuilt-in default: 10000000000 (100 CKB); public nodes commonly require 499 CKB funding
auto_accept_channel_ckb_funding_amountAuto-accept contributionBuilt-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 CKB

Example: 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

ResourceURLNotes
CKB Testnet Faucetfaucet.nervos.orgGet testnet CKB
RUSD Stablecointestnet0815.stablepp.xyzMint testnet RUSD
CKB Explorerexplorer.nervos.orgTestnet block explorer
Fiber Dashboarddashboard.fiber.channelNetwork topology & stats
Fiber ReleasesGitHub ReleasesDownload latest binary

Public Testnet Nodes

NamePubkeyAuto-accept CKBAuto-accept UDT
fiber-testnet-public-bottle02b6d4e3ab86a2ca2fad6fae0ecb2e1e559e0b911939872a90abdda6d20302be71≥ 499 CKBRUSD ≥ 20
fiber-testnet-public-bracer0291a6576bd5a94bd74b27080a48340875338fff9f6d6361fe6b8db8d0d1912fcc≥ 499 CKBRUSD ≥ 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      receiver

Local 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 true

Keysend 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: