@fiber-offers/protocol
v0.1.0
Published
Signed reusable payment offer protocol for Nervos Fiber Network.
Maintainers
Readme
@fiber-offers/protocol
Signed reusable payment offers for the Nervos Fiber Network.
The package implements the canonical Fiber Offer document, Ed25519 lifecycle
signatures, deterministic offer IDs, Bech32m fbroffer1... encoding, amount
and asset validation, recurrence policy, and signed revocations.
Install
npm install @fiber-offers/protocolNode.js 20 or newer is required.
Example
import {
createSignedOffer,
encodeOffer,
generateOfferKeyPair,
verifyOffer
} from "@fiber-offers/protocol";
const keys = generateOfferKeyPair();
const offer = createSignedOffer(
{
node_id: "03" + "00".repeat(32),
network: "testnet",
resolver_url: "https://fiber-offers.example.com",
description: "Coffee",
amount_min: "100000000",
amount_max: "100000000",
assets: [{ asset_type: "ckb", symbol: "CKB" }],
single_use: false,
public_key: keys.publicKeyPem
},
keys.privateKeyPem
);
console.log(verifyOffer(offer));
console.log(encodeOffer(offer));Amounts are integer base units. One CKB is 100000000 shannons.
See the Fiber Offers repository for the protocol specification and complete examples.
License
MIT
