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

# Download the latest binary
mkdir tmp && cd tmp
tar xzvf fnn-latest.tar.gz

# macOS: remove quarantine attribute
xattr -d com.apple.quarantine fnn fnn-cli fnn-migrate

# Set up keys
ckb-cli account new
ckb-cli account export --lock-arg <lock_arg> --extended-privkey-path ./ckb/exported-key
head -n 1 ./ckb/exported-key > ./ckb/key

# Start the node
FIBER_SECRET_KEY_PASSWORD='your_password' RUST_LOG=info ./fnn -c config.yml -d .

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

Common CLI Commands

Node & Peer

CategoryOperationCommand
NodeView node infofnn-cli info
NodeList available commandsfnn-cli --help
PeerConnect to a peer (by pubkey)fnn-cli peer connect_peer --pubkey <pubkey>
PeerConnect to a peer (by address)fnn-cli peer connect_peer --address "/ip4/<ip>/tcp/<port>"
PeerList connected peersfnn-cli peer list_peers
PeerDisconnect a peerfnn-cli peer disconnect_peer --pubkey <pubkey>

Channel

CategoryOperationCommand
ChannelOpen a CKB channelfnn-cli channel open_channel --pubkey <pubkey> --funding-amount <amount>
ChannelOpen a UDT channelfnn-cli channel open_channel --pubkey <pubkey> --funding-amount <amount> --udt-type-script '<json>'
ChannelList all channelsfnn-cli channel list_channels
ChannelClose a channelfnn-cli channel shutdown_channel --channel-id <id>
ChannelUpdate channel configfnn-cli channel update_channel --channel-id <id> [options]

Invoice & Payment

CategoryOperationCommand
InvoiceCreate a CKB invoicefnn-cli invoice new_invoice --amount 1000 --currency Fibt --description "Test"
InvoiceCreate a UDT invoicefnn-cli invoice new_invoice --amount 1000 --currency Fibt --udt-type-script '<json>'
InvoiceParse an invoicefnn-cli invoice parse_invoice --invoice "fibt1..."
PaymentSend paymentfnn-cli payment send_payment --invoice "fibt1..."
PaymentSend keysend paymentfnn-cli payment send_payment --pubkey <pubkey> --amount <amount> --keysend
PaymentCheck payment statusfnn-cli payment get_payment --payment-hash 0x...
PaymentList all paymentsfnn-cli payment list_payments

Amount units differ between CLI and RPC: CLI uses human-readable units (e.g. 1000 = 1000 CKB), while RPC uses hex shannons (e.g. "0x0DE0B6B3A7640000" = 1 CKB = 108 shannons). For UDT amounts, CLI uses base units directly.

RPC Quick Reference

The default RPC endpoint is http://127.0.0.1:8227. All calls use JSON-RPC 2.0.

Node & Peer

MethodDescriptionKey Params
node_infoGet node identity & config
connect_peerConnect to a remote peerpubkey, address
disconnect_peerDisconnect from a peerpubkey
list_peersList connected peers

Channel

MethodDescriptionKey Params
open_channelOpen a new channelpubkey, funding_amount, funding_fee_rate, udt_type_script
list_channelsList all channels
shutdown_channelClose a channelchannel_id
update_channelUpdate channel parameterschannel_id, tlc_fee_proportional_millionths, tlc_min_value, tlc_expiry_delta

Invoice & Payment

MethodDescriptionKey Params
new_invoiceCreate an invoiceamount, currency, description, expiry, udt_type_script
parse_invoiceDecode an invoice stringinvoice
send_paymentSend a paymentinvoice or target_pubkey + amount
get_paymentGet payment statuspayment_hash
list_paymentsList all payments

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

┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│  Awaiting    │────▶│  Channel     │────▶│   Closing    │
│   Lockin     │     │    Ready     │     │              │
└──────────────┘     └──────┬───────┘     └──────┬───────┘
                           │                     │
                           ▼                     ▼
                    ┌──────────────┐     ┌──────────────┐
                    │   Normal     │     │    Closed    │
                    │  Operation   │     │              │
                    └──────────────┘     └──────────────┘
StateDescription
AwaitingLockinFunding transaction submitted, waiting for on-chain confirmation
ChannelReadyChannel is open and operational; off-chain payments are possible
ClosingA shutdown request has been initiated
ClosedChannel is fully settled on-chain

Use fnn-cli channel list_channels to check the state of your channels. Each side must reserve 99 CKB (98 for commitment lock + 1 for shutdown fee).

Payment Lifecycle

Created ──▶ Inflight ──┬──▶ Success
                       └──▶ Failed
StateDescription
CreatedPayment session initialized, routing in progress
InflightPayment is being forwarded through the network
SuccessPayment settled; preimage revealed, funds transferred
FailedPayment permanently failed (expired invoice, no route, etc.)

Fiber uses a two-level state machine: a high-level PaymentSession represents the intent, and one or more PaymentAttempts handle actual routing. Failed attempts are automatically retried with different routes.

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)86400000 (1 day)
to_self_delayCommitment delay (epochs)1 epoch (~4 hours)
max_tlc_value_in_flightMax total TLC value in flightSet at channel open, not updatable
max_tlc_number_in_flightMax number of TLCs in flight125
open_channel_auto_accept_min_ckb_funding_amountMin funding for auto-accept49900000000 (≥ 499 CKB)
auto_accept_channel_ckb_funding_amountAuto-accept contribution25000000000 (250 CKB)

Capacity Formula

Each channel 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 channel, both sides must reserve this amount. This reserve is not available for payments — it covers the commitment transaction lock and the shutdown transaction fee.

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 --pubkey <recipient_pubkey> --amount 1000 --keysend

Keysend is useful for spontaneous payments, tipping, and machine-to-machine transactions where the recipient cannot pre-generate an invoice.


Further reading:

Fiber AI Assistant

Ask me anything

I can answer questions about Fiber Network using our documentation.

AI answers are based on Fiber documentation