diff --git a/website/docs/dapp/TutorialOverview.tsx b/website/docs/dapp/TutorialOverview.tsx index a3dbd14ff..d131352ae 100644 --- a/website/docs/dapp/TutorialOverview.tsx +++ b/website/docs/dapp/TutorialOverview.tsx @@ -1,97 +1,163 @@ import Link from "@docusaurus/Link"; import { TutorialHeaderProps } from "@site/src/components/TutorialHeader"; -const TRANSFEROVERVIEW: TutorialHeaderProps = -{ - time: "2 - 5 min", - topics: [ - { label: "Cell Model", link:"/docs/tech-explanation/cell-model" }, - { label: "Transaction", link:"/docs/tech-explanation/glossary#transaction" }, - { label: "Witness", link:"/docs/tech-explanation/glossary#witness" }, - { label: "Signature", link:"/docs/tech-explanation/glossary#cryptographic-signature" }, - ], - tools: [ -
An IDE/Editor that supports TypeScript
, -
- - Node.js - {' and '} - - Yarn - -
, -
CKB dev environment: OffCKB
- ], -} -const WRITEOVERVIEW: TutorialHeaderProps = -{ - time: "2 - 5 min", - topics: [ - { label: "Cell Model", link:"/docs/tech-explanation/cell-model" }, - { label: "Data", link:"/docs/tech-explanation/glossary#data" }, - { label: "Transaction Hash", link:"/docs/tech-explanation/glossary#transaction-hash" }, - ], - tools: [ -
An IDE/Editor that supports TypeScript
, -
- - Node.js - {' and '} - - Yarn - -
, -
CKB dev environment: OffCKB
- ], -} -const TOKENOVERVIEW: TutorialHeaderProps = -{ - time: "5 - 10 min", - topics: [ - { label: "UDT", link:"/docs/tech-explanation/glossary#udt" }, - { label: "Fungible Token", link:"/docs/tech-explanation/glossary#fungible-token" }, - { label: "xUDT", link:"https://github.com/XuJiandong/rfcs/blob/xudt/rfcs/0052-extensible-udt/0052-extensible-udt.md" }, - ], - tools: [ -
An IDE/Editor that supports TypeScript
, -
- - Node.js - {' and '} - - Yarn - -
, -
CKB dev environment: OffCKB
- ], -} -const DOBOVERVIEW: TutorialHeaderProps = -{ - time: "5 - 10 min", - topics: [ - { label: "DOB", link:'/docs/tech-explanation/glossary#digital-object-dob' }, - { label: "NFT", link: '/docs/tech-explanation/glossary#non-fungible-token' }, - { label: "Spore Protocol", link: 'https://spore.pro' }, - ], - tools: [ -
An IDE/Editor that supports TypeScript
, -
- - Node.js - {' and '} - - Yarn - -
, -
CKB dev environment: OffCKB
- ], -} - - -export { - TRANSFEROVERVIEW, - WRITEOVERVIEW, - TOKENOVERVIEW, - DOBOVERVIEW +const TRANSFEROVERVIEW: TutorialHeaderProps = { + time: "2 - 5 min", + topics: [ + { label: "Cell Model", link: "/docs/tech-explanation/cell-model" }, + { + label: "Transaction", + link: "/docs/tech-explanation/glossary#transaction", + }, + { label: "Witness", link: "/docs/tech-explanation/glossary#witness" }, + { + label: "Signature", + link: "/docs/tech-explanation/glossary#cryptographic-signature", + }, + ], + tools: [ +
An IDE/Editor that supports TypeScript
, +
+ + Node.js + + {" and "} + + Yarn + +
, +
+ CKB dev environment:{" "} + + OffCKB + +
, + ], }; - \ No newline at end of file +const WRITEOVERVIEW: TutorialHeaderProps = { + time: "2 - 5 min", + topics: [ + { label: "Cell Model", link: "/docs/tech-explanation/cell-model" }, + { label: "Data", link: "/docs/tech-explanation/glossary#data" }, + { + label: "Transaction Hash", + link: "/docs/tech-explanation/glossary#transaction-hash", + }, + ], + tools: [ +
An IDE/Editor that supports TypeScript
, +
+ + Node.js + + {" and "} + + Yarn + +
, +
+ CKB dev environment:{" "} + + OffCKB + +
, + ], +}; +const TOKENOVERVIEW: TutorialHeaderProps = { + time: "5 - 10 min", + topics: [ + { label: "UDT", link: "/docs/tech-explanation/glossary#udt" }, + { + label: "Fungible Token", + link: "/docs/tech-explanation/glossary#fungible-token", + }, + { + label: "xUDT", + link: "https://github.com/XuJiandong/rfcs/blob/xudt/rfcs/0052-extensible-udt/0052-extensible-udt.md", + }, + ], + tools: [ +
An IDE/Editor that supports TypeScript
, +
+ + Node.js + + {" and "} + + Yarn + +
, +
+ CKB dev environment:{" "} + + OffCKB + +
, + ], +}; +const DOBOVERVIEW: TutorialHeaderProps = { + time: "5 - 10 min", + topics: [ + { + label: "DOB", + link: "/docs/tech-explanation/glossary#digital-object-dob", + }, + { + label: "NFT", + link: "/docs/tech-explanation/glossary#non-fungible-token", + }, + { label: "Spore Protocol", link: "https://spore.pro" }, + ], + tools: [ +
An IDE/Editor that supports TypeScript
, +
+ + Node.js + + {" and "} + + Yarn + +
, +
+ CKB dev environment:{" "} + + OffCKB + +
, + ], +}; + +export { TRANSFEROVERVIEW, WRITEOVERVIEW, TOKENOVERVIEW, DOBOVERVIEW }; diff --git a/website/docs/dapp/_SetupProjectContent.mdx b/website/docs/dapp/_SetupProjectContent.mdx index 46cbfe7ac..3b643998c 100644 --- a/website/docs/dapp/_SetupProjectContent.mdx +++ b/website/docs/dapp/_SetupProjectContent.mdx @@ -1,6 +1,6 @@ -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; -import ImgContainer from '@components/ImgContainer'; +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import ImgContainer from "@components/ImgContainer"; import useBaseUrl from "@docusaurus/useBaseUrl"; To interact with the dApp, ensure that your Devnet is up and running. After installing [@offckb/cli](https://www.npmjs.com/package/@offckb/cli), open a terminal and start the Devnet with the following command: @@ -9,13 +9,16 @@ To interact with the dApp, ensure that your Devnet is up and running. After inst ``` + ```bash offckb node ``` + ```mdx-code-block ``` + ```bash /bin/sh: /Users/nervosDocs/.nvm/versions/node/v18.12.1/lib/node_modules/@offckb/cli/target/ckb/ckb: No such file or directory /Users/nervosDocs/.nvm/versions/node/v18.12.1/lib/node_modules/@offckb/cli/target/ckb/ckb not found, download and install the new version 0.113.1.. @@ -32,6 +35,7 @@ CKB output: 2024-03-20 07:56:45.320 +00:00 main INFO ckb_db_migration Init data CKB output: 2024-03-20 07:56:45.329 +00:00 main INFO ckb_launcher Touch chain spec hash: Byte32(0x3036c73473a371f3aa61c588c38924a93fb8513e481fa7c8d884fc4cf5fd368a) ``` + ```mdx-code-block @@ -43,13 +47,16 @@ You might want to check pre-funded accounts and copy private keys for later use. ``` + ```bash offckb accounts ``` + ```mdx-code-block ``` + ```bash Print account list, each account is funded with 42_000_000_00000000 capacity in the genesis block. [ @@ -75,9 +82,10 @@ Print account list, each account is funded with 42_000_000_00000000 capacity in address: 'ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqt435c3epyrupszm7khk6weq5lrlyt52lg48ucew', args: '0x758d311c8483e0602dfad7b69d9053e3f917457d' }, - #... + #... ] ``` + ```mdx-code-block @@ -91,18 +99,22 @@ Navigate to your project, install the node dependencies, and start running the e ``` + ```bash yarn && NETWORK=devnet yarn start ``` + ```mdx-code-block ``` + ```bash $ parcel index.html Server running at http://localhost:1234 ✨ Built in 66ms ``` + ```mdx-code-block diff --git a/website/docs/dapp/_SwitchToTestnet.mdx b/website/docs/dapp/_SwitchToTestnet.mdx index 116fdab92..2b96a7543 100644 --- a/website/docs/dapp/_SwitchToTestnet.mdx +++ b/website/docs/dapp/_SwitchToTestnet.mdx @@ -1,6 +1,6 @@ So now your app works great on the local blockchain, you might want to switch it to different environments like Testnet and Mainnet. -To do this, you need to update the chain config and related code. +To do this, you need to update the chain config and related code. Open the `ckb.ts` in your project root dir, change the `lumosConfig` and `CKB_RPC_URL`: diff --git a/website/docs/dapp/create-dob.mdx b/website/docs/dapp/create-dob.mdx index ea289465d..8dce1e909 100644 --- a/website/docs/dapp/create-dob.mdx +++ b/website/docs/dapp/create-dob.mdx @@ -2,8 +2,9 @@ id: create-dob title: Create a DOB --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; import TutorialHeader from "@components/TutorialHeader"; import { DOBOVERVIEW } from "./TutorialOverview.tsx"; import SetupProject from "./SetupProject.tsx"; diff --git a/website/docs/dapp/create-token.mdx b/website/docs/dapp/create-token.mdx index 61aaf3a8b..b154a9a17 100644 --- a/website/docs/dapp/create-token.mdx +++ b/website/docs/dapp/create-token.mdx @@ -2,8 +2,9 @@ id: create-token title: Create a Fungible Token --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; import TutorialHeader from "@components/TutorialHeader"; import { TOKENOVERVIEW } from "./TutorialOverview.tsx"; import SetupProject from "./SetupProject.tsx"; @@ -46,7 +47,7 @@ cd docs.nervos.org/examples/xudt ### Step 2: Start the Devnet - + ## Behind the Scene @@ -71,7 +72,8 @@ export async function issueToken(privKey: string, amount: string) { ``` This function accepts two parameters: -- `privKey`: The private key of the issuer + +- `privKey`: The private key of the issuer - `amount`: The amount of token Note that we aim to create an output Cell whose [type script](/docs/tech-explanation/glossary#type-script) is an xUDT script. The args of this xUDT script are the issuer's lock script hash, which is why we include the following lines of code: diff --git a/website/docs/dapp/transfer-ckb.mdx b/website/docs/dapp/transfer-ckb.mdx index 90c87799b..3d415ed2f 100644 --- a/website/docs/dapp/transfer-ckb.mdx +++ b/website/docs/dapp/transfer-ckb.mdx @@ -2,8 +2,9 @@ id: transfer-ckb title: Transfer CKB --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; import TutorialHeader from "@components/TutorialHeader"; import { TRANSFEROVERVIEW } from "./TutorialOverview.tsx"; import SetupProject from "./SetupProject.tsx"; @@ -36,7 +37,7 @@ cd docs.nervos.org/examples/simple-transfer ### Step 2: Start the Devnet - + ## Behind the Scene @@ -136,6 +137,7 @@ if (collectedSum.lt(neededCapacity)) { ``` Now, let's create the transaction's output Cells: + - `transferOutput`: Generated based on the desired transfer amount by the user. - `changeOutput`: Represents the remaining balance after completing the transaction. @@ -158,6 +160,7 @@ const changeOutput: Cell = { data: "0x", }; ``` + Then, we need to add Inputs and Outputs to the created `txSkeleton`. Additionally, we add `Cell Deps`, which contain an `OutPoint` pointing to some specific Live Cells. These Cells are related to the transaction and can be used as dependencies to place code that will be loaded and executed by the `ckb-vm` or to place data that can be used for on-chain script execution. ```ts @@ -180,7 +183,6 @@ Next, update specific [witness](/docs/tech-explanation/glossary#witness) data in The `witnessArgs` consists of 3 distinct parts, each corresponding to the different data required for the execution of specific scripts: - ```ts export interface WitnessArgs { lock?: HexString; // lock scripts of the input Cells diff --git a/website/docs/dapp/write-message.mdx b/website/docs/dapp/write-message.mdx index 62a79d662..21a48d11f 100644 --- a/website/docs/dapp/write-message.mdx +++ b/website/docs/dapp/write-message.mdx @@ -2,10 +2,11 @@ id: write-message title: Write an On-Chain Message --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; import TutorialHeader from "@components/TutorialHeader"; -import { WRITEOVERVIEW } from "./TutorialOverview.tsx"; +import { WRITEOVERVIEW } from "./TutorialOverview.tsx"; import SetupProject from "./SetupProject.tsx"; import SwitchToTestnet from "./_SwitchToTestnet.mdx"; @@ -36,7 +37,7 @@ cd docs.nervos.org/examples/write-message ### Step 2: Start the Devnet - + ## Behind the Scene diff --git a/website/docs/ecosystem/EcoCardContents.tsx b/website/docs/ecosystem/EcoCardContents.tsx index eff949f58..de0c9f507 100644 --- a/website/docs/ecosystem/EcoCardContents.tsx +++ b/website/docs/ecosystem/EcoCardContents.tsx @@ -1,416 +1,489 @@ import { EcoCardProps } from "@site/src/components/EcoCard"; const ecoCardContents: EcoCardProps[] = [ - { - title: 'RGB++', - description: 'An extended RGB protocol to manage state changes and transaction verification', - href: 'https://github.com/ckb-cell/RGBPlusPlus-design', - bannerSrc: 'rgb++', - tags: ['Protocol'], - links: [ - { label: 'github', link: 'https://github.com/ckb-cell/RGBPlusPlus-design' }, - { label: 'doc', link: 'https://github.com/ckb-cell/RGBPlusPlus-design/blob/main/docs/light-paper-en.md' }, - ], - }, - { - title: 'Spore', - description: 'Craft, Secure, Distribute, and Monetize DOBs', - href: 'https://spore.pro/', - bannerSrc: 'spore', - tags: ['Protocol', 'DOB'], - links: [ - { label: 'website', link: 'https://spore.pro/' }, - { label: 'doc', link: 'https://docs.spore.pro/' }, - ], - }, - { - title: 'JoyID', - description: 'A web-based passwordless and mnemonic-free wallet solution', - href: 'https://joy.id/', - bannerSrc: 'joyid', - tags: ['Wallet'], - links: [ - { label: 'website', link: 'https://joy.id/' }, - { label: 'github', link: 'https://github.com/nervina-labs?q=joyid' }, - ], - }, - { - title: '.bit', - description: 'Cross-chain Web3 identities for you and your community', - href: 'https://did.id/', - bannerSrc: '.bit', - tags: ['DID'], - links: [ - { label: 'website', link: 'https://did.id/' }, - { label: 'github', link: 'https://github.com/dotbitHQ' }, - { label: 'doc', link: 'https://www.notion.so/bit-Previously-DAS-5cea5b425b204679b8ef2855ed94b04d'}, - ], - }, - { - title: 'Omiga', - description: 'The 1st inscription protocol established on Nervos $CKB blockchain', - href: 'https://omiga.io/', - bannerSrc: 'omiga', - tags: ['Protocol', 'DApp'], - links: [ - { label: 'website', link: 'https://omiga.io/' }, - { label: 'doc', link: 'https://docs.omiga.io/' }, - ], - }, - { - title: 'CoTA', - description: 'A layer-1.5 account based token protocol on Nervos CKB', - href: 'https://www.cotadev.io/', - bannerSrc: 'cota', - tags: ['Protocol', 'NFT'], - links: [ - { label: 'website', link: 'https://www.cotadev.io/' }, - { label: 'doc', link: 'https://www.cotadev.io/docs/getting-started/overview' }, - ], - }, + { + title: "RGB++", + description: + "An extended RGB protocol to manage state changes and transaction verification", + href: "https://github.com/ckb-cell/RGBPlusPlus-design", + bannerSrc: "rgb++", + tags: ["Protocol"], + links: [ + { + label: "github", + link: "https://github.com/ckb-cell/RGBPlusPlus-design", + }, + { + label: "doc", + link: "https://github.com/ckb-cell/RGBPlusPlus-design/blob/main/docs/light-paper-en.md", + }, + ], + }, + { + title: "Spore", + description: "Craft, Secure, Distribute, and Monetize DOBs", + href: "https://spore.pro/", + bannerSrc: "spore", + tags: ["Protocol", "DOB"], + links: [ + { label: "website", link: "https://spore.pro/" }, + { label: "doc", link: "https://docs.spore.pro/" }, + ], + }, + { + title: "JoyID", + description: "A web-based passwordless and mnemonic-free wallet solution", + href: "https://joy.id/", + bannerSrc: "joyid", + tags: ["Wallet"], + links: [ + { label: "website", link: "https://joy.id/" }, + { label: "github", link: "https://github.com/nervina-labs?q=joyid" }, + ], + }, + { + title: ".bit", + description: "Cross-chain Web3 identities for you and your community", + href: "https://did.id/", + bannerSrc: ".bit", + tags: ["DID"], + links: [ + { label: "website", link: "https://did.id/" }, + { label: "github", link: "https://github.com/dotbitHQ" }, + { + label: "doc", + link: "https://www.notion.so/bit-Previously-DAS-5cea5b425b204679b8ef2855ed94b04d", + }, + ], + }, + { + title: "Omiga", + description: + "The 1st inscription protocol established on Nervos $CKB blockchain", + href: "https://omiga.io/", + bannerSrc: "omiga", + tags: ["Protocol", "DApp"], + links: [ + { label: "website", link: "https://omiga.io/" }, + { label: "doc", link: "https://docs.omiga.io/" }, + ], + }, + { + title: "CoTA", + description: "A layer-1.5 account based token protocol on Nervos CKB", + href: "https://www.cotadev.io/", + bannerSrc: "cota", + tags: ["Protocol", "NFT"], + links: [ + { label: "website", link: "https://www.cotadev.io/" }, + { + label: "doc", + link: "https://www.cotadev.io/docs/getting-started/overview", + }, + ], + }, - { - title: 'Nervape', - description: 'A Metaverse with an ongoing Story and NFTs Shaped by the Community', - href: 'https://nervape.com/', - bannerSrc: 'nervape', - tags: ['NFT'], - links: [ - { label: 'website', link: 'https://nervape.com/' }, - { label: 'github', link: 'https://github.com/nervape' }, - { label: 'doc', link: 'https://tourmaline-elderberry-f93.notion.site/Nervape-Community-Wiki-e46261f411ed42e19b859f48da06fe63' }, - ], - }, - { - title: 'JoyGift', - description: 'Sending crypto assets as gifts to your friends, communities, or users', - href: 'https://joygift.cc/', - bannerSrc: 'joygift', - tags: ['DApp'], - links: [ - { label: 'website', link: 'https://joygift.cc/' }, - ], - }, - { - title: 'Philosopher\'s Stone', - description: 'On-Chain Gifting Platform powered by the Spore Protocol', - href: 'https://philosopherstone.xyz/', - bannerSrc: 'philosopherstone', - tags: ['DApp', 'DOB'], - links: [ - { label: 'website', link: 'https://philosopherstone.xyz/' }, - { label: 'github', link: 'https://github.com/SpectreMercury/PhilosopherStone' }, - ], - }, - { - title: 'NFTnation', - description: 'Explore, buy and sell NFTs. By the community, for the community', - href: 'https://nft-nation.live/', - bannerSrc: 'nftnation', - tags: ['NFT'], - links: [ - { label: 'website', link: 'https://nft-nation.live/' }, - { label: 'doc', link: 'https://nftnation.gitbook.io/nftnation-explained' }, - ], - }, - { - title: 'CKB Explorer', - description: 'A CKB Explorer built with React and Ruby on Rails', - href: 'https://explorer.nervos.org/', - bannerSrc: 'explorer', - tags: ['Explorer'], - links: [ - { label: 'website', link: 'https://explorer.nervos.org/' }, - { label: 'github', link: 'https://github.com/nervosnetwork/ckb-explorer' }, - ], - }, - { - title: 'Nervos Scan', - description: 'A CKB Explorer produced with love by 7774.bit', - href: 'https://nervosscan.com/', - bannerSrc: 'nervosscan', - tags: ['Explorer'], - links: [ - { label: 'website', link: 'https://nervosscan.com/' }, - ], - }, - { - title: 'Neuron', - description: 'A versatile desktop wallet designed for securely managing CKB assets', - href: 'https://github.com/nervosnetwork/neuron/releases/tag/v0.114.2', - bannerSrc: 'neuron', - tags: ['Wallet'], - links: [ - { label: 'website', link: 'https://github.com/nervosnetwork/neuron/releases/tag/v0.114.2' }, - ], - }, - - { - title: 'CKBull', - description: 'A mobile wallet that allows you to access and manage your CKB', - href: 'https://ckbull.app/', - bannerSrc: 'ckbull', - tags: ['Wallet'], - links: [ - { label: 'website', link: 'https://ckbull.app/' }, - { label: 'doc', link: 'https://www.notion.so/How-to-use-CKBull-wallet-89153cac673447b0bf827d1f6f7d151c?pvs=4'}, - ], - }, - { - title: 'imToken', - description: 'A built-in CKB wallet on mobile that enables users to safely send, receive and store CKB', - href: 'https://token.im/', - bannerSrc: 'imtoken', - tags: ['Wallet'], - links: [ - { label: 'website', link: 'https://token.im/' }, - { label: 'github', link: 'https://github.com/consenlabs' }, - { label: 'doc', link: 'https://medium.com/imtoken/imtoken-2-5-0-now-with-nervos-tron-bch-ltc-support-14d7171ccf4' }, - ], - }, - { - title: 'SafePal', - description: 'A hardware wallet that supports both Nervos L1 CKB and L2 Godwoken', - href: 'https://www.safepal.com/', - bannerSrc: 'safepal', - tags: ['Wallet'], - links: [ - { label: 'website', link: 'https://www.safepal.com/' }, - { label: 'doc', link: 'https://www.notion.so/How-to-add-send-Nervos-Chain-CKB-coin-with-SafePal-Hardware-Wallet-40da32d8f7074563859e9d08b585768e'}, - ], - }, - { - title: 'Ledger', - description: 'Provide secure hardware wallets for cryptocurrency storage and management', - href: 'https://www.ledger.com/', - bannerSrc: 'ledger', - tags: ['Wallet'], - links: [ - { label: 'website', link: 'https://www.ledger.com/' }, - { label: 'doc', link: 'https://developers.ledger.com/docs/sections'}, - ], - }, - { - title: 'imKey', - description: 'Offer secure, user-friendly hardware wallets for digital asset protection', - href: 'https://imkey.im/', - bannerSrc: 'imkey', - tags: ['Wallet'], - links: [ - { label: 'website', link: 'https://imkey.im/' }, - ], - }, - { - title: 'oneKey', - description: 'Offer secure hardware wallets with cross-platform apps for digital asset management', - href: 'https://onekey.so/', - bannerSrc: 'onekey', - tags: ['Wallet'], - links: [ - { label: 'website', link: 'https://onekey.so/' }, - { label: 'github', link: 'https://github.com/OneKeyHQ/'}, - { label: 'doc', link: 'https://developer.onekey.so/'}, - ], - }, - { - title: 'ForceBridge', - description: 'A cross-chain interoperability bridge b/w Nervos and other blockchains', - href: 'https://forcebridge.com/', - bannerSrc: 'forcebridge', - tags: ['Bridge'], - links: [ - { label: 'website', link: 'https://forcebridge.com/' }, - { label: 'github', link: 'https://github.com/nervosnetwork/force-bridge'}, - { label: 'doc', link: 'https://github.com/nervosnetwork/force-bridge/blob/main/docs/dapp-user-guide.md'}, - ], - }, - { - title: 'Godwoken Bridge', - description: 'A token bridge between CKB and Godwoken', - href: 'https://bridge.godwoken.io/', - bannerSrc: 'godwokenbridge', - tags: ['Bridge'], - links: [ - { label: 'website', link: 'https://bridge.godwoken.io/' }, - { label: 'github', link: 'https://github.com/godwokenrises/light-godwoken/tree/develop/apps/godwoken-bridge'}, - { label: 'doc', link: 'https://docs.godwoken.io/'}, - ], - }, - { - title: 'Yokaiswap Bridge', - description: 'A cross-chain interoperability bridge b/w Nervos and other blockchains', - href: 'https://www.yokaiswap.com/bridge/', - bannerSrc: 'yokaiswap', - tags: ['Bridge'], - links: [ - { label: 'website', link: 'https://www.yokaiswap.com/bridge/' }, - { label: 'github', link: 'https://github.com/yokaiswap'}, - ], - }, - { - title: 'Ankr', - description: 'The fastest, most reliable Web3 infrastructure', - href: 'https://www.ankr.com/', - bannerSrc: 'ankr', - tags: ['Tools & Infra'], - links: [ - { label: 'website', link: 'https://www.ankr.com/' }, - { label: 'doc', link: 'https://archive.nervos.org/blog/ankr-integrates-support-for-nervos-nodes' }, - ], - }, - { - title: 'Axon', - description: 'A L2 framework that unleashes the power of appchain future', - href: 'https://axonweb3.io/', - bannerSrc: 'axon', - tags: ['Tools & Infra'], - links: [ - { label: 'website', link: 'https://axonweb3.io/' }, - { label: 'github', link: 'https://github.com/axonweb3/axon' }, - { label: 'doc', link: 'https://docs.axonweb3.io/' }, - ], - }, - { - title: 'BandProtocol', - description: 'A L2 framework that unleashes the power of appchain future', - href: 'https://www.bandprotocol.com/', - bannerSrc: 'bandprotocol', - tags: ['Tools & Infra'], - links: [ - { label: 'website', link: 'https://www.bandprotocol.com/' }, - { label: 'github', link: 'https://github.com/bandprotocol' }, - { label: 'doc', link: 'https://medium.com/bandprotocol/band-protocol-integrates-with-nervos-godwoken-361546e1091d' }, - ], - }, - { - title: 'DIA', - description: 'Provides fully customizable and transparent data feeds for smart contracts', - href: 'https://www.diadata.org/', - bannerSrc: 'dia', - tags: ['Tools & Infra'], - links: [ - { label: 'website', link: 'https://www.diadata.org/' }, - { label: 'doc', link: 'https://archive.nervos.org/blog/dia-deploys-oracles-onto-layer-2-bolstering-dev-resources' }, - ], - }, - { - title: 'Godwoken', - description: 'An EVM-compatible, L2 optimistic rollup solution built on Nervos L1', - href: 'https://www.godwoken.com/', - bannerSrc: 'godwoken', - tags: ['Tools & Infra'], - links: [ - { label: 'website', link: 'https://www.godwoken.com/' }, - { label: 'github', link: 'https://github.com/godwokenrises' }, - { label: 'doc', link: 'https://docs.godwoken.io/' }, - ], - }, - { - title: 'Khalani', - description: 'A decentralized infrastructure for collaborative solving in intent-driven applications', - href: 'https://khalani.network/', - bannerSrc: 'khalani', - tags: ['Tools & Infra'], - links: [ - { label: 'website', link: 'https://khalani.network/' }, - { label: 'doc', link: 'https://blog.khalani.network/' }, - ], - }, - { - title: 'Perun', - description: 'A L2 solution enhancing efficiency with off-chain transaction capabilities', - href: 'https://perun.network/', - bannerSrc: 'perun', - tags: ['Tools & Infra'], - links: [ - { label: 'website', link: 'https://perun.network/' }, - { label: 'github', link: 'https://github.com/perun-network/go-perun' }, - ], - }, - { - title: 'Unifra', - description: 'A leading L2 platform that provides open, reliable infrastructure services', - href: 'https://unifra.io/', - bannerSrc: 'unifra', - tags: ['Tools & Infra'], - links: [ - { label: 'website', link: 'https://unifra.io/' }, - ], - }, - { - title: 'F2Pool', - description: 'Leading mining pool for PoW network', - href: 'https://www.f2pool.com/', - bannerSrc: 'f2pool', - tags: ['Mining pool'], - links: [ - { label: 'website', link: 'https://www.f2pool.com/' }, - { label: 'doc', link: 'https://f2pool.zendesk.com/hc/en-us/articles/22893426126489-How-to-mine-Nervos'}, - ], - }, - { - title: 'Antpool', - description: 'World leading BTC mining pool', - href: 'https://www.antpool.com/home?lang=en', - bannerSrc: 'antpool', - tags: ['Mining pool'], - links: [ - { label: 'website', link: 'https://www.antpool.com/home?lang=en'}, - { label: 'doc', link: 'https://antpoolsupport-hc.zendesk.com/hc/en-us/articles/5985104597913-CKB-Mining'}, - ], - }, - { - title: 'Binance Pool', - description: 'Enjoy zero pool fees with CKB mining', - href: 'https://pool.binance.com/en', - bannerSrc: 'binancepool', - tags: ['Mining pool'], - links: [ - { label: 'website', link: 'https://pool.binance.com/en'}, - { label: 'doc', link: 'https://www.binance.com/en/support/faq/how-to-mine-nervos-ckb-on-binance-pool-6967ad3306b84ec49dcbb5ed8ac30a9b'}, - ], - }, - { - title: '2miners', - description: 'The most profitable Nervos mining pool for GPU and ASIC', - href: 'https://ckb.2miners.com/', - bannerSrc: '2miners', - tags: ['Mining pool'], - links: [ - { label: 'website', link: 'https://ckb.2miners.com/'}, - ], - }, - { - title: 'ViaBTC', - description: 'Pool the world together by providing the best mining services', - href: 'https://www.viabtc.com/', - bannerSrc: 'viabtc', - tags: ['Mining pool'], - links: [ - { label: 'website', link: 'https://www.viabtc.com/'}, - ], - }, - { - title: 'DxPool', - description: 'Technology leading blockchain infrastructure service provider', - href: 'https://www.dxpool.com/', - bannerSrc: 'dxpool', - tags: ['Mining pool'], - links: [ - { label: 'website', link: 'https://www.dxpool.com/'}, - ], - }, - { - title: 'Poolin', - description: 'A great bitocin and multi-cryptocurrency mining pool', - href: 'https://www.poolin.com/', - bannerSrc: 'poolin', - tags: ['Mining pool'], - links: [ - { label: 'website', link: 'https://www.poolin.com/'}, - { label: 'doc', link: 'https://help.poolin.me/hc/en-us/articles/360040689912-CKB-Mining-Settings'}, - ], - }, + { + title: "Nervape", + description: + "A Metaverse with an ongoing Story and NFTs Shaped by the Community", + href: "https://nervape.com/", + bannerSrc: "nervape", + tags: ["NFT"], + links: [ + { label: "website", link: "https://nervape.com/" }, + { label: "github", link: "https://github.com/nervape" }, + { + label: "doc", + link: "https://tourmaline-elderberry-f93.notion.site/Nervape-Community-Wiki-e46261f411ed42e19b859f48da06fe63", + }, + ], + }, + { + title: "JoyGift", + description: + "Sending crypto assets as gifts to your friends, communities, or users", + href: "https://joygift.cc/", + bannerSrc: "joygift", + tags: ["DApp"], + links: [{ label: "website", link: "https://joygift.cc/" }], + }, + { + title: "Philosopher's Stone", + description: "On-Chain Gifting Platform powered by the Spore Protocol", + href: "https://philosopherstone.xyz/", + bannerSrc: "philosopherstone", + tags: ["DApp", "DOB"], + links: [ + { label: "website", link: "https://philosopherstone.xyz/" }, + { + label: "github", + link: "https://github.com/SpectreMercury/PhilosopherStone", + }, + ], + }, + { + title: "NFTnation", + description: + "Explore, buy and sell NFTs. By the community, for the community", + href: "https://nft-nation.live/", + bannerSrc: "nftnation", + tags: ["NFT"], + links: [ + { label: "website", link: "https://nft-nation.live/" }, + { + label: "doc", + link: "https://nftnation.gitbook.io/nftnation-explained", + }, + ], + }, + { + title: "CKB Explorer", + description: "A CKB Explorer built with React and Ruby on Rails", + href: "https://explorer.nervos.org/", + bannerSrc: "explorer", + tags: ["Explorer"], + links: [ + { label: "website", link: "https://explorer.nervos.org/" }, + { + label: "github", + link: "https://github.com/nervosnetwork/ckb-explorer", + }, + ], + }, + { + title: "Nervos Scan", + description: "A CKB Explorer produced with love by 7774.bit", + href: "https://nervosscan.com/", + bannerSrc: "nervosscan", + tags: ["Explorer"], + links: [{ label: "website", link: "https://nervosscan.com/" }], + }, + { + title: "Neuron", + description: + "A versatile desktop wallet designed for securely managing CKB assets", + href: "https://github.com/nervosnetwork/neuron/releases/tag/v0.114.2", + bannerSrc: "neuron", + tags: ["Wallet"], + links: [ + { + label: "website", + link: "https://github.com/nervosnetwork/neuron/releases/tag/v0.114.2", + }, + ], + }, + + { + title: "CKBull", + description: + "A mobile wallet that allows you to access and manage your CKB", + href: "https://ckbull.app/", + bannerSrc: "ckbull", + tags: ["Wallet"], + links: [ + { label: "website", link: "https://ckbull.app/" }, + { + label: "doc", + link: "https://www.notion.so/How-to-use-CKBull-wallet-89153cac673447b0bf827d1f6f7d151c?pvs=4", + }, + ], + }, + { + title: "imToken", + description: + "A built-in CKB wallet on mobile that enables users to safely send, receive and store CKB", + href: "https://token.im/", + bannerSrc: "imtoken", + tags: ["Wallet"], + links: [ + { label: "website", link: "https://token.im/" }, + { label: "github", link: "https://github.com/consenlabs" }, + { + label: "doc", + link: "https://medium.com/imtoken/imtoken-2-5-0-now-with-nervos-tron-bch-ltc-support-14d7171ccf4", + }, + ], + }, + { + title: "SafePal", + description: + "A hardware wallet that supports both Nervos L1 CKB and L2 Godwoken", + href: "https://www.safepal.com/", + bannerSrc: "safepal", + tags: ["Wallet"], + links: [ + { label: "website", link: "https://www.safepal.com/" }, + { + label: "doc", + link: "https://www.notion.so/How-to-add-send-Nervos-Chain-CKB-coin-with-SafePal-Hardware-Wallet-40da32d8f7074563859e9d08b585768e", + }, + ], + }, + { + title: "Ledger", + description: + "Provide secure hardware wallets for cryptocurrency storage and management", + href: "https://www.ledger.com/", + bannerSrc: "ledger", + tags: ["Wallet"], + links: [ + { label: "website", link: "https://www.ledger.com/" }, + { label: "doc", link: "https://developers.ledger.com/docs/sections" }, + ], + }, + { + title: "imKey", + description: + "Offer secure, user-friendly hardware wallets for digital asset protection", + href: "https://imkey.im/", + bannerSrc: "imkey", + tags: ["Wallet"], + links: [{ label: "website", link: "https://imkey.im/" }], + }, + { + title: "oneKey", + description: + "Offer secure hardware wallets with cross-platform apps for digital asset management", + href: "https://onekey.so/", + bannerSrc: "onekey", + tags: ["Wallet"], + links: [ + { label: "website", link: "https://onekey.so/" }, + { label: "github", link: "https://github.com/OneKeyHQ/" }, + { label: "doc", link: "https://developer.onekey.so/" }, + ], + }, + { + title: "ForceBridge", + description: + "A cross-chain interoperability bridge b/w Nervos and other blockchains", + href: "https://forcebridge.com/", + bannerSrc: "forcebridge", + tags: ["Bridge"], + links: [ + { label: "website", link: "https://forcebridge.com/" }, + { + label: "github", + link: "https://github.com/nervosnetwork/force-bridge", + }, + { + label: "doc", + link: "https://github.com/nervosnetwork/force-bridge/blob/main/docs/dapp-user-guide.md", + }, + ], + }, + { + title: "Godwoken Bridge", + description: "A token bridge between CKB and Godwoken", + href: "https://bridge.godwoken.io/", + bannerSrc: "godwokenbridge", + tags: ["Bridge"], + links: [ + { label: "website", link: "https://bridge.godwoken.io/" }, + { + label: "github", + link: "https://github.com/godwokenrises/light-godwoken/tree/develop/apps/godwoken-bridge", + }, + { label: "doc", link: "https://docs.godwoken.io/" }, + ], + }, + { + title: "Yokaiswap Bridge", + description: + "A cross-chain interoperability bridge b/w Nervos and other blockchains", + href: "https://www.yokaiswap.com/bridge/", + bannerSrc: "yokaiswap", + tags: ["Bridge"], + links: [ + { label: "website", link: "https://www.yokaiswap.com/bridge/" }, + { label: "github", link: "https://github.com/yokaiswap" }, + ], + }, + { + title: "Ankr", + description: "The fastest, most reliable Web3 infrastructure", + href: "https://www.ankr.com/", + bannerSrc: "ankr", + tags: ["Tools & Infra"], + links: [ + { label: "website", link: "https://www.ankr.com/" }, + { + label: "doc", + link: "https://archive.nervos.org/blog/ankr-integrates-support-for-nervos-nodes", + }, + ], + }, + { + title: "Axon", + description: "A L2 framework that unleashes the power of appchain future", + href: "https://axonweb3.io/", + bannerSrc: "axon", + tags: ["Tools & Infra"], + links: [ + { label: "website", link: "https://axonweb3.io/" }, + { label: "github", link: "https://github.com/axonweb3/axon" }, + { label: "doc", link: "https://docs.axonweb3.io/" }, + ], + }, + { + title: "BandProtocol", + description: "A L2 framework that unleashes the power of appchain future", + href: "https://www.bandprotocol.com/", + bannerSrc: "bandprotocol", + tags: ["Tools & Infra"], + links: [ + { label: "website", link: "https://www.bandprotocol.com/" }, + { label: "github", link: "https://github.com/bandprotocol" }, + { + label: "doc", + link: "https://medium.com/bandprotocol/band-protocol-integrates-with-nervos-godwoken-361546e1091d", + }, + ], + }, + { + title: "DIA", + description: + "Provides fully customizable and transparent data feeds for smart contracts", + href: "https://www.diadata.org/", + bannerSrc: "dia", + tags: ["Tools & Infra"], + links: [ + { label: "website", link: "https://www.diadata.org/" }, + { + label: "doc", + link: "https://archive.nervos.org/blog/dia-deploys-oracles-onto-layer-2-bolstering-dev-resources", + }, + ], + }, + { + title: "Godwoken", + description: + "An EVM-compatible, L2 optimistic rollup solution built on Nervos L1", + href: "https://www.godwoken.com/", + bannerSrc: "godwoken", + tags: ["Tools & Infra"], + links: [ + { label: "website", link: "https://www.godwoken.com/" }, + { label: "github", link: "https://github.com/godwokenrises" }, + { label: "doc", link: "https://docs.godwoken.io/" }, + ], + }, + { + title: "Khalani", + description: + "A decentralized infrastructure for collaborative solving in intent-driven applications", + href: "https://khalani.network/", + bannerSrc: "khalani", + tags: ["Tools & Infra"], + links: [ + { label: "website", link: "https://khalani.network/" }, + { label: "doc", link: "https://blog.khalani.network/" }, + ], + }, + { + title: "Perun", + description: + "A L2 solution enhancing efficiency with off-chain transaction capabilities", + href: "https://perun.network/", + bannerSrc: "perun", + tags: ["Tools & Infra"], + links: [ + { label: "website", link: "https://perun.network/" }, + { label: "github", link: "https://github.com/perun-network/go-perun" }, + ], + }, + { + title: "Unifra", + description: + "A leading L2 platform that provides open, reliable infrastructure services", + href: "https://unifra.io/", + bannerSrc: "unifra", + tags: ["Tools & Infra"], + links: [{ label: "website", link: "https://unifra.io/" }], + }, + { + title: "F2Pool", + description: "Leading mining pool for PoW network", + href: "https://www.f2pool.com/", + bannerSrc: "f2pool", + tags: ["Mining pool"], + links: [ + { label: "website", link: "https://www.f2pool.com/" }, + { + label: "doc", + link: "https://f2pool.zendesk.com/hc/en-us/articles/22893426126489-How-to-mine-Nervos", + }, + ], + }, + { + title: "Antpool", + description: "World leading BTC mining pool", + href: "https://www.antpool.com/home?lang=en", + bannerSrc: "antpool", + tags: ["Mining pool"], + links: [ + { label: "website", link: "https://www.antpool.com/home?lang=en" }, + { + label: "doc", + link: "https://antpoolsupport-hc.zendesk.com/hc/en-us/articles/5985104597913-CKB-Mining", + }, + ], + }, + { + title: "Binance Pool", + description: "Enjoy zero pool fees with CKB mining", + href: "https://pool.binance.com/en", + bannerSrc: "binancepool", + tags: ["Mining pool"], + links: [ + { label: "website", link: "https://pool.binance.com/en" }, + { + label: "doc", + link: "https://www.binance.com/en/support/faq/how-to-mine-nervos-ckb-on-binance-pool-6967ad3306b84ec49dcbb5ed8ac30a9b", + }, + ], + }, + { + title: "2miners", + description: "The most profitable Nervos mining pool for GPU and ASIC", + href: "https://ckb.2miners.com/", + bannerSrc: "2miners", + tags: ["Mining pool"], + links: [{ label: "website", link: "https://ckb.2miners.com/" }], + }, + { + title: "ViaBTC", + description: + "Pool the world together by providing the best mining services", + href: "https://www.viabtc.com/", + bannerSrc: "viabtc", + tags: ["Mining pool"], + links: [{ label: "website", link: "https://www.viabtc.com/" }], + }, + { + title: "DxPool", + description: + "Technology leading blockchain infrastructure service provider", + href: "https://www.dxpool.com/", + bannerSrc: "dxpool", + tags: ["Mining pool"], + links: [{ label: "website", link: "https://www.dxpool.com/" }], + }, + { + title: "Poolin", + description: "A great bitocin and multi-cryptocurrency mining pool", + href: "https://www.poolin.com/", + bannerSrc: "poolin", + tags: ["Mining pool"], + links: [ + { label: "website", link: "https://www.poolin.com/" }, + { + label: "doc", + link: "https://help.poolin.me/hc/en-us/articles/360040689912-CKB-Mining-Settings", + }, + ], + }, ]; export default ecoCardContents; diff --git a/website/docs/getting-started/CardsContents.tsx b/website/docs/getting-started/CardsContents.tsx index 51fcad167..4141579af 100644 --- a/website/docs/getting-started/CardsContents.tsx +++ b/website/docs/getting-started/CardsContents.tsx @@ -60,7 +60,8 @@ const toolCardContents: CardProps[] = [ }, { title: "CKB-Debugger", - description: "A standalone debugger enabling off-chain contract development", + description: + "A standalone debugger enabling off-chain contract development", link: "https://github.com/nervosnetwork/ckb-standalone-debugger", type: "tool", links: [ @@ -131,7 +132,4 @@ const tutorialFrameContent = [ }, ]; -export { - toolCardContents, - tutorialFrameContent, -}; +export { toolCardContents, tutorialFrameContent }; diff --git a/website/docs/getting-started/devtool.md b/website/docs/getting-started/devtool.md index 8e8b447ba..56f53c051 100644 --- a/website/docs/getting-started/devtool.md +++ b/website/docs/getting-started/devtool.md @@ -8,6 +8,7 @@ import CardLayout from '@components/CardLayout'; import { toolCardContents } from './CardsContents'; # Dev Tools + Explore essential tools and resources tailored for development on Nervos CKB, designed to streamline your workflow from concept to deployment. ## Development & Deployment diff --git a/website/docs/getting-started/how-ckb-works.mdx b/website/docs/getting-started/how-ckb-works.mdx index e9208d06c..20b6e5ff6 100644 --- a/website/docs/getting-started/how-ckb-works.mdx +++ b/website/docs/getting-started/how-ckb-works.mdx @@ -9,15 +9,20 @@ To understand CKB, you first need to understand BTC. If you're familiar with BTC ## BTC’s UTXO vs. Cash -BTC works just like cash. To know how much money you have, you simply count the cash in your pocket. In the BTC world, this cash is termed as a [UTXO (Unspent Transaction Output)](/docs/tech-explanation/glossary/#utxo). +BTC works just like cash. To know how much money you have, you simply count the cash in your pocket. In the BTC world, this cash is termed as a [UTXO (Unspent Transaction Output)](/docs/tech-explanation/glossary/#utxo). -Features of UTXO +Features of UTXO -- **Code as a lock:** Unlike a piece of paper, a UTXO is more like a locked box. Each box carries a code that can only be unlocked by some predefined conditions. If you have the right keys, you can unlock the box and claim the ownership. -- **Monetary value display:** Each UTXO box records the monetary value on its surface much like the denomination on the cash. +- **Code as a lock:** Unlike a piece of paper, a UTXO is more like a locked box. Each box carries a code that can only be unlocked by some predefined conditions. If you have the right keys, you can unlock the box and claim the ownership. +- **Monetary value display:** Each UTXO box records the monetary value on its surface much like the denomination on the cash. - **Divisibility of value:** The value of UTXO boxes can be small or large. Larger value boxes can be split into multiple smaller one, allowing for precise value transactions similar to making change in cash dealings. -Now you understand the 80% of CKB, the rest 20% difference is that CKB uses generalized UTXOs called [Cell](/docs/tech-explanation/cell-model). A Cell is the basic unit of CKB, just like UTXOs to BTC. +Now you understand the 80% of CKB, the rest 20% difference is that CKB uses generalized UTXOs called [Cell](/docs/tech-explanation/cell-model). A Cell is the basic unit of CKB, just like UTXOs to BTC. But what exactly are generalized UTXOs? @@ -25,11 +30,11 @@ But what exactly are generalized UTXOs? UTXOs are like boxes that carry a lock made up of codes, with the monetary value clearly marked on the surface; Cells are boxes too, but much more versatile and powerful. -### Dynamic Storage +### Dynamic Storage UTXO boxes represent a specific amount of BTC and that's all it can hold—just the cryptocurrency value. UTXO boxes cannot expand and do not have the capacity to store additional data. -On the other hand, Cell boxes are different. Each Cell box not only holds a cryptocurrency value but also has storage capacity that can be used to hold arbitrary data. The larger the denomination, the more storage space available. 1 CKB = 1 byte of storage. Thus, if you have 50,000 CKB tokens, you get 50,000 bytes of on-chain storage space as well. +On the other hand, Cell boxes are different. Each Cell box not only holds a cryptocurrency value but also has storage capacity that can be used to hold arbitrary data. The larger the denomination, the more storage space available. 1 CKB = 1 byte of storage. Thus, if you have 50,000 CKB tokens, you get 50,000 bytes of on-chain storage space as well. ### Versatility of Content @@ -37,7 +42,7 @@ Cell boxes can store any data types, as long as there is enough space to fit the ### Advanced Coding Capabilities -Unlike the simple and limited code that UTXOs can carry, Cells can use complex, Turing-complete codes akin to the normal software runing on your computer. You can learn the difference of [limited scripts](https://en.bitcoin.it/wiki/Script) and [Turing-complete scripts](/docs/tech-explanation/glossary/#script) further. +Unlike the simple and limited code that UTXOs can carry, Cells can use complex, Turing-complete codes akin to the normal software runing on your computer. You can learn the difference of [limited scripts](https://en.bitcoin.it/wiki/Script) and [Turing-complete scripts](/docs/tech-explanation/glossary/#script) further. ### Dual Lock System @@ -61,14 +66,17 @@ Cell: { capacity: HexString; # represent the total storage space size of the Cell. The basic unit for capcaity is shannon, where 1 CKB equals 10**8 shannons. lock: Script; # a piece of code type: Script; # a piece of code - data: HexString; # this field can store arbitrary bytes, which means it can hold any type of data + data: HexString; # this field can store arbitrary bytes, which means it can hold any type of data } ``` + :::note - The total size of all four fiels above in a Cell must be less than or equal to the Cell's capacity, as shown below: +The total size of all four fiels above in a Cell must be less than or equal to the Cell's capacity, as shown below: + ``` capacity = Cell's total space >= Sum of the byte lengths of the 4 fields ``` + ::: A Script‘s structure looks like this: @@ -102,7 +110,12 @@ A major benefit of this design is efficiency. If everyone needs the same type of A transaction in CKB is simply an action that destroys some Cells and creates new ones. -transaction structure +transaction structure The Cells in the inputs must all be Live Cells. These input Cells will be spent and become Dead Cells after a transaction is committed. The newly created output Cells will then become new Live Cells. @@ -112,12 +125,14 @@ CKB also ensures that the total capacity of all output Cells is less than the to :::note In practice, for storage optimization reasons, we do not put the complete Cell in an input; instead, we just put the Cell's index that leads us to the real input Cell. This index structure is called OutPoint, which points to a particular Cell. -```sh + +```sh OutPoint: { tx_hash: HexString # The hash value of the transaction to which the target Cell belongs index: uint32 # The Cell position in the transaction to which the target Cell belongs } ``` + ::: ## Congratulations! diff --git a/website/docs/getting-started/quick-start.mdx b/website/docs/getting-started/quick-start.mdx index fe4a44ea6..ccaa94ede 100644 --- a/website/docs/getting-started/quick-start.mdx +++ b/website/docs/getting-started/quick-start.mdx @@ -3,8 +3,8 @@ id: quick-start title: Quick Start (5min) --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; # Quick Start (5min) @@ -27,15 +27,16 @@ Throughout this documentation, we use offckb/cli version **>=0.2.2**. You can al To setup a boilerplate for a full-stacked dApp, run the following command. Replace `` with any name you like. ```bash -offckb create +offckb create ``` -When prompted to select a bare template, use your arrow keys to select the frontend framework you prefer. If you wish to use a frontend framework not listed, please refer to [this section](/docs/getting-started/quick-start#different-frontend-framework). +When prompted to select a bare template, use your arrow keys to select the frontend framework you prefer. If you wish to use a frontend framework not listed, please refer to [this section](/docs/getting-started/quick-start#different-frontend-framework). ```mdx-code-block ``` + ```bash {3} ? Select a bare template Remix-Vite Bare Templates @@ -44,14 +45,17 @@ When prompted to select a bare template, use your arrow keys to select the fron A full-stack template with Next.js framework and ckb-script-templates, [next.js,tailwindcss,ckb-script-templates,typescript,rust] ``` + ```mdx-code-block ``` + ```bash Cloning into '/Users/Desktop/offckb/templates/temp-clone-folder'... Folder examples/next-js-template downloaded successfully from https://github.com/nervosnetwork/docs.nervos.org and moved to /Users/nervosDocs/Desktop/offckb/my-dapp-project ``` + ```mdx-code-block @@ -60,14 +64,15 @@ Folder examples/next-js-template downloaded successfully from https://github.com
How to create a Script-only project? - To create a project focused solely on Script development without any frontend work, you can run the following command. Replace `` with any name you like. - ```bash - offckb create --script - ``` - - Note that `offckb` essentially utilizes an underlying tool called `ckb-script-templates` to initialize Script projects. You can directly engage `ckb-script-templates` for more specific Script development tasks. For further details, refer to the [Script tutorial](/docs/script/minimal-script). -
+To create a project focused solely on Script development without any frontend work, you can run the following command. Replace `` with any name you like. + +```bash +offckb create --script +``` +Note that `offckb` essentially utilizes an underlying tool called `ckb-script-templates` to initialize Script projects. You can directly engage `ckb-script-templates` for more specific Script development tasks. For further details, refer to the [Script tutorial](/docs/script/minimal-script). + + ## Start the Devnet @@ -75,13 +80,16 @@ Folder examples/next-js-template downloaded successfully from https://github.com ``` + ```bash -offckb node +offckb node ``` + ```mdx-code-block ``` + ```bash /bin/sh: /Users/nervosDocs/.nvm/versions/node/v18.12.1/lib/node_modules/@offckb/cli/target/ckb/ckb: No such file or directory /Users/nervosDocs/.nvm/versions/node/v18.12.1/lib/node_modules/@offckb/cli/target/ckb/ckb not found, download and install the new version 0.113.1.. @@ -98,6 +106,7 @@ CKB output: 2024-03-20 07:56:45.320 +00:00 main INFO ckb_db_migration Init data CKB output: 2024-03-20 07:56:45.329 +00:00 main INFO ckb_launcher Touch chain spec hash: Byte32(0x3036c73473a371f3aa61c588c38924a93fb8513e481fa7c8d884fc4cf5fd368a) ``` + ```mdx-code-block @@ -106,20 +115,25 @@ CKB output: 2024-03-20 07:56:45.329 +00:00 main INFO ckb_launcher Touch chain s Your local CKB blockchain is currently active with the RPC endpoint at [localhost:8114](http://localhost:8114). To stop the chain, press `CTRL+C` in the terminal. To resume where you left off, simply run `offckb node` again. If you need to start fresh with a new chain, run the following command before starting the node: + ```mdx-code-block ``` + ```bash offckb clean ``` + ```mdx-code-block ``` + ```bash Chain data cleaned. ``` + ```mdx-code-block @@ -149,10 +163,9 @@ Once the server is up and running, you can view the dApp by visiting [localhost: The boilerplate project for a full-stack CKB dApp comprises two main components: -- The frontend, which utilizes the CKB JavaScript framework, [Lumos](https://github.com/ckb-js/lumos). +- The frontend, which utilizes the CKB JavaScript framework, [Lumos](https://github.com/ckb-js/lumos). - The Scripts, which leverages the [ckb-script-templates](https://github.com/nervosnetwork/ckb-script-templates). - By default, the Next.js template comes with a simple Script `hello-world` under `contracts/hello-world/src/main.rs`. :::note Tools You Need @@ -166,28 +179,33 @@ Check out the `ckb-script-templates` for more [details](https://github.com/crypt ::: ### Script-Related Commands + - Add a new Script: `make generate` - Build Script: `make build` - Run unit tests: `make test` - ### Deploy Scripts to Blockchain -After building your Scripts, you can navigate to your frontend workspace and deploy your Scripts to the Devnet or Testnet by using the following command: +After building your Scripts, you can navigate to your frontend workspace and deploy your Scripts to the Devnet or Testnet by using the following command: + ```mdx-code-block ``` + ```sh offckb deploy --network devnet ``` + ```mdx-code-block ``` + ```sh offckb deploy --network testnet ``` + ```mdx-code-block @@ -195,7 +213,7 @@ offckb deploy --network testnet ### Use Scripts in Frontend -If the deployment is successful, the `offckb.config.ts` file will contain the necessary details to import and utilize your Scripts in your frontend dApp. Here's how you can use your Scripts directly: +If the deployment is successful, the `offckb.config.ts` file will contain the necessary details to import and utilize your Scripts in your frontend dApp. Here's how you can use your Scripts directly: ```ts import offckb from "offckb.config"; @@ -211,7 +229,6 @@ const myContractDep: CellDep = { }; ``` - ## Switch Between Different Networks One of the things you might want to do is to switch between different blockchain networks during the development of your dApps. This can be accomplished by applying different environment variables in the project. @@ -222,7 +239,8 @@ According to your boilerplate, you can switch the CKB blockchain network by sett ``` -Run the following command in your terminal. Replace `devnet` with `testnet` or `mainnet` as needed: + +Run the following command in your terminal. Replace `devnet` with `testnet` or `mainnet` as needed: ```bash NETWORK=devnet yarn dev @@ -232,16 +250,19 @@ NETWORK=devnet yarn dev ``` -Search for the `.env` file, and modify `NEXT_PUBLIC_NETWORK` with your desired environment: + +Search for the `.env` file, and modify `NEXT_PUBLIC_NETWORK` with your desired environment: ```bash NEXT_PUBLIC_NETWORK=testnet # or testnet, mainnet ``` + Then, run the following command to start your dApp: ```bash npm run dev ``` + ```mdx-code-block @@ -255,13 +276,16 @@ npm run dev ``` + ```bash -offckb accounts +offckb accounts ``` + ```mdx-code-block ``` + ```bash #### ALL ACCOUNTS ARE FOR TEST AND DEVELOP ONLY #### #### DON'T USE THESE ACCOUNTS ON MAINNET #### @@ -310,6 +334,7 @@ lockScript: args: 0xe65f823bc5a48a38515690604e503dba4eb15d61 # More accounts... ``` + ```mdx-code-block @@ -327,20 +352,25 @@ Occasionally, you may prefer to use your personal CKB account rather than the pr :::tip CKB vs. Shannons 1 CKByte = 100,000,000 Shannons ::: + ```mdx-code-block ``` + ```bash offckb deposit --network devnet ``` + ```mdx-code-block ``` + ```bash tx hash: 0xe895970e9c75a5c4703c38a4e37b000895e7690552ba67ef82ae92109d7322fd ``` + ```mdx-code-block @@ -354,16 +384,20 @@ To check the balance of a specific account, use the following command. Replace ` ``` + ```bash offckb balance --network ``` + ```mdx-code-block ``` + ```bash Balance: 42000000 CKB ``` + ```mdx-code-block @@ -374,17 +408,21 @@ Balance: 42000000 CKB The frontend world is filled with numerous (perhaps too many) frameworks. New frameworks come out every day, and different developers have different preferences among these frameworks. So if you don't use the framework in the pre-defined boilerplate, like `remix-vite` and `next.js`, don't worry! You can still use `offckb` with the `inject-config` command. First, simply initialize your dApp project with your preferred framework, such as [CRA](https://create-react-app.dev/): + ```mdx-code-block ``` + ```bash npx create-react-app my-cra-dapp --template typescript ``` + ```mdx-code-block ``` + ```bash Creating a new React app in /Users/nervosDocs/Desktop/offckb/my-cra-dapp. @@ -393,27 +431,32 @@ Installing react, react-dom, and react-scripts with cra-template-typescript... added 1489 packages in 2m ``` + ```mdx-code-block ``` Next, navigate to your dApp directory and initialize the `offckb` config within your framework: + ```mdx-code-block ``` + ```bash cd my-cra-dapp offckb inject-config ``` + ```mdx-code-block ``` + ```bash -All good. You can now use it in your project like: - +All good. You can now use it in your project like: + import offCKB from "offckb.config"; const lumosConfig = offCKB.lumosConfig; @@ -422,26 +465,32 @@ const rpc = offCKB.rpc; Check example at https://github.com/nervosnetwork/docs.nervos.org/tree/develop/examples/simple-transfer ``` + ```mdx-code-block ``` Now, when you deploy your Scripts with `offckb deploy --network devnet --target `, run the following command in your frontend root path where the `offckb.config.ts` file is located to update the deployed Scripts info for your frontend. + ```mdx-code-block ``` + ```bash offckb sync-config ``` + ```mdx-code-block ``` + ```bash offCKB config updated. ``` + ```mdx-code-block @@ -450,23 +499,22 @@ offCKB config updated. For switching between different networks, you might need to update the `readEnvNetwork` method in `offckb.config.ts` according to your framework. ```ts -function readEnvNetwork(): 'devnet' | 'testnet' | 'mainnet' { +function readEnvNetwork(): "devnet" | "testnet" | "mainnet" { // you may need to update the env method // according to your frontend framework const network = process.env.NETWORK; - const defaultNetwork = 'devnet'; - if (!network)return defaultNetwork; - if(!['devnet', 'testnet', 'mainnet'].includes(network)){ + const defaultNetwork = "devnet"; + if (!network) return defaultNetwork; + if (!["devnet", "testnet", "mainnet"].includes(network)) { return defaultNetwork; } - return network as 'devnet' | 'testnet' | 'mainnet'; + return network as "devnet" | "testnet" | "mainnet"; } ``` -## About offckb.config.ts +## About offckb.config.ts `offckb.config.ts` is a straightforward TypeScript file that encapsulates basic info and configs for [Lumos](https://github.com/ckb-js/lumos). Everything is explicitly defined, making it easy to modify. This minimalistic approach ensures that `offckb` does not impose limitations on the tech selections and development processes of developers. If you have any feedback you would like to share with us, feel free to contact us at [github](https://github.com/nervosnetwork/docs.nervos.org) or [discord](https://discord.gg/AqGTUE9). - diff --git a/website/docs/integrate-wallets/CardContents.tsx b/website/docs/integrate-wallets/CardContents.tsx index 7d9f3d6ed..3a43f3da3 100644 --- a/website/docs/integrate-wallets/CardContents.tsx +++ b/website/docs/integrate-wallets/CardContents.tsx @@ -1,46 +1,46 @@ import { WalletCardProps } from "@site/src/components/WalletCard"; const walletCardContents: WalletCardProps[] = [ - { - title: 'Neuron', - href: 'https://neuron.magickbase.com/', - tags: ['Desktop'], - }, - { - title: 'JoyID', - href: 'https://joy.id/', - tags: ['Web-based'], - }, - { - title: 'imToken', - href: 'https://token.im/ckb-wallet', - tags: ['Mobile'], - }, - { - title: 'CKBull', - href: 'https://ckbull.app/#download', - tags: ['Mobile'], - }, - { - title: 'SafePal', - href: 'https://blog.safepal.com/ckb/', - tags: ['Mobile', 'Hardware'], - }, - { - title: 'Ledger', - href: 'https://www.ledger.com/', - tags: ['Hardware'], - }, - { - title: 'imKey', - href: 'https://imkey.im/', - tags: ['Hardware'], - }, - { - title: 'OneKey', - href: 'https://onekey.so/', - tags: ['Mobile', 'Desktop', 'Hardware'], - }, - ]; - - export { walletCardContents }; \ No newline at end of file + { + title: "Neuron", + href: "https://neuron.magickbase.com/", + tags: ["Desktop"], + }, + { + title: "JoyID", + href: "https://joy.id/", + tags: ["Web-based"], + }, + { + title: "imToken", + href: "https://token.im/ckb-wallet", + tags: ["Mobile"], + }, + { + title: "CKBull", + href: "https://ckbull.app/#download", + tags: ["Mobile"], + }, + { + title: "SafePal", + href: "https://blog.safepal.com/ckb/", + tags: ["Mobile", "Hardware"], + }, + { + title: "Ledger", + href: "https://www.ledger.com/", + tags: ["Hardware"], + }, + { + title: "imKey", + href: "https://imkey.im/", + tags: ["Hardware"], + }, + { + title: "OneKey", + href: "https://onekey.so/", + tags: ["Mobile", "Desktop", "Hardware"], + }, +]; + +export { walletCardContents }; diff --git a/website/docs/integrate-wallets/integrate-joyid.mdx b/website/docs/integrate-wallets/integrate-joyid.mdx index 03f606d48..d4d38b28d 100644 --- a/website/docs/integrate-wallets/integrate-joyid.mdx +++ b/website/docs/integrate-wallets/integrate-joyid.mdx @@ -4,7 +4,7 @@ title: JoyID --- ## Integrate Wallet (JoyID) -For developers looking to integrate wallets into their dApps, we currently recommend using JoyID, the most popular wallet in our ecosystem. JoyID offers a seamless experience for users, enabling secure and efficient interactions with your dApp. -For a comprehensive guide on integrating JoyID, please visit [JoyID-Connect](https://docs.joyid.dev/guide/evm/connect). Stay tuned for future integration guides for additional wallets as our ecosystem continues to grow. +For developers looking to integrate wallets into their dApps, we currently recommend using JoyID, the most popular wallet in our ecosystem. JoyID offers a seamless experience for users, enabling secure and efficient interactions with your dApp. +For a comprehensive guide on integrating JoyID, please visit [JoyID-Connect](https://docs.joyid.dev/guide/evm/connect). Stay tuned for future integration guides for additional wallets as our ecosystem continues to grow. diff --git a/website/docs/integrate-wallets/intro-to-wallets.mdx b/website/docs/integrate-wallets/intro-to-wallets.mdx index 15b1d7aad..5ac9dda00 100644 --- a/website/docs/integrate-wallets/intro-to-wallets.mdx +++ b/website/docs/integrate-wallets/intro-to-wallets.mdx @@ -6,50 +6,45 @@ title: Intro to Wallets import useBaseUrl from "@docusaurus/useBaseUrl"; import Link from "@docusaurus/Link"; -import WalletCard from '@components/WalletCard'; -import CardLayout from '@components/CardLayout'; -import { walletCardContents } from './CardContents'; +import WalletCard from "@components/WalletCard"; +import CardLayout from "@components/CardLayout"; +import { walletCardContents } from "./CardContents"; Essential insights for CKB dApp developers, covering wallet choices, address specifics, and CKB transfer guidelines - ## CKB Wallet Options Crypto wallets store private keys to access cryptos. They come in two types: hot wallets (online) and cold wallets (offline). Hot wallets, such as web-based, desktop, and mobile wallets, offer convenience but pose higher risk. Cold wallets, including paper and hardware wallets, provide enhanced security by keeping keys offline. -When it comes to storing and securing CKB assets, users have various options, including hot and cold wallets. While storing assets on exchanges is common, additional security can be achieved with dedicated wallets. +When it comes to storing and securing CKB assets, users have various options, including hot and cold wallets. While storing assets on exchanges is common, additional security can be achieved with dedicated wallets. These wallets listed below offer custody and security services tailored to CKB. For more information, refer to the respective guides for each wallet. - -{walletCardContents.map(({ index, title, href, tags }) => ( - + + {walletCardContents.map(({ index, title, href, tags }) => ( + ))} --- ## CKB Address -Nervos CKB follows [Bitcoin's bech32m address format (BIP-350)](https://github.com/sipa/bips/blob/bip-bech32m/bip-0350.mediawiki) for address generation. It features a new full address format like this: `ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqdnnw7qkdnnclfkg59uzn8umtfd2kwxceqxwquc4`. +Nervos CKB follows [Bitcoin's bech32m address format (BIP-350)](https://github.com/sipa/bips/blob/bip-bech32m/bip-0350.mediawiki) for address generation. It features a new full address format like this: `ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqdnnw7qkdnnclfkg59uzn8umtfd2kwxceqxwquc4`. -The previous short address format is now **deprecated**, for example: `ckb1qyq5lv479ewscx3ms620sv34pgeuz6zagaaqklhtgg`. +The previous short address format is now **deprecated**, for example: `ckb1qyq5lv479ewscx3ms620sv34pgeuz6zagaaqklhtgg`. Tools for address generation and transformation include: + - [CKB.tools/address](https://ckb.tools/) - [CKB Lumos](https://lumos-website.vercel.app/#2-generate-a-wallet-account) - [ckb-address-transformer](https://codesandbox.io/s/ckb-address-transformer-524gi) For detailed specifications, refer to [RFC0021: CKB Address Format](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0021-ckb-address-format/0021-ckb-address-format.md). - ## Requirements for CKB Transfers To initiate a transfer, you need at least one Cell. Each Cell comprises the essential data fields: `capacity`, `lock`, `args`, and `hash_type`, with storage sizes as follows: + - `capacity`: 8 bytes - `lock`: 32 bytes - `args`: 20 bytes diff --git a/website/docs/mining/cost-and-profit.mdx b/website/docs/mining/cost-and-profit.mdx index e66795882..a11542998 100644 --- a/website/docs/mining/cost-and-profit.mdx +++ b/website/docs/mining/cost-and-profit.mdx @@ -2,9 +2,11 @@ id: cost-and-profit title: Cost & Profit --- + import useBaseUrl from "@docusaurus/useBaseUrl"; # Cost & Profit + Mining CKBytes allows you to essentially purchase CKBytes at the cost of energy rather than market prices. Mining involves costs such as electricity, hardware, cooling, maintenance, and pool fees. - **Electricity**: Key expense in CKB mining, as the computational power needed consumes significant power. Miners seek low-cost electricity regions or renewable energy sources to cut expenses. @@ -15,7 +17,11 @@ Mining CKBytes allows you to essentially purchase CKBytes at the cost of energy - **Space and Rent**: Dedicated facilities may be rented or purchased for equipment setup. - **Mining Pool Fees**: Miners joining pools incur fees for services like block rewards distribution. -f2pool comparison +f2pool comparison Profit depends on factors like: diff --git a/website/docs/mining/guide.mdx b/website/docs/mining/guide.mdx index a04e1502c..36ac630d2 100644 --- a/website/docs/mining/guide.mdx +++ b/website/docs/mining/guide.mdx @@ -40,7 +40,6 @@ Many other wallets are also available. The Nervos Community maintains a more com Selecting a mining pool is one of the most important decisions you will make when you start mining. This is not only important for your profitability as a miner, but it is also important for the long-term health of the network itself. > Decentralized blockchains can become more vulnerable to a 51% attack when too much mining power is concentrated in single mining pools. When choosing a pool, consider selecting one of the smaller pools to help keep the hash power decentralized. -> Larger pools tend to find blocks more quickly, and thus have faster payouts for miners. However, the payouts are smaller since you represent a smaller slice of the total pool. Smaller pools will have slower payouts but each payout will be larger. In theory, total earnings between a large and small pool should be roughly the same in the long term. @@ -89,7 +88,7 @@ After these steps are completed, your miner should be up and running. Sometimes ## Where to Get Help -If you have trouble with your miner, check to see if the manufacturer provides support. Some pools will also offer support for users who need help configuring their miners. +If you have trouble with your miner, check to see if the manufacturer provides support. Some pools will also offer support for users who need help configuring their miners. You can also ask other CKB miners on [Telegram](https://t.me/NervosMining) and [Discord](https://discord.com/channels/657799690070523914/671647273603694625) for help since many of them will be running similar equipment on similar pools. diff --git a/website/docs/mining/hardware.mdx b/website/docs/mining/hardware.mdx index 4eaddc845..5b15aa2ca 100644 --- a/website/docs/mining/hardware.mdx +++ b/website/docs/mining/hardware.mdx @@ -2,14 +2,19 @@ id: hardware title: Hardware --- + import useBaseUrl from "@docusaurus/useBaseUrl"; # Hardware Since March 2020, CKB mining has gradually shifted towards ASIC mining. Mining CKB requires purchasing professional mining machines developed by third-party manufacturers. -mining hardware +mining hardware -CKB miners can be acquired from platforms such as: [estripe.com](http://estripe.com/), [Bitmain Official Store](https://shop.bitmain.com/?coin=CKB), [Wyminer](https://www.wyminer.com/), and [Newegg](https://www.newegg.com/). +CKB miners can be acquired from platforms such as: [estripe.com](http://estripe.com/), [Bitmain Official Store](https://shop.bitmain.com/?coin=CKB), [Wyminer](https://www.wyminer.com/), and [Newegg](https://www.newegg.com/). Platforms like [f2pool](https://www.f2pool.com/miners?currency_code=ckb) offer insights into mining revenue comparison, helping you make informed decisions. diff --git a/website/docs/mining/rewards.mdx b/website/docs/mining/rewards.mdx index efb31cccd..569fffb84 100644 --- a/website/docs/mining/rewards.mdx +++ b/website/docs/mining/rewards.mdx @@ -7,7 +7,7 @@ import useBaseUrl from "@docusaurus/useBaseUrl"; # Rewards -CKB block rewards comprise base reward, secondary reward, proposal reward, and commitment reward, jointly determined by Nervos’ tokenomics and the NC Max consensus. +CKB block rewards comprise base reward, secondary reward, proposal reward, and commitment reward, jointly determined by Nervos’ tokenomics and the NC Max consensus. - **Base Reward**: Halves every 4 years, totaling 33.6 billion CKB. - **Secondary Reward**: Fixed at 1.344 billion annually, distributed based on network usage. @@ -15,25 +15,33 @@ CKB block rewards comprise base reward, secondary reward, proposal reward, and c ## Base reward -CKB's base reward, similar to Bitcoin's issuance, has a fixed upper limit and undergoes halving approximately every four years. Unlike Bitcoin, which employs fixed block rewards and difficulty adjustment of every 2016 blocks, CKB uses the NC-Max consensus, adjusting difficulty based on the [orphan rate](/docs/tech-explanation/glossary#orphan-rate). The orphan rate of the previous [Cycle](/docs/tech-explanation/glossary#cycles) is calculated, and then the difficulty adjustment is calculated based on a series of parameter adjustments to maintain a relatively constant orphan block rate for the entire network. During each difficulty adjustment, the block count for the next Cycle is calculated. Therefore, the number of blocks mined within each Cycle vary. +CKB's base reward, similar to Bitcoin's issuance, has a fixed upper limit and undergoes halving approximately every four years. Unlike Bitcoin, which employs fixed block rewards and difficulty adjustment of every 2016 blocks, CKB uses the NC-Max consensus, adjusting difficulty based on the [orphan rate](/docs/tech-explanation/glossary#orphan-rate). The orphan rate of the previous [Cycle](/docs/tech-explanation/glossary#cycles) is calculated, and then the difficulty adjustment is calculated based on a series of parameter adjustments to maintain a relatively constant orphan block rate for the entire network. During each difficulty adjustment, the block count for the next Cycle is calculated. Therefore, the number of blocks mined within each Cycle vary. -CKB's adjustments are made based on Cycles. The total block reward within each Cycle is a fixed value, with a target Cycle time of 4 hours. That is to say, when the block interval of a Cycle becomes longer and the number of blocks decreases, the block reward per block will increase accordingly, and vice versa. Through this method, CKB ensures that a fixed total block reward is always distributed over an integer number of Cycles every 4 hours, ensuring that the system's [halving schedule](https://explorer.nervos.org/halving) is maintained. +CKB's adjustments are made based on Cycles. The total block reward within each Cycle is a fixed value, with a target Cycle time of 4 hours. That is to say, when the block interval of a Cycle becomes longer and the number of blocks decreases, the block reward per block will increase accordingly, and vice versa. Through this method, CKB ensures that a fixed total block reward is always distributed over an integer number of Cycles every 4 hours, ensuring that the system's [halving schedule](https://explorer.nervos.org/halving) is maintained. The total amount of base reward is 33.6 billion CKB, halving every 4 years. The [first halving](https://www.youtube.com/watch?v=kZ6v0pqv1w4) took place on November 19, 2023. ## Secondary reward -Unlike Bitcoin, which relies solely on basic issuance, CKB introduces secondary issuance to maintain miner incentives and network security after the halving. +Unlike Bitcoin, which relies solely on basic issuance, CKB introduces secondary issuance to maintain miner incentives and network security after the halving. Secondary issuance occurs annually alongside basic issuance, providing a fixed amount of CKB identical to basic issuance. However, not all secondary issuance goes to miners. It's distributed based on the network's state. Miners receive compensation for storing and actively using CKB, but not for CKB without data storage or locked in Nervos DAO. -Three States of CKBytes +Three States of CKBytes -*Three States of CKBytes* +_Three States of CKBytes_ The total amount of secondary issuance issued annually is fixed at 1.344 billion. The portion allocated to miners depends on the CKBytes' usage rate. Higher usage rates lead to more CKBytes for miners. -Secondary Issuance Allocation +Secondary Issuance Allocation *Secondary Issuance Allocation* ## Proposal Reward and Commit Reward @@ -48,8 +56,7 @@ Miners who mine block N will receive: The amount of CKBytes mined annually can be calculated by the formula below: -> Annual Quantity of CKBytes Mined = Base Reward + Secondary Reward - CKBytes Burned in Secondary Issuance -> +> Annual Quantity of CKBytes Mined = Base Reward + Secondary Reward - CKBytes Burned in Secondary Issuance Where: @@ -57,4 +64,8 @@ Where: - **Secondary Reward**: 1.344 billion per year - **CKBytes Burned in Secondary Issuance**: This refers to the CKB allocated to the treasury, which is dynamically changing. The quantity is proportional to the percentage of circulating CKB to the total amount. According to [CKB Explorer](https://explorer.nervos.org/charts/secondary-issuance), at the time of writing, the CKBytes burnt accounted for 69.58% of the secondary issuance. -charts_secondary-issuance +charts_secondary-issuance diff --git a/website/docs/mining/risks.mdx b/website/docs/mining/risks.mdx index 69a4f1160..ef3204b59 100644 --- a/website/docs/mining/risks.mdx +++ b/website/docs/mining/risks.mdx @@ -7,18 +7,16 @@ title: Potential Risks ## Legal and Policy Concerns -The impact of mining on energy consumption and its implications on traditional financial systems remain unclear to certain areas. The legality of mining activities varies depending on the jurisdiction. +The impact of mining on energy consumption and its implications on traditional financial systems remain unclear to certain areas. The legality of mining activities varies depending on the jurisdiction. Mining activities should be conducted in accordance with the legal regulations of the respective region. - ## Challenges in Acquiring Mining Equipment Mining equipment prices are often correlate with the price of cryptocurrencies, exposing them to fluctuations in cryptocurrency prices. Additionally, mining equipment purchased through unofficial channels may pose quality issues. - ## Volatility With CKB Price Fluctuations CKB is not a stable coin. Its value is tied to consensus Bytes, but the market decides the worth of these Bytes. diff --git a/website/docs/node/rpcs.mdx b/website/docs/node/rpcs.mdx index 56104615c..59e73102c 100644 --- a/website/docs/node/rpcs.mdx +++ b/website/docs/node/rpcs.mdx @@ -2,36 +2,42 @@ id: rpcs title: RPCs --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; # RPCs + CKB RPCs are a set of programming interfaces provided by the Nervos CKB blockchain, enabling developers to interact with the network for querying data, managing transactions, and deploying smart contracts directly. ## Public JSON RPC Nodes + - These nodes are provided by community members, they may be unstable, incomplete or not work at all, use at your own risk. - You may use these nodes to try out or test some features, but you should not use them for production. - Since ckb v0.105.0, ckb already included indexer service, just use ckb jsonrpc url for indexer service. -Type | Link --------------|------------------------------ -Mainnet | https://mainnet.ckbapp.dev/ -Mainnet | https://mainnet.ckb.dev/ -Testnet | https://testnet.ckbapp.dev/ -Testnet | https://testnet.ckb.dev/ +| Type | Link | +| ------- | --------------------------- | +| Mainnet | https://mainnet.ckbapp.dev/ | +| Mainnet | https://mainnet.ckb.dev/ | +| Testnet | https://testnet.ckbapp.dev/ | +| Testnet | https://testnet.ckb.dev/ | ## RPC Provider: Ankr + Ankr is an RPC provider that wors as intermediary to help you interact with the Nervos Network. You might experience some levels of latency depending on the provider’s location. Ankr’s endpoint root: [https://rpc.ankr.com/nervos](https://rpc.ankr.com/nervos) ## CKB JSON-RPC Protocols + CKB exposes a set of RPCs in [JSON-RPC 2.0](https://www.jsonrpc.org/specification) protocols for interactions. For more details, please refer to [CKB JSON RPC Protocols Documentation](https://github.com/nervosnetwork/ckb/blob/master/rpc/README.md). :::tip + - The RPCs exposed by CKB are only designed for internal usage. Please limit the access to the CKB RPCs strictly to trusted machines (by using rpc.listen_address configuration option). Exposing CKB RPCs to the public Internet is dangerous and strongly discouraged. - CKB JSON-RPC only supports HTTP now. If you need SSL support, please setup a reverse proxy via nginx or other HTTPS servers. - Subscriptions require a full duplex connection. CKB offers such connections in the form of tcp (enable with rpc.tcp_listen_address configuration option) and websockets (enable with rpc.ws_listen_address), plain HTTP connection does not support subscriptions. See below for examples on this. -::: + ::: ## Basic Usage @@ -41,6 +47,7 @@ The following commands uses [get_tip_block_number](https://github.com/nervosnetw ``` + ``` echo '{ "id": 2, @@ -57,9 +64,11 @@ http://localhost:8114 ``` + ```bash {"jsonrpc":"2.0","result":"0x2cb4","id":2} ``` + ```mdx-code-block @@ -71,6 +80,7 @@ The following commands uses `send_transaction` RPC to send transactions to the C ``` + ``` echo '{ "id": 3, @@ -122,10 +132,12 @@ echo '{ | curl -H 'content-type: application/json' -d @- \ http://localhost:8114 ``` + ```mdx-code-block ``` + ```json { "id": 3, @@ -133,6 +145,7 @@ http://localhost:8114 "result": "0xa0ef4eb5f4ceeb08a4c8524d84c5da95dce2f608e0ca2ec8091191b0f330c6e3" } ``` + ```mdx-code-block @@ -144,6 +157,7 @@ It should be noted that `send_transaction` is asynchronous, that is, the return ``` + ``` echo '{ "id": 4, @@ -155,10 +169,12 @@ echo '{ | curl -H 'content-type: application/json' -d @- \ http://localhost:8114 ``` + ```mdx-code-block ``` + ```json { "id": 4, @@ -198,14 +214,12 @@ http://localhost:8114 "type": null } ], - "outputs_data": [ - "0x" - ], + "outputs_data": ["0x"], "version": "0x0", "witnesses": [] }, "cycles": "0x219", - "time_added_to_pool" : "0x187b3d137a1", + "time_added_to_pool": "0x187b3d137a1", "tx_status": { "block_hash": null, "status": "pending", @@ -214,6 +228,7 @@ http://localhost:8114 } } ``` + ```mdx-code-block @@ -222,6 +237,7 @@ http://localhost:8114 ## Subscription To use `subscription` feature, you need to configure CKB to enable such features. In this section, we assume you use the following configuration in `CKB.toml`section: + ``` [rpc] listen_address = "127.0.0.1:8114" @@ -230,6 +246,7 @@ ws_listen_address = "127.0.0.1:18115" # ... more configs ``` + This above config ensures CKB listens at 8114 port for normal HTTP connections, 18114 port for TCP duplex connections, and 18115 port for WebSocket duplex connections. ## TCP Based RPC @@ -309,20 +326,20 @@ CKB's RPCs returns data in JSON format. While most fields are self-explanatory, All numbers used in CKB's RPCs, including request parameters and return values, use hex encoding, the number is encoded first in hexadecimal in the most compact format(meaning useless leading zeros should be striped), and then prefixed with `0x`. Here are some examples: -* `0` is encoded as `0x0`, we cannot remove the remaining `0` since otherwise it won't be a proper number -* `4` is encoded as `0x4` -* `15` is encoded as `0xf` -* `42` is encoded as `0x2a` -* `291` is encoded as `0x123` -* `3984` is encoded as `0xf90` +- `0` is encoded as `0x0`, we cannot remove the remaining `0` since otherwise it won't be a proper number +- `4` is encoded as `0x4` +- `15` is encoded as `0xf` +- `42` is encoded as `0x2a` +- `291` is encoded as `0x123` +- `3984` is encoded as `0xf90` ### Binary Data All binary data, including all the hashes, `args` in script, `outputs_data` items, are represented as hex string with `0x` prefix. Some examples include: -* `0x65b253cdcb6226e7f8cffec5c47c959b3d74af2caf7970a1eb1500e9b92aa200` -* `0x927f3e74dceb87c81ba65a19da4f098b4de75a0d` -* `0x40420f00000000000000000000000000` -* `0x` (empty data) +- `0x65b253cdcb6226e7f8cffec5c47c959b3d74af2caf7970a1eb1500e9b92aa200` +- `0x927f3e74dceb87c81ba65a19da4f098b4de75a0d` +- `0x40420f00000000000000000000000000` +- `0x` (empty data) Unlike numbers, binary data should always have a even numbered length. diff --git a/website/docs/node/run-devnet-node.mdx b/website/docs/node/run-devnet-node.mdx index 96e73f13e..83d8b0665 100644 --- a/website/docs/node/run-devnet-node.mdx +++ b/website/docs/node/run-devnet-node.mdx @@ -3,8 +3,8 @@ id: run-devnet-node title: Run a Devnet Node --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; # Run a Devnet Node @@ -39,25 +39,31 @@ It is highly recommended to use `Dummy-Worker` for most development scenarios. ` ::: ### Download CKB Binary + Download the latest `ckb` binary file from the CKB releases page on [GitHub](https://github.com/nervosnetwork/ckb/releases). The following commands can be used to verify the binaries are working and to check versions: + ```mdx-code-block ``` + ```bash ckb --version ckb-cli --version ``` + ```mdx-code-block ``` + ```bash ckb 0.115.0-rc2 (e4bb6c8 2024-03-20) ckb-cli 1.7.0 (0c8711e 2024-02-29) ``` + ```mdx-code-block @@ -68,17 +74,21 @@ ckb-cli 1.7.0 (0c8711e 2024-02-29) ### 1. Initialize Use the following command to initialize the development blockchain and generate the required configuration files: + ```mdx-code-block ``` + ```bash ckb init --chain dev ``` + ```mdx-code-block ``` + ```bash WARN: mining feature is disabled because of lacking the block assembler config options Initialized CKB directory in /PATH/ckb_v0.115.0-rc2_x86_64-unknown-linux-gnu @@ -88,6 +98,7 @@ create ckb-miner.toml create default.db-options Genesis Hash: 0x180621a13efd899730abfb3dd7aaa82f4b61ac9ed5283fe73b47b0f4c4196757 ``` + ```mdx-code-block @@ -102,21 +113,25 @@ The Block Assembler configuration specifies which address should receive block r To receive the block rewards, you'll need to generate an address. This can be accomplished using the `ckb-cli` tool. ##### Note: Be sure to record the `lock_arg` value in the response which we will use in the next step. + ```mdx-code-block ``` + ```bash ckb-cli account new ``` + ```mdx-code-block ``` + ```bash Your new account is locked with a password. Please give a password. Do not forget this password. -Password: -Repeat password: +Password: +Repeat password: address: mainnet: ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqghklqs0vttylku4pjxhr8hxsaratn8muc28r7vu testnet: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqghklqs0vttylku4pjxhr8hxsaratn8mucy4g3xy @@ -126,6 +141,7 @@ address(deprecated): lock_arg: 0x17b7c107b16b27edca8646b8cf7343a3eae67df3 lock_hash: 0x9fecea1600fecfac989b2d15dc227b885afe68f5b652a1a159b59cb69e83ddae ``` + ```mdx-code-block @@ -138,7 +154,7 @@ Modify the `args` and `message` parameters in the `ckb.toml` file under the `blo ```bash [block_assembler] code_hash = "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8" # Do not change this. -args = "0x8d627decece439977a3a0a97815b63debaff2874" # Change this to your lock_arg value. +args = "0x8d627decece439977a3a0a97815b63debaff2874" # Change this to your lock_arg value. hash_type = "type" # Do not change this. message = "A 0x-prefixed hex string" # Change this to "0x" to supply an empty message. ``` @@ -184,17 +200,21 @@ value = 5000 # The unit of measurement is "ms". ``` ### 4. Start CKB Node + ```mdx-code-block ``` + ```bash ckb run ``` + ```mdx-code-block ``` + ```bash 2020-06-05 18:31:14.970 +08:00 main INFO sentry sentry is disabled 2020-06-05 18:31:15.058 +08:00 main INFO ckb-db Initialize a new database @@ -210,6 +230,7 @@ ckb run 2020-06-05 18:31:15.211 +08:00 main INFO ckb-db Init database version 20191201091330 2020-06-05 18:31:26.586 +08:00 ChainService INFO ckb-chain block: 1, hash: 0x47995f78e95202d2c85ce11bce2ee16d131a57d871f7d93cd4c90ad2a8220bd1, epoch: 0(1/1000), total_diff: 0x200, txs: 1 ``` + ```mdx-code-block @@ -218,25 +239,30 @@ ckb run ### 5. Start CKB Miner This should be performed in a separate terminal. + ```mdx-code-block ``` + ```bash ckb miner ``` + ```mdx-code-block ``` + ```bash 2020-06-05 18:31:21.558 +08:00 main INFO sentry sentry is disabled -Dummy-Worker ⠁ [00:00:00] +Dummy-Worker ⠁ [00:00:00] Found! #1 0x47995f78e95202d2c85ce11bce2ee16d131a57d871f7d93cd4c90ad2a8220bd1 Found! #2 0x19978085abfa6204471d42bfb279eac0c20e3b81745b48c4dcaea85643e301f9 Found! #3 0x625b230f84cb92bcd9cb0bf76d1397c1d948ab25c19df3c4edc246a765f94427 Found! #4 0x4550fb3b62d9d5ba4d3926db6704b25b90438cfb67037d253ceceb2d86ffdbf7 ``` + ```mdx-code-block @@ -254,18 +280,21 @@ An address to receive the block rewards must be created using `ckb-cli`. ``` + ```bash $ ckb-cli account new ``` + ```mdx-code-block ``` + ```bash ckb-cli account new Your new account is locked with a password. Please give a password. Do not forget this password. -Password: -Repeat password: +Password: +Repeat password: address: mainnet: ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqghklqs0vttylku4pjxhr8hxsaratn8muc28r7vu testnet: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqghklqs0vttylku4pjxhr8hxsaratn8mucy4g3xy @@ -275,29 +304,35 @@ address(deprecated): lock_arg: 0x17b7c107b16b27edca8646b8cf7343a3eae67df3 lock_hash: 0x9fecea1600fecfac989b2d15dc227b885afe68f5b652a1a159b59cb69e83ddae ``` + ```mdx-code-block ``` ### 2. Initialize Miner + ```mdx-code-block ``` + ```bash -ckb init -c dev --ba-arg 0x41ecee7b8fc0783c75da1f4346009b2e5a774a96 // Change this to your lock_arg value. +ckb init -c dev --ba-arg 0x41ecee7b8fc0783c75da1f4346009b2e5a774a96 // Change this to your lock_arg value. ``` + ```mdx-code-block ``` + ```bash Initialized CKB directory in /PATH/ckb_v0.32.1_x86_64-apple-darwin create specs/dev.toml create ckb.toml create ckb-miner.toml ``` + ```mdx-code-block @@ -320,17 +355,21 @@ threads = 1 ``` ### 4. Start CKB Node + ```mdx-code-block ``` + ```bash ckb run ``` + ```mdx-code-block ``` + ```bash 2020-06-05 11:25:31.433 +08:00 main INFO sentry sentry is disabled 2020-06-05 11:25:31.508 +08:00 main INFO ckb-db Initialize a new database @@ -345,6 +384,7 @@ ckb run 2020-06-05 11:25:31.612 +08:00 main INFO ckb-db Initialize a new database 2020-06-05 11:25:31.638 +08:00 main INFO ckb-db Init database version 20191201091330 ``` + ```mdx-code-block @@ -353,25 +393,30 @@ ckb run ### 5. Start CKB Miner This should be performed in a separate terminal. + ```mdx-code-block ``` + ```bash ckb miner ``` + ```mdx-code-block ``` + ```bash 2020-06-05 11:25:37.867 +08:00 main INFO sentry sentry is disabled -EaglesongSimple-Worker-0 ⠁ [00:00:00] +EaglesongSimple-Worker-0 ⠁ [00:00:00] 2020-06-05 11:25:37.870 +08:00 main INFO ckb-memory-tracker track current proceFound! #1 0x57e6ad0f15bacc4f30e53811d488d895e6619c17222981eca5484f0115f84acd Found! #2 0xe5831f39f928dca599a02e490c482a881ccdc47a2376371dec4e440e363fa5c0 Found! #3 0x605b3e6449954c2daa996c06b2412bbf60b8231763149742119fb623f9de27b2 Found! #4 0x64064e7257ea4589e8cb177cf119c68ab1b4559de005a20dc13ef3d42949e04b ``` + ```mdx-code-block @@ -388,17 +433,21 @@ Using `ckb-cli` to transfer CKBytes is recommended only for development and test ::: ### 1. Access `ckb-cli` + ```mdx-code-block ``` + ```bash ckb-cli ``` + ```mdx-code-block ``` + ```bash [ ckb-cli version ]: 1.7.0 (0c8711e 2024-02-29) [ url ]: http://127.0.0.1:8114/ (network: Dev, loading...) @@ -412,28 +461,33 @@ ckb-cli No previous history. CKB> ``` + ```mdx-code-block ``` ### 2. Create Account + ```mdx-code-block ``` + ```bash account new ``` + ```mdx-code-block ``` + ```bash $ ckb-cli account new Your new account is locked with a password. Please give a password. Do not forget this password. -Password: -Repeat password: +Password: +Repeat password: address: mainnet: ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqghklqs0vttylku4pjxhr8hxsaratn8muc28r7vu testnet: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqghklqs0vttylku4pjxhr8hxsaratn8mucy4g3xy @@ -443,6 +497,7 @@ address(deprecated): lock_arg: 0x17b7c107b16b27edca8646b8cf7343a3eae67df3 lock_hash: 0x9fecea1600fecfac989b2d15dc227b885afe68f5b652a1a159b59cb69e83ddae ``` + ```mdx-code-block @@ -456,65 +511,80 @@ In the previous sections, you created a miner account that collects all mining r ``` + ```bash -wallet get-capacity --address "miner's address" +wallet get-capacity --address "miner's address" ``` + ```mdx-code-block ``` + ```bash CKB> wallet get-capacity --address "ckt1qyqg6cnaankwgwvh0gaq49uptd3aawhl9p6qpg5cus" immature: 8027902.89083717 (CKB) total: 46253677.72927512 (CKB) ``` + ```mdx-code-block ``` ### 4. Transfer CKBytes + ```mdx-code-block ``` + ```bash wallet transfer --from-account "miner's address" --to-address "new account's address" --capacity 10000 --tx-fee 0.00001 ``` + ```mdx-code-block ``` + ```bash CKB> wallet transfer --from-account ckt1qyqg6cnaankwgwvh0gaq49uptd3aawhl9p6qpg5cus --to-address ckt1qyq0g9p6nxf5cdy38fm35zech5f90jl5aueqnsxch5 --capacity 10000 --max-tx-fee 0.00001 -Password: +Password: 0x1b66aafaaba5ce34de494f60374ef78e8f536bb3af9cab4fa63c0f29374c3f89 ``` + ```mdx-code-block ``` ### 5. Verify Balance + ```mdx-code-block ``` + ```bash wallet get-capacity --address "new account's address" ``` + ```mdx-code-block ``` + ```bash CKB> wallet get-capacity --address ckt1qyq0g9p6nxf5cdy38fm35zech5f90jl5aueqnsxch5 total: 10000.0 (CKB) ``` + ```mdx-code-block ``` + The transfer is successful! --- @@ -528,16 +598,20 @@ When the development blockchain configuration is generated with `ckb init --chai Genesis Issued Cell #1 - Private Key0xd00c06bfd800d27397002dca6fb0993d5ba6399b4238b2f29ee9deb97593d2bc + Private Key + 0xd00c06bfd800d27397002dca6fb0993d5ba6399b4238b2f29ee9deb97593d2bc - Lock Arg0xc8328aabcd9b9e8e64fbc566c4385c3bdeb219d7 + Lock Arg + 0xc8328aabcd9b9e8e64fbc566c4385c3bdeb219d7 - Testnet Addressckt1qyqvsv5240xeh85wvnau2eky8pwrhh4jr8ts8vyj37 + Testnet Address + ckt1qyqvsv5240xeh85wvnau2eky8pwrhh4jr8ts8vyj37 - Capcity20,000,000,000 CKBytes + Capcity + 20,000,000,000 CKBytes @@ -546,16 +620,20 @@ When the development blockchain configuration is generated with `ckb init --chai Genesis Issued Cell #2 - Private Key0x63d86723e08f0f813a36ce6aa123bb2289d90680ae1e99d4de8cdb334553f24d + Private Key + 0x63d86723e08f0f813a36ce6aa123bb2289d90680ae1e99d4de8cdb334553f24d - Lock Arg0x470dcdc5e44064909650113a274b3b36aecb6dc7 + Lock Arg + 0x470dcdc5e44064909650113a274b3b36aecb6dc7 - Testnet Addressckt1qyqywrwdchjyqeysjegpzw38fvandtktdhrs0zaxl4 + Testnet Address + ckt1qyqywrwdchjyqeysjegpzw38fvandtktdhrs0zaxl4 - Capcity5,198,735,037 CKBytes + Capcity + 5,198,735,037 CKBytes @@ -571,21 +649,25 @@ echo 0x63d86723e08f0f813a36ce6aa123bb2289d90680ae1e99d4de8cdb334553f24d > pk2 ### 2. Import Private Keys Import the private key files using `ckb-cli`: + ```mdx-code-block ``` + ```bash CKB> account import --privkey-path pk1 CKB> account import --privkey-path pk2 ``` + ```mdx-code-block ``` + ```bash $ ckb-cli account import --privkey-path pk1 -Password: +Password: address: mainnet: ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqvgswj39m3rs0qp2a9r9rmqamxtkntcysq007jd8 testnet: ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqvgswj39m3rs0qp2a9r9rmqamxtkntcysqpa4a8l @@ -594,6 +676,7 @@ address(deprecated): testnet: ckt1qyqg3qa9zthz8q7qz462x28kpmkvhdxhsfqq0cjrxd lock_arg: 0x8883a512ee2383c01574a328f60eeccbb4d78240 ``` + ```mdx-code-block diff --git a/website/docs/node/run-mainnet-node.mdx b/website/docs/node/run-mainnet-node.mdx index b55affa97..e2a13330d 100644 --- a/website/docs/node/run-mainnet-node.mdx +++ b/website/docs/node/run-mainnet-node.mdx @@ -2,6 +2,7 @@ id: run-mainnet-node title: Run a Mainnet Node --- + import useBaseUrl from "@docusaurus/useBaseUrl"; import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; @@ -18,8 +19,7 @@ We will use **ckb_v0.115.0** for this guide. Please ensure you download the late ::: -Get the latest CKB binary from [Github releases](https://github.com/nervosnetwork/ckb/releases). - +Get the latest CKB binary from [Github releases](https://github.com/nervosnetwork/ckb/releases). ## Step 2: Navigate to CKB Directory @@ -29,16 +29,20 @@ Unzip the downloaded file to an easily accessible folder, e.g., C:\ckb for Windo ``` + ```bash cd /Users/(NAME)/Documents/ckb_v0.115.0-rc3_aarch64-apple-darwin-portable/ckb ``` + ```mdx-code-block ``` + ```bash cd C:/ckb_v0.115.0_x86_64-pc-windows-msvc ``` + ```mdx-code-block @@ -50,18 +54,22 @@ Unzip the downloaded file to an easily accessible folder, e.g., C:\ckb for Windo ``` + ```bash ckb --version ckb-cli --version ``` + ```mdx-code-block ``` + ```bash ckb 0.115.0 (d845cbf 2024-04-01) ckb-cli 1.8.0-rc1 (cf4159b 2024-03-28) ``` + ```mdx-code-block @@ -79,8 +87,8 @@ Unzip the downloaded file to an easily accessible folder, e.g., C:\ckb for Windo ckb run ``` -By following these steps, you've successfully started a CKB node connected to the mainnet. This node will participate in the network, contributing to its security and robustness. +By following these steps, you've successfully started a CKB node connected to the mainnet. This node will participate in the network, contributing to its security and robustness. ## Track Your Node -Track your node using [CKB Node Probe](https://nodes.ckb.dev/) and view the global distribution of active CKB nodes. \ No newline at end of file +Track your node using [CKB Node Probe](https://nodes.ckb.dev/) and view the global distribution of active CKB nodes. diff --git a/website/docs/node/run-public-rpc-node.mdx b/website/docs/node/run-public-rpc-node.mdx index 1eaa68097..a40117911 100644 --- a/website/docs/node/run-public-rpc-node.mdx +++ b/website/docs/node/run-public-rpc-node.mdx @@ -2,6 +2,7 @@ id: run-public-rpc-node title: Run a Public RPC Node --- + import useBaseUrl from "@docusaurus/useBaseUrl"; import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; @@ -60,6 +61,7 @@ This example retrieves the latest block's hash and number from the CKB node thro ``` + ```bash echo '{ "id": 2, @@ -73,30 +75,33 @@ http://192.168.1.100:80 ## Note that http://192.168.1.100:80 needs to be changed to your proxy IP. ``` + ```mdx-code-block ``` + ```json { - "jsonrpc": "2.0", - "result": { - "compact_target": "0x1d090fbe", - "dao": "0xba17553fab3db84154bc4aa9f09b2600e826a2b0df99010400ed51b4686b5808", - "epoch": "0x7080687001539", - "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "hash": "0x7a46e779a3fc2d5b55c82aad852e721b0097bf873927b9751409b1d185599ce4", - "nonce": "0xd265e70dfd205dbbed33b29294121856", - "number": "0x7037f2", - "parent_hash": "0x3d105fe9ec60f138baa6623abd16af70ba1be90ad23d1943bcaa55d5f14fcb6f", - "proposals_hash": "0x2581d1769886226a8c90ee99baf2d8696e24c7f6bb6751748ff8b4452f8006e5", - "timestamp": "0x1847a2bfad2", - "transactions_root": "0x28157a5962c4ae1d3e153b1d8d331e5fd3c158866287f5398ab7f7d38210dfb0", - "version": "0x0" - }, - "id": 2 + "jsonrpc": "2.0", + "result": { + "compact_target": "0x1d090fbe", + "dao": "0xba17553fab3db84154bc4aa9f09b2600e826a2b0df99010400ed51b4686b5808", + "epoch": "0x7080687001539", + "extra_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "hash": "0x7a46e779a3fc2d5b55c82aad852e721b0097bf873927b9751409b1d185599ce4", + "nonce": "0xd265e70dfd205dbbed33b29294121856", + "number": "0x7037f2", + "parent_hash": "0x3d105fe9ec60f138baa6623abd16af70ba1be90ad23d1943bcaa55d5f14fcb6f", + "proposals_hash": "0x2581d1769886226a8c90ee99baf2d8696e24c7f6bb6751748ff8b4452f8006e5", + "timestamp": "0x1847a2bfad2", + "transactions_root": "0x28157a5962c4ae1d3e153b1d8d331e5fd3c158866287f5398ab7f7d38210dfb0", + "version": "0x0" + }, + "id": 2 } ``` + ```mdx-code-block @@ -120,6 +125,7 @@ These methods can alter the node's network interactions significantly and should ``` + ```bash echo '{ "id": 2, @@ -129,13 +135,16 @@ echo '{ }' | tr -d '\n' | curl -H 'content-type: application/json' -d @- \ http://192.168.1.100:80 ``` + ```mdx-code-block ``` + ``` This method has been banned. ``` + ```mdx-code-block diff --git a/website/docs/node/run-testnet-node.mdx b/website/docs/node/run-testnet-node.mdx index 7140159c7..123aeaf16 100644 --- a/website/docs/node/run-testnet-node.mdx +++ b/website/docs/node/run-testnet-node.mdx @@ -2,6 +2,7 @@ id: run-testnet-node title: Run a Testnet Node --- + import useBaseUrl from "@docusaurus/useBaseUrl"; import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; @@ -20,7 +21,6 @@ We will use **ckb_v0.115.0** for this guide. Please ensure you download the late Get the latest CKB binary from [Github releases](https://github.com/nervosnetwork/ckb/releases). - ## Step 2: Navigate to CKB Directory Unzip the downloaded file to an easily accessible folder, e.g., C:\ckb for Windows, ~/Documents for Mac. Open your terminal/command line and navigate to your CKB directory using the following command: @@ -29,38 +29,47 @@ Unzip the downloaded file to an easily accessible folder, e.g., C:\ckb for Windo ``` + ```bash cd /Users/(NAME)/Documents/ckb_v0.115.0-rc3_aarch64-apple-darwin-portable/ckb ``` + ```mdx-code-block ``` + ```bash cd C:/ckb_v0.115.0_x86_64-pc-windows-msvc ``` + ```mdx-code-block ``` + ## Step 3: Verify versions ```mdx-code-block ``` + ```bash ckb --version ckb-cli --version ``` + ```mdx-code-block ``` + ```bash ckb 0.115.0 (d845cbf 2024-04-01) ckb-cli 1.8.0-rc1 (cf4159b 2024-03-28) ``` + ```mdx-code-block @@ -69,37 +78,41 @@ Unzip the downloaded file to an easily accessible folder, e.g., C:\ckb for Windo ## Step 4: Connect to Pudge Testnet Initialize your CKB node: + ```mdx-code-block ``` + ```bash ckb init --chain testnet ``` + ```mdx-code-block ``` + ```bash WARN: Mining feature is disabled because of lacking the block assembler config options. Initialized CKB directory in /PATH/0.115.0 create ckb.toml create ckb-miner.toml ``` + ```mdx-code-block ``` ## Step 5: Start the CKB Testnet Node - + ``` ckb run -``` +``` After these steps, your CKB Testnet node will be up and running, allowing you to experiment and develop with the Nervos blockchain. - ## Track Your Node Track your node using [CKB Node Probe](https://nodes.ckb.dev/) and view the global distribution of active CKB nodes. diff --git a/website/docs/script/ScriptHeaders.tsx b/website/docs/script/ScriptHeaders.tsx index d9064ae36..a09a3fb21 100644 --- a/website/docs/script/ScriptHeaders.tsx +++ b/website/docs/script/ScriptHeaders.tsx @@ -14,7 +14,10 @@ export const ScriptHeaders: ScriptHeadersType = { link: "/docs/tech-explanation/glossary#ckb-vm", }, { label: "Cell Model", link: "/docs/tech-explanation/cell-model" }, - { label: "Transaction", link: "/docs/tech-explanation/glossary#transaction" }, + { + label: "Transaction", + link: "/docs/tech-explanation/glossary#transaction", + }, ], tools: [
@@ -66,26 +69,26 @@ export const ScriptHeaders: ScriptHeadersType = { {" sample installtion steps for selected platforms are:"}
    -
  • - Debian / Ubuntu:{" "} - - wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo - ./llvm.sh 16 && rm llvm.sh - -
  • -
  • - Fedora 39+: sudo dnf -y install clang -
  • -
  • - Archlinux: sudo pacman --noconfirm -Syu clang -
  • -
  • - macOS: brew install llvm@16 -
  • -
  • - Windows(with [Scoop](scoop install llvm yasm)):{" "} - scoop install llvm yasm -
  • +
  • + Debian / Ubuntu:{" "} + + wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo + ./llvm.sh 16 && rm llvm.sh + +
  • +
  • + Fedora 39+: sudo dnf -y install clang +
  • +
  • + Archlinux: sudo pacman --noconfirm -Syu clang +
  • +
  • + macOS: brew install llvm@16 +
  • +
  • + Windows(with [Scoop](scoop install llvm yasm)):{" "} + scoop install llvm yasm +
,
diff --git a/website/docs/script/_deploy-script.mdx b/website/docs/script/_deploy-script.mdx index 7990a7f1c..bf96004d5 100644 --- a/website/docs/script/_deploy-script.mdx +++ b/website/docs/script/_deploy-script.mdx @@ -2,4 +2,5 @@ id: deploy-script title: Deploy Script (Coming soon...) --- + # Coming soon... diff --git a/website/docs/script/_dynamic-linking.mdx b/website/docs/script/_dynamic-linking.mdx index f2eee161c..7ae42953d 100644 --- a/website/docs/script/_dynamic-linking.mdx +++ b/website/docs/script/_dynamic-linking.mdx @@ -2,4 +2,5 @@ id: dynamic-linking-script title: Use Dynamic Linking in Script (Coming soon...) --- + # Coming soon... diff --git a/website/docs/script/_script-in-js.mdx b/website/docs/script/_script-in-js.mdx index ab9e4ea37..42cd17f8e 100644 --- a/website/docs/script/_script-in-js.mdx +++ b/website/docs/script/_script-in-js.mdx @@ -2,4 +2,5 @@ id: script-in-js title: Run Script on Top of JS runtime (Coming soon...) --- + # Coming soon... diff --git a/website/docs/script/_simple-payment-channel.mdx b/website/docs/script/_simple-payment-channel.mdx index 1e94c01ce..dad921c06 100644 --- a/website/docs/script/_simple-payment-channel.mdx +++ b/website/docs/script/_simple-payment-channel.mdx @@ -2,4 +2,5 @@ id: simple-payment-channel-script title: Write a simple Payment Channel Script (Coming soon...) --- + # Coming soon... diff --git a/website/docs/script/a-minimal-script.mdx b/website/docs/script/a-minimal-script.mdx index ce8bdb45b..9c8216302 100644 --- a/website/docs/script/a-minimal-script.mdx +++ b/website/docs/script/a-minimal-script.mdx @@ -2,8 +2,9 @@ id: minimal-script title: "Tutorial: A Minimal Script" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; import ScriptHeaders from "./ScriptHeaders.tsx"; import TutorialHeader from "@components/TutorialHeader"; @@ -33,9 +34,9 @@ Despite its utility, the `always-success` Script is not very interesting due to Here we will start with a more interesting idea: -> Personally I dislike carrot. I do know that carrot is great from a nutritional point of view, but I still want to avoid it due to the taste. Now what if I want to set a rule, that none of my Cells on CKB has data that begin with the word `carrot`? +> Personally I dislike carrot. I do know that carrot is great from a nutritional point of view, but I still want to avoid it due to the taste. Now what if I want to set a rule, that none of my Cells on CKB has data that begin with the word `carrot`? -Let’s write a Script code to ensure this. +Let’s write a Script code to ensure this. Below is a step-by-step guide, and you can also clone the full code example from the Github at [carrot-script](https://github.com/nervosnetwork/docs.nervos.org/tree/develop/examples/carrot-script). @@ -43,10 +44,10 @@ Below is a step-by-step guide, and you can also clone the full code example from The first step is to create a new Script project. We use [ckb-script-templates](https://github.com/cryptape/ckb-script-templates) for this purpose. You will need the following dependencies: -* `git`, `make`, `sed`, `bash`, `sha256sum` and others Unix utilities -* `Rust` with `riscv64` target installed: `rustup target add riscv64imac-unknown-none-elf` -* `Clang 16+` -* `cargo-generate`: You can install this via `cargo install cargo-generate` +- `git`, `make`, `sed`, `bash`, `sha256sum` and others Unix utilities +- `Rust` with `riscv64` target installed: `rustup target add riscv64imac-unknown-none-elf` +- `Clang 16+` +- `cargo-generate`: You can install this via `cargo install cargo-generate` If you got any problems for these dependencies, refer to [readme](https://github.com/cryptape/ckb-script-templates?tab=readme-ov-file#dependencies) for install details. @@ -58,14 +59,17 @@ Now let's run the command to generate a new Script project called `my-first-cont ``` + ```bash alias create-ckb-scripts="cargo generate gh:cryptape/ckb-script-templates workspace" create-ckb-scripts ``` + ```mdx-code-block ``` + ```bash ⚠️ Favorite `gh:cryptape/ckb-script-templates` not found in config, using it as a git repository: https://github.com/cryptape/ckb-script-templates.git 🤷 Project Name: my-first-contract-workspace @@ -76,6 +80,7 @@ create-ckb-scripts 🔧 Initializing a fresh Git repository ✨ Done! New project created /tmp/my-first-contract-workspace ``` + ```mdx-code-block @@ -89,14 +94,17 @@ Let’s create a new Script called `carrot`. ``` + ```bash cd my-first-contract-workspace make generate ``` + ```mdx-code-block ``` + ```bash 🤷 Project Name: carrot 🔧 Destination: /tmp/my-first-contract-workspace/contracts/carrot ... @@ -106,6 +114,7 @@ make generate 🔧 Initializing a fresh Git repository ✨ Done! New project created /tmp/my-first-contract-workspace/contracts/carrot ``` + ```mdx-code-block @@ -117,13 +126,16 @@ Our project is successfully setup! You can run `tree .` to show the project stru ``` + ```bash {5} tree . ``` + ```mdx-code-block ``` + ```bash . ├── Cargo.lock @@ -147,6 +159,7 @@ tree . 7 directories, 13 files ``` + ```mdx-code-block @@ -154,11 +167,9 @@ tree . Here's a little introduction: `contracts/carrot/src/main.rs` contains the source code of the carrot Script, while `tests/tests.rs` provides unit tests for our Scripts. We will introduce the tests after we write the Script. - - ### Use CKB Syscall with CKB-STD Library -To ensure the security of CKB Script, each Script has to run in an isolated environment that is totally separated from the main computer you are running CKB. This way it won’t be able to access data it doesn’t need, such as your private keys or passwords. +To ensure the security of CKB Script, each Script has to run in an isolated environment that is totally separated from the main computer you are running CKB. This way it won’t be able to access data it doesn’t need, such as your private keys or passwords. However, for a Script to be useful, there must be certain data it want to access, such as the Cell a Script guards, or a transaction a Script validates. CKB provides [syscalls](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0009-vm-syscalls/0009-vm-syscalls.md) to ensure this, syscalls are defined in RISC-V standard, they provide a way to access certain resources provided by the environment. In a normal situation, the environment here means the operating system, but in the case of CKB VM, the environment refers to the actual CKB process. With syscalls, a CKB Script can access the whole transaction containing itself, including inputs, outputs, witnesses, and deps. @@ -187,7 +198,7 @@ ckb_std::entry!(program_entry); #[cfg(not(test))] default_alloc!(); -pub fn program_entry() -> i8 { +pub fn program_entry() -> i8 { match carrot_forbidden() { Ok(_) => 0, Err(err) => err as i8, @@ -255,13 +266,13 @@ Several points worth explaining here: To load Cell data, we use `load_cell_data` syscall from `CKB-STD` library. the function takes two arguments, one is the index number, and one is source type flag that denoting the source of Cells to locate. Different source type and index number will point to different Cell. For example, `load_cell_data(0, Source::GroupOutput)` means load the first Cell from the output Cells group with the same running Script as current Script. You can check [rfc](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0046-syscalls-summary/0046-syscalls-summary.md#source) for more details. -The workflow of our Script goes like this: +The workflow of our Script goes like this: First, it loops through all output Cells in the transaction, load each Cell data and test if those bytes match the word `carrot`. If we found a match, the Script would return -1, denoting an error status, if no match is found, the Script exits with 0, meaning execution success. To perform the loop, the Script would keep an index variable, in each loop iteration, it would tries to make the syscall to fetch the Cell denoted by current index value, if the syscall returns CKB_INDEX_OUT_OF_BOUND, it means the Script has iterated through all the Cells, hence it just exits the loop, otherwise, the loop would continue, the Cell data is tested, then index variable is incremented for the next iteration. -Besides the main logic in `main.rs` file, we also write a `error.rs` to define our custom error code for the carrot Script. +Besides the main logic in `main.rs` file, we also write a `error.rs` to define our custom error code for the carrot Script. CKB defines some basic error code like: @@ -272,7 +283,7 @@ CKB defines some basic error code like: We define error code 5 to be the custom `CarrotAttack` error. So everytime the Script throws out error code 5, we know that means the Script have found a Cell data starts with the `carrot` word so it fails. -So that's all! This concludes your first useful CKB Script code! +So that's all! This concludes your first useful CKB Script code! In the next section, we will see how we can test and deploy it to CKB and run it. @@ -476,4 +487,4 @@ By following this tutorial this far, you have mastered how to write a basic Scri - script templates: [ckb-script-templates](https://github.com/cryptape/ckb-script-templates) - CKB transaction structure: [RFC-0022-transaction-structure](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0022-transaction-structure/0022-transaction-structure.md) - CKB data structure basics: [RFC-0019-data-structure](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0019-data-structures/0019-data-structures.md) -./ScriptHeaders.js + ./ScriptHeaders.js diff --git a/website/docs/script/common-script-error-code.mdx b/website/docs/script/common-script-error-code.mdx index 09320f65b..ffb5f7b7a 100644 --- a/website/docs/script/common-script-error-code.mdx +++ b/website/docs/script/common-script-error-code.mdx @@ -27,4 +27,10 @@ Molecule Error Codes from [CKB standard C library](https://github.com/nervosnetw Error codes from common scripts via [ckb-script-error-codes](https://nervosnetwork.github.io/ckb-script-error-codes/) - + diff --git a/website/docs/script/intro-to-script.mdx b/website/docs/script/intro-to-script.mdx index d1fa5248a..d71a85ade 100644 --- a/website/docs/script/intro-to-script.mdx +++ b/website/docs/script/intro-to-script.mdx @@ -8,6 +8,7 @@ title: "Intro to Script" A [Script](/docs/tech-explanation/glossary#script) in Nervos CKB is a binary executable that can be executed on-chain. It is Turing-complete and can perform arbitray logic to guard and protect your on-chain assets. You can think of it as smart contract. ## How a Script Work + When executing a Script, CKB takes the executables and runs them in a virtual machine environment called [CKB-VM](/docs/tech-explanation/ckb-vm). After the execution, if the program returns a code of 0, we consider the Script successful; any non-zero return codes will be considered Script failures. When you submit a transaction to CKB, it executes all the Scripts from the transaction to ensure that each Script succeeds. If any Script fails, the transaction will not be included on-chain. @@ -21,7 +22,7 @@ A Script can be one of two types: - Lock Script - Used to control ownership and access to a Cell. - Type Script - Used to control how a Cell is used in a transaction. -In most cases, Lock Script works the same with Type Script. The difference is that, only the Lock Script from the input Cells will be exeuted in the transaction, while the Type Script from both the input Cells and output Cells will be executed in the transaction. +In most cases, Lock Script works the same with Type Script. The difference is that, only the Lock Script from the input Cells will be exeuted in the transaction, while the Type Script from both the input Cells and output Cells will be executed in the transaction. This difference has lead to the different usecases of Lock Script and Type Script as we have mentioned above. Lock Script is often used to control owener ship of a Cell while Type Script defines what kinds of changes of a Cell is valid for the transaction. @@ -42,10 +43,3 @@ The `code_hash` serves to identify a Script code, allowing the `CKB-VM` to load A Script also includes the `args` part, which differentiates one Script from another using the same Script code. The `args` can provide additional arguments for a CKB Script; for example, while multiple users might utilize the same default Lock Script code, each user can have their own public key hash stored in `args`. This setup allows each user to have a unique Lock Script while sharing the same Lock Script code. `hash_type` indicates the method CKB-VM uses to locate the Script code for a Script. Possible values include `type`, `data`, `data1`, and `data2`. Each specifies a different way of referencing the required Script code. - - - - - - - diff --git a/website/docs/script/js-script.mdx b/website/docs/script/js-script.mdx index b2a9c2618..cd61ccb17 100644 --- a/website/docs/script/js-script.mdx +++ b/website/docs/script/js-script.mdx @@ -2,8 +2,9 @@ id: js-script title: "Tutorial: Run JS on CKB" --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; import ScriptHeaders from "./ScriptHeaders.tsx"; import TutorialHeader from "@components/TutorialHeader"; @@ -65,7 +66,7 @@ cargo install --git https://github.com/nervosnetwork/ckb-standalone-debuggger ck ### Quick Test with CKB-Debugger -Now let's run the `ckb-js-vm` with some JS test codes. +Now let's run the `ckb-js-vm` with some JS test codes. Make sure you are in the root of the `ckb-vm-js` project folder: @@ -73,13 +74,16 @@ Make sure you are in the root of the `ckb-vm-js` project folder: ``` + ```bash ckb-debugger --read-file tests/examples/hello.js --bin build/ckb-js-vm -- -r ``` + ```mdx-code-block ``` + ```bash Run from file, local access enabled. For testing only. hello, world @@ -87,6 +91,7 @@ Run result: 0 Total cycles consumed: 30081070(2.9m) Transfer cycles: 125121(122.2k), running cycles: 2955949(2.8m) ``` + ```mdx-code-block @@ -94,7 +99,7 @@ Transfer cycles: 125121(122.2k), running cycles: 2955949(2.8m) With the `-r` option, `ckb-js-vm` will read a local JS file via CKB-Debugger. This function is intended for testing purposes and does not function in a production environment. However, we can see the -running output, which includes a `hello, world` message. The run result is 0, indicating that the `hello.js` Script executes successfully. +running output, which includes a `hello, world` message. The run result is 0, indicating that the `hello.js` Script executes successfully. Also, you can see how many `cycles`(the overhead required to execute a Script) are needed to run the JS Script in the output as well. ## Integrate ckb-js-vm @@ -105,10 +110,10 @@ understanding. The first step is to create a new Script project. We use [ckb-script-templates](https://github.com/cryptape/ckb-script-templates) for this purpose. You will need the following dependencies: -* `git`, `make`, `sed`, `bash`, `sha256sum` and others Unix utilities -* `Rust` with `riscv64` target installed: `rustup target add riscv64imac-unknown-none-elf` -* `Clang 16+` -* `cargo-generate`: You can install this via `cargo install cargo-generate` +- `git`, `make`, `sed`, `bash`, `sha256sum` and others Unix utilities +- `Rust` with `riscv64` target installed: `rustup target add riscv64imac-unknown-none-elf` +- `Clang 16+` +- `cargo-generate`: You can install this via `cargo install cargo-generate` If you encounter any problems with these dependencies, refer to the [ReadMe](https://github.com/cryptape/ckb-script-templates?tab=readme-ov-file#dependencies) for installation details. @@ -120,14 +125,17 @@ Now let's run the command to generate a new Script project called `my-first-scri ``` + ```bash alias create-ckb-scripts="cargo generate gh:cryptape/ckb-script-templates workspace" create-ckb-scripts ``` + ```mdx-code-block ``` + ```bash ⚠️ Favorite `gh:cryptape/ckb-script-templates` not found in config, using it as a git repository: https://github.com/cryptape/ckb-script-templates.git 🤷 Project Name: my-first-script-workspace @@ -138,6 +146,7 @@ create-ckb-scripts 🔧 Initializing a fresh Git repository ✨ Done! New project created /tmp/my-first-script-workspace ``` + ```mdx-code-block @@ -151,14 +160,17 @@ Let’s create a new Script called `run-js`. ``` + ```bash cd my-first-script-workspace make generate ``` + ```mdx-code-block ``` + ```bash 🤷 Project Name: run-js 🔧 Destination: /tmp/my-first-script-workspace/contracts/run-js ... @@ -168,6 +180,7 @@ make generate 🔧 Initializing a fresh Git repository ✨ Done! New project created /tmp/my-first-script-workspace/contracts/run-js ``` + ```mdx-code-block @@ -191,7 +204,7 @@ Copy the `ckb-js-vm` binary we built before into the `deps` folder. When you're ... ``` -Everything looks good now! +Everything looks good now! ### Integrate via Script @@ -204,6 +217,7 @@ hash_type: args: ``` + :::note 2 bytes ckb-js-vm args are reserved for further use ::: @@ -227,7 +241,7 @@ console.log("hello, ckb-js-script!"); #### Compile the `hello.js` into binary with CKB-Debugger ```sh -ckb-debugger --read-file js/hello.js --bin deps/ckb-js-vm -- -c | awk '/Run result: 0/{exit} {print}' | xxd -r -p > js/build/hello.bc +ckb-debugger --read-file js/hello.js --bin deps/ckb-js-vm -- -c | awk '/Run result: 0/{exit} {print}' | xxd -r -p > js/build/hello.bc ``` #### Write tests for the `hello.js` Script @@ -405,19 +419,23 @@ alternative command: ``` + ```sh cargo test -- --nocapture ``` + ```mdx-code-block ``` + ```sh running 1 test [contract debug] hello, ckb-js-script! consume cycles: 3070458 test tests::hello_script ... ok ``` + ```mdx-code-block @@ -432,15 +450,12 @@ We can try a different JavaScript example. Let's write a `fib.js` in the `js` fo ```js title='my-first-script-workspace/js/fib.js' console.log("testing fib"); function fib(n) { - if (n <= 0) - return 0; - else if (n == 1) - return 1; - else - return fib(n - 1) + fib(n - 2); -}; + if (n <= 0) return 0; + else if (n == 1) return 1; + else return fib(n - 1) + fib(n - 2); +} var value = fib(10); -console.assert(value == 55, 'fib(10) = 55'); +console.assert(value == 55, "fib(10) = 55"); ``` #### Compile the `fib.js` into Binary with CKB-Debugger @@ -541,7 +556,7 @@ fn fib_script() { } ``` -#### Run the test for `fib.js` smart contract +#### Run the test for `fib.js` smart contract ```sh make build @@ -607,6 +622,7 @@ pub fn program_entry() -> i8 { 0 } ``` + The most important code in the Script is the usage of `ckb_std` library to perform the `spawn` syscall to call the `ckb-js-vm`: @@ -643,117 +659,120 @@ const CKB_INDEX_OUT_OF_BOUND = 1; const ERROR_AMOUNT = -52; function assert(cond, obj1) { - if (!cond) { - throw Error(obj1); - } + if (!cond) { + throw Error(obj1); + } } function compare_array(a, b) { - if (a.byteLength != b.byteLength) { - return false; - } - for (let i = 0; i < a.byteLength; i++) { - if (a[i] != b[i]) { - return false; - } + if (a.byteLength != b.byteLength) { + return false; + } + for (let i = 0; i < a.byteLength; i++) { + if (a[i] != b[i]) { + return false; } - return true; + } + return true; } function unpack_script(buf) { - let script = new Uint32Array(buf); - let raw_data = new Uint8Array(buf); - - let full_size = script[0]; - assert(full_size == buf.byteLength, 'full_size == buf.byteLength'); - let code_hash_offset = script[1]; - let code_hash = buf.slice(code_hash_offset, code_hash_offset + 32); - let hash_type_offset = script[2]; - let hash_type = raw_data[hash_type_offset]; - let args_offset = script[3]; - let args = buf.slice(args_offset + 4); - return {'code_hash': code_hash, 'hash_type': hash_type, 'args': args}; + let script = new Uint32Array(buf); + let raw_data = new Uint8Array(buf); + + let full_size = script[0]; + assert(full_size == buf.byteLength, "full_size == buf.byteLength"); + let code_hash_offset = script[1]; + let code_hash = buf.slice(code_hash_offset, code_hash_offset + 32); + let hash_type_offset = script[2]; + let hash_type = raw_data[hash_type_offset]; + let args_offset = script[3]; + let args = buf.slice(args_offset + 4); + return { code_hash: code_hash, hash_type: hash_type, args: args }; } function* iterate_field(source, field) { - let index = 0; - while (true) { - try { - let ret = ckb.load_cell_by_field(index, source, field); - yield ret; - index++; - } catch (e) { - if (e.error_code == CKB_INDEX_OUT_OF_BOUND) { - break; - } else { - throw e; - } - } + let index = 0; + while (true) { + try { + let ret = ckb.load_cell_by_field(index, source, field); + yield ret; + index++; + } catch (e) { + if (e.error_code == CKB_INDEX_OUT_OF_BOUND) { + break; + } else { + throw e; + } } + } } function* iterate_cell_data(source) { - let index = 0; - while (true) { - try { - let ret = ckb.load_cell_data(index, source); - yield ret; - index++; - } catch (e) { - if (e.error_code == CKB_INDEX_OUT_OF_BOUND) { - break; - } else { - throw e; - } - } + let index = 0; + while (true) { + try { + let ret = ckb.load_cell_data(index, source); + yield ret; + index++; + } catch (e) { + if (e.error_code == CKB_INDEX_OUT_OF_BOUND) { + break; + } else { + throw e; + } } + } } function main() { - console.log('simple UDT ...'); - let buf = ckb.load_script(); - let script = unpack_script(buf); - let owner_mode = false; - // ckb-js-vm has leading 35 bytes args - let real_args = script.args.slice(35); - for (let lock_hash of iterate_field(ckb.SOURCE_INPUT, ckb.CELL_FIELD_LOCK_HASH)) { - if (compare_array(lock_hash, real_args)) { - owner_mode = true; - } + console.log("simple UDT ..."); + let buf = ckb.load_script(); + let script = unpack_script(buf); + let owner_mode = false; + // ckb-js-vm has leading 35 bytes args + let real_args = script.args.slice(35); + for (let lock_hash of iterate_field( + ckb.SOURCE_INPUT, + ckb.CELL_FIELD_LOCK_HASH + )) { + if (compare_array(lock_hash, real_args)) { + owner_mode = true; } - if (owner_mode) { - return 0; - } - let input_amount = 0n; - - for (let data of iterate_cell_data(ckb.SOURCE_GROUP_INPUT)) { - if (data.byteLength != 16) { - throw `Invalid data length: ${data.byteLength}`; - } - let n = new BigUint64Array(data); - let current_amount = n[0] | (n[1] << 64n); - input_amount += current_amount; - } - let output_amount = 0n; - for (let data of iterate_cell_data(ckb.SOURCE_GROUP_OUTPUT)) { - if (data.byteLength != 16) { - throw `Invalid data length: ${data.byteLength}`; - } - let n = new BigUint64Array(data); - let current_amount = n[0] | (n[1] << 64n); - output_amount += current_amount; + } + if (owner_mode) { + return 0; + } + let input_amount = 0n; + + for (let data of iterate_cell_data(ckb.SOURCE_GROUP_INPUT)) { + if (data.byteLength != 16) { + throw `Invalid data length: ${data.byteLength}`; } - console.log(`verifying amount: ${input_amount} and ${output_amount}`); - if (input_amount < output_amount) { - return ERROR_AMOUNT; + let n = new BigUint64Array(data); + let current_amount = n[0] | (n[1] << 64n); + input_amount += current_amount; + } + let output_amount = 0n; + for (let data of iterate_cell_data(ckb.SOURCE_GROUP_OUTPUT)) { + if (data.byteLength != 16) { + throw `Invalid data length: ${data.byteLength}`; } - console.log('Simple UDT quit successfully'); - return 0; + let n = new BigUint64Array(data); + let current_amount = n[0] | (n[1] << 64n); + output_amount += current_amount; + } + console.log(`verifying amount: ${input_amount} and ${output_amount}`); + if (input_amount < output_amount) { + return ERROR_AMOUNT; + } + console.log("Simple UDT quit successfully"); + return 0; } let exit_code = main(); if (exit_code != 0) { - ckb.exit(exit_code); + ckb.exit(exit_code); } ``` @@ -872,6 +891,7 @@ fn sudt_script() { println!("consume cycles: {}", cycles); } ``` + Some explanation for this test: Just like the previous tests, we deploy all the Scripts we need, including `ckb-js-vm`, `run-js`, @@ -925,6 +945,7 @@ assemble the transaction for submission on-chain: .expect("pass verification"); println!("consume cycles: {}", cycles); ``` + #### Run test for `sudt.js` ```sh @@ -945,6 +966,7 @@ test tests::sudt_script ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out; finished in 0.04s ``` + --- ## Congratulations! @@ -961,7 +983,7 @@ By following this tutorial so far, you have mastered how to write Scripts that i - Full source code of this tutorial: [ckb-js-script](https://github.com/nervosnetwork/docs.nervos.org/tree/develop/examples/ckb-js-script) -- More about `ckb-js-vm`: [ckb-js-vm docs](https://nervosnetwork/ckb-js-vm/blob/main/docs) +- More about `ckb-js-vm`: [ckb-js-vm docs](https://nervosnetwork/ckb-js-vm/blob/main/docs) - CKB syscalls specs: [RFC-0009](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0009-vm-syscalls/0009-vm-syscalls.md) - Script templates: [ckb-script-templates](https://github.com/cryptape/ckb-script-templates) - CKB transaction structure: [RFC-0022-transaction-structure](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0022-transaction-structure/0022-transaction-structure.md) diff --git a/website/docs/script/program-language-for-script.mdx b/website/docs/script/program-language-for-script.mdx index 8ae93d05f..507929af9 100644 --- a/website/docs/script/program-language-for-script.mdx +++ b/website/docs/script/program-language-for-script.mdx @@ -18,8 +18,9 @@ We will use `Rust` as the programming language across the tutorials on this webs ::: ## Rust + f -Rust can easily compile the source code to a RISC-V target, allowing the code to be executed on CKB-VM. +Rust can easily compile the source code to a RISC-V target, allowing the code to be executed on CKB-VM. We have also built some useful Rust libraries and template tools to help developers build Script: @@ -29,7 +30,7 @@ We have also built some useful Rust libraries and template tools to help develop ## C -You can also use [C](https://en.wikipedia.org/wiki/C_(programming_language)) language and [GCC](https://gcc.gnu.org/) to write and compile CKB Scripts to RISC-V binaries. +You can also use [C]() language and [GCC](https://gcc.gnu.org/) to write and compile CKB Scripts to RISC-V binaries. Some of our developers have used this way to build Scripts like [sUDT](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0025-simple-udt/0025-simple-udt.md) and [xUDT](https://github.com/nervosnetwork/rfcs/pull/428). You can check [ckb-production-scripts](https://github.com/nervosnetwork/ckb-production-scripts/tree/master/c) for reference. diff --git a/website/docs/tech-explanation/cell-model.md b/website/docs/tech-explanation/cell-model.md index 21a99384b..d36085c18 100644 --- a/website/docs/tech-explanation/cell-model.md +++ b/website/docs/tech-explanation/cell-model.md @@ -7,7 +7,6 @@ title: Cell Model > This approach maintains Bitcoin's simplicity and consistency. > In CKB, all states are stored in Cells, computation is done off-chain, and nodes handle all verification. - ## Cell A **Cell** represents the fundamental data storage unit in Nervos. It can encompass various data types, such as CKBytes, tokens, JavaScript code, or serialized data like JSON strings, offering extensive flexibility in data storage. @@ -22,12 +21,11 @@ The collection of Cells constitutes the **state** of CKB. A state verified and h CKB State - ## Cell Model Inspired by Bitcoin's UTXO model, Cell Model defines the behavior of individual Cells within Nervos, as well as the process for updating their contained data. -Cells are immutable. No changes can be made once the Cells have been added on-chain. Updating data within a Cell requires a process called **Consumption**. This involves consuming the existing Cell, extracting and updating the data, followed by creating a new Cell with the updated data, which is then added on-chain. +Cells are immutable. No changes can be made once the Cells have been added on-chain. Updating data within a Cell requires a process called **Consumption**. This involves consuming the existing Cell, extracting and updating the data, followed by creating a new Cell with the updated data, which is then added on-chain. Each Cell can be consumed only once. A non-consumed Cell is a **Live Cell**. A consumed Cell is a **Dead Cell**. Once a Cell is dead, it can no longer be used. @@ -43,7 +41,7 @@ This ownership structure also defines the responsibility for asset upkeep. As as ## Flexible Transaction Fee Coverage -When transferring tokens, typically, those who initiate the transaction or execute smart contracts must cover the transaction fees. This poses a usability challenge in adoption. +When transferring tokens, typically, those who initiate the transaction or execute smart contracts must cover the transaction fees. This poses a usability challenge in adoption. Cell Model provides the flexibility by allowing any party to cover the transaction fees, eliminating the need for the sender to possess CKBytes (transaction fee in Nervos). Instead, either the receiver or a third-party can cover the fee, significantly enhancing user experience. @@ -59,6 +57,6 @@ In Cell Model, smart contract execution is parallel. Each transaction runs indep Transactions are highly flexible and effective in Cell Model. Multiple smart contract operations can be batched into a single transaction, thereby minimizing transactions overhead and processing fees. -*** +--- For more details and the rationale behind the Cell Model, refer to [this post](https://medium.com/nervosnetwork/https-medium-com-nervosnetwork-cell-model-7323fca57571). diff --git a/website/docs/tech-explanation/ckb-vm.md b/website/docs/tech-explanation/ckb-vm.md index d0aa47610..b1c6e1919 100644 --- a/website/docs/tech-explanation/ckb-vm.md +++ b/website/docs/tech-explanation/ckb-vm.md @@ -17,6 +17,6 @@ Any programming language that can target RISC-V can be used natively for develop Nervos CKB offers native SDKs in several mainstream programming languages, such as JavaScript, Rust, Go, Java, and Ruby. -*** +--- For more information on CKB-VM, please refer to the [RFC CKB-VM](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0003-ckb-vm/0003-ckb-vm.md). diff --git a/website/docs/tech-explanation/consensus.md b/website/docs/tech-explanation/consensus.md index 69eac4966..b914b49ef 100644 --- a/website/docs/tech-explanation/consensus.md +++ b/website/docs/tech-explanation/consensus.md @@ -17,7 +17,7 @@ To achieve Nervos' objectives, a consensus mechanism without compromise is imper ## NC-Max Consensus Algorithm -Bitcoin’s Nakamoto Consensus (NC) is the PoW algorithm that has successfully defended Bitcoin from countless attacks for over a decade. The technology is well understood and proven through the test of time. +Bitcoin’s Nakamoto Consensus (NC) is the PoW algorithm that has successfully defended Bitcoin from countless attacks for over a decade. The technology is well understood and proven through the test of time. Nervos’ NC-MAX consensus is built on Nakamoto Consensus, while addressing NC‘s limitations without compromising security. It offers robust resistance against transaction withholding attacks, while showcasing its superior performance, maximizing network throughput and considerably reducing transaction confirmation latency compared to traditional NC implementations. @@ -33,7 +33,7 @@ Shorter block intervals in blockchain networks can increase transaction throughp Selfish mining practices undermine network security by allowing miners to gain a disproportionate share of rewards while contributing less hash power. NC-MAX confronts this challenge by accurately measuring the network's computing power and mitigating known selfish mining attacks. By considering both external and internal factors, NC-MAX makes selfish mining strategies unprofitable, enhancing overall network security. -*** +--- For a comprehensive understanding of NC-MAX, refer to [NC-Max: Breaking the Security-Performance Tradeoff in Nakamoto Consensus](https://eprint.iacr.org/2020/1101) and [RFC Consensus Protocol](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0020-ckb-consensus-protocol/0020-ckb-consensus-protocol.md). @@ -43,7 +43,6 @@ Bitcoin’s Nakamoto Consensus utilizes the widely-used SHA256 hash function. An To address this vulnerability, Nervos developed Eaglesong, a novel cryptographic hash function tailored for its ecosystem. Eaglesong offers a balance of novelty, simplicity, and security, ensuring easy implementation in both software and hardware. This innovation enhances Nervos' security and ensures complete hardware sovereignty, providing a secure alternative to SHA256. -*** +--- For more information on Eaglesong, refer to [RFC Eaglesong](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0010-eaglesong/0010-eaglesong.md). - diff --git a/website/docs/tech-explanation/economics.md b/website/docs/tech-explanation/economics.md index 01ea7eccf..1c71909e8 100644 --- a/website/docs/tech-explanation/economics.md +++ b/website/docs/tech-explanation/economics.md @@ -45,7 +45,7 @@ Base Issuance follows a transparent, predictable inflation schedule, [halving](h ## Secondary Issuance -After Base Issuance, relying solely on transaction fees may not suffice for miner incentives or data persistence. Secondary Issuance, with an small annual fixed inflation of 1.344 billion CKBytes, addresses these concerns. +After Base Issuance, relying solely on transaction fees may not suffice for miner incentives or data persistence. Secondary Issuance, with an small annual fixed inflation of 1.344 billion CKBytes, addresses these concerns. Unlike Base Issuance, Secondary Issuance only targets at users occupying Nervos space or holding CKBytes outside Nervos DAO. Secondary Issuance are distributed to: @@ -57,6 +57,6 @@ Unlike Base Issuance, Secondary Issuance only targets at users occupying Nervos CKBytes holders can earn interest by locking tokens in Nervos DAO, similar to staking. Interest accrues proportionally to Secondary Issuance, offsetting the long-term inflationary effects of the latter, thus maintaining value. Users occupying space in Nervos have their CKBytes locked, making them ineligible to be placed in Nervos DAO. Once the space-occupying Cells are consumed and the CKBytes are released, they can be placed in Nervos DAO. This mechanism incentivizes the removal of unnecessary data, ensuring long-term manageability of the blockchain. -*** +--- For more information, refer to the [RFC Crypto-Economics of the Nervos Common Knowledge Base](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0015-ckb-cryptoeconomics/0015-ckb-cryptoeconomics.md). diff --git a/website/docs/tech-explanation/glossary.md b/website/docs/tech-explanation/glossary.md index ff89713ce..9360de46a 100644 --- a/website/docs/tech-explanation/glossary.md +++ b/website/docs/tech-explanation/glossary.md @@ -17,33 +17,39 @@ import Link from "@docusaurus/Link"; ## General Glossary - ### Account + A kind of basic object in distributed ledger used to keep the balance and other information of users. --- ### Address + A label consists of string of letters and numbers that anonymously represents user's identity on chain. Crypto assets can be sent to and/or from addresses. #### Synonyms + - [Payment Address](#payment-address) --- ### Asset + A piece of data that has value or that represents an entity having value. #### Synonyms + - [Digital Asset](#digital-asset) - [Token](#token) --- ### Block + A grouping of transactions, marked with a timestamp, and a fingerprint of the previous block. The block header is hashed to produce a proof of work, thereby validating the transactions. Valid blocks are added to the main blockchain by network consensus. #### See Also + - [Blockchain](#blockchain) - [Confirmation](#confirmation) - [Transaction](#transaction) @@ -51,12 +57,15 @@ A grouping of transactions, marked with a timestamp, and a fingerprint of the pr --- ### Block Height + Block height is the total number of blocks that have been confirmed on the blockchain, also used to identify a unique block when specifying a particular block height, as there is always an exact block at any block height. #### Synonyms + - [Height](#height) #### See Also + - [Block](#block) - [Blockchain](#blockchain) - [Confirmation](#confirmation) @@ -64,28 +73,34 @@ Block height is the total number of blocks that have been confirmed on the block --- ### Block Interval + Also known as [Block Time](#block-time). Block interval is the length of time it takes to create a new block in a cryptocurrency blockchain. Block interval is the measure of the time it takes the miners or validators within a network to verify transactions within one block and produce a new block in that blockchain. The block interval is variable on Nervos blockchain. The block interval on the Bitcoin blockchain is approximately every 10 minutes. The block interval on Nervos is variable, but is usually under 10 seconds. #### Synonyms + - [Block Time](#block-time) #### See Also + - [Block](#block) - [Blockchain](#blockchain) --- ### Block Propagation -The process of synchronizing a new block to the majority of full nodes in the network. Block propagation is a well-known bottleneck that prevents Bitcoin from scaling. + +The process of synchronizing a new block to the majority of full nodes in the network. Block propagation is a well-known bottleneck that prevents Bitcoin from scaling. Block propagation time is an average time that is needed for the new block to reach the majority of nodes in the network. Long block propagation delay reduces the node's resistance against 51% attacks. #### Synonyms + - [Propagation](#propagation) #### See Also + - [Block](#block) - [Broadcast](#broadcast) - [Full Node](#full-node) @@ -93,35 +108,42 @@ Block propagation time is an average time that is needed for the new block to re --- ### Block Reward -The amount of cryptocurrency credited to a miner's account after the miner successfully adds a block of transactions to the blockchain. + +The amount of cryptocurrency credited to a miner's account after the miner successfully adds a block of transactions to the blockchain. In Nervos CKB, block rewards are the CKBytes credited to a miner's account after a block is successfully added to CKB by the miner. #### See Also + - [Block](#block) - [Block Subsidy](#block-subsidy) --- ### Block Time + Alternatively referred to as [Block Interval](#block-interval). #### Synonyms + - [Block Interval](#block-interval) --- ### Blockchain -A data structure maintaining a growing list of records, organized as a chain of blocks. Each block, apart from the first one, is cryptographically linked to the previous block, thus creating a chain-like structure. + +A data structure maintaining a growing list of records, organized as a chain of blocks. Each block, apart from the first one, is cryptographically linked to the previous block, thus creating a chain-like structure. The cryptographic link ensures any party with the last block can verify that none of the historical data is modified after the creation of this block. #### See Also + - [Block](#block) --- ### BLS Signature + A cryptographic signature scheme for signing and verification. BLS is short for Boneh–Lynn–Shacham. #### See Also @@ -131,21 +153,26 @@ A cryptographic signature scheme for signing and verification. BLS is short for --- ### Broadcast + Blocks are sent to all nodes in a blockchain network. #### See Also + - [Blockchain](#blockchain) - [Node](#node) --- ### Capacity + The maximum space (in bytes) that a Cell can occupy on the Nervos CKB. #### Synonyms + - [CKByte](#ckbyte) #### See Also + - [CKB](#ckb) - [Common Knowledge Base](#common-knowledge-base) - [Common Knowledge Byte](#common-knowledge-byte) @@ -154,14 +181,17 @@ The maximum space (in bytes) that a Cell can occupy on the Nervos CKB. --- ### Cell -All data on Nervos CKB is stored in Cells. Cells are the primary state units in CKB, within them users can include arbitrary states. + +All data on Nervos CKB is stored in Cells. Cells are the primary state units in CKB, within them users can include arbitrary states. A Cell has 4 fields: `capacity`, `data`, `type` and `lock`. #### Synonyms + - [Micro-State](#micro-state) #### See Also + - [Data](#data) - [Lock](#lock) - [Lock Script](#lock-script) @@ -174,11 +204,13 @@ A Cell has 4 fields: `capacity`, `data`, `type` and `lock`. --- ### Cell Model -A representation of how state is managed on Nervos CKB. The Cell Model is a more generic state model than either Bitcoin's UTXO or Ethereum's account model. + +A representation of how state is managed on Nervos CKB. The Cell Model is a more generic state model than either Bitcoin's UTXO or Ethereum's account model. The Cell Model is a new construction that combines many of the advantages of Ethereum's account model with the asset ownership and proof-based verification properties of Bitcoin's UTXO model. #### See Also + - [Lock Script](#lock-script) - [Type Script](#type-script) - [Cell Model](/docs/tech-explanation/cell-model) @@ -198,40 +230,48 @@ Censorship resistance in blockchain generally means that it is difficult for a m A shorthand name for blockchain. #### Synonyms + - [Blockchain](#blockchain) --- ### CKB + An abbreviation which can have different meanings depending on the context: - Common Knowledge Base - The layer 1 blockchain of the Nervos Network. - Common Knowledge Byte - The native token of the Nervos Common Knowledge Base. #### Synonyms + - [Common Knowledge Base](#common-knowledge-base) - [Common Knowledge Byte](#common-knowledge-byte) --- ### CKByte + A shorthand name for Common Knowledge Byte. CKByte is also sometimes shortened to CKB. Exchanges often use CKB as the ticker symbol. #### Synonyms + - [CKB](#ckb) - [Common Knowledge Byte](#common-knowledge-byte) #### Not To Be Confused With + - [Common Knowledge Base](#common-knowledge-base) --- ### CKB-VM + CKB VM is a crypto-agnostic virtual machine, a RISC-V instruction set based VM for executing both on-chain and off-chain code. #### See Also + - [RISC-V](#risc-v) - [Script](#script) - [Virtual Machine on Wikipedia](https://en.wikipedia.org/wiki/Virtual_machine) @@ -239,6 +279,7 @@ CKB VM is a crypto-agnostic virtual machine, a RISC-V instruction set based VM f --- ### Code Hash + A field in a Cell which contains a hash value that can refer to a specific piece of data, or a specific Cell referenced by Type ID. #### See Also @@ -249,9 +290,11 @@ A field in a Cell which contains a hash value that can refer to a specific piece --- ### Cold Storage + A method of securing funds by placing them in a cold wallet; a type of wallet that is never connected to the internet. #### See Also + - [Cold Wallet](#cold-wallet) - [Hardware Wallet](#hardware-wallet) - [Wallet](#wallet) @@ -259,45 +302,55 @@ A method of securing funds by placing them in a cold wallet; a type of wallet th --- ### Cold Wallet + A wallet that is used to secure assets offline. This wallet is permanently disconnected from the internet, and not vulnerable to attacks which rely on an active internet connection. #### See Also + - [Cold Storage](#cold-storage) - [Wallet](#wallet) --- ### Commit + Nervos CKB's consensus algorithm, [NC-Max](#nc-max) consensus, has two phases: **propose** and **commit**. Commit is the process of including a valid proposed transaction into a new block. --- ### Commit-Chain + A scheme that enables the off-chain processing of transactions by one or more operators with on-chain state update commitments that do not contain per-transaction data. --- ### Commit Reward + A reward paid to miners in CKBytes on inclusion of previously proposed transactions. --- ### Common Knowledge Base + A layer 1 proof of work blockchain that provides a foundation of decentralized trust for the Nervos Network. #### Synonyms + - [CKB](#ckb) - [Nervos CKB](#nervos-ckb) #### Not To Be Confused With + - [Common Knowledge Byte](#common-knowledge-byte) #### See Also + - [Nervos CKB on Nervos.org](https://www.nervos.org/ckb/) --- ### Common Knowledge Byte + The native token of the Nervos layer 1 blockchain, the Common Knowledge Base. Common Knowledge Byte is often abbreviated as CKByte or CKB. @@ -305,13 +358,16 @@ Common Knowledge Byte is often abbreviated as CKByte or CKB. Owning a CKByte entitles the holder to store one byte of data on the Nervos CKB blockchain. #### Synonyms + - [CKB](#ckb) - [CKByte](#ckbyte) #### Not To Be Confused With + - [Common Knowledge Base](#common-knowledge-base) #### See Also + - [Capacity](#capacity) - [Nervos CKB](#nervos-ckb) - [Shannon](#shannon) @@ -319,9 +375,11 @@ Owning a CKByte entitles the holder to store one byte of data on the Nervos CKB --- ### Confirmation + A process where a transaction has been accepted and verified by the network and included in a block. #### See Also + - [Block](#block) - [Transaction](#transaction) - [Unconfirmed](#unconfirmed) @@ -329,62 +387,74 @@ A process where a transaction has been accepted and verified by the network and --- ### Consensus + An algorithm executed among a number of distributed participants, ensuring that all participants faithfully executing this algorithm can reach agreement on some data value even if the other participants are faulty or malicious. #### See Also + - [NC-MAX](#nc-max) --- - ### Consume + The process of using a Live Cell as an input to a transaction. The consumption processes indicate that Live Cell turns into a Dead Cell. --- ### Contract Account + An account containing code that executes automatically whenever it receives an event from another account. #### See Also + - [Account](#account) --- ### Cryptocurrency + A cryptocurrency is a digital or virtual currency that is secured by blockchain and cryptography, which makes it nearly impossible to counterfeit or double-spend. #### See Also + - [Digital Currency](#digital-currency) - [Fiat Currency](#fiat-currency) --- ### Cryptographic Signature + A concise piece of proof data. Cryptographic signature schemes are a fundamental component of cryptocurrency networks that verify the integrity and non-repudiation of transaction messages across the network. #### Synonyms + - [Private Key](#private-key) - [Signature](#signature) --- ### Cryptography + Cryptography is the practice and study of techniques for secure communication in the presence of adversarial behavior. #### See Also + - [Cryptography at Wikipedia](https://en.wikipedia.org/wiki/Cryptography) --- ### Cycles -The number of RISC-V computational cycles required by a script to execute. It's a metric used to prevent malicious behavior such as infinite loops, that's why it is called cycles. + +The number of RISC-V computational cycles required by a script to execute. It's a metric used to prevent malicious behavior such as infinite loops, that's why it is called cycles. This is a similar concept to Ethereum's Gas, we set cycles to ensure optimal performance and security. Scripts must stay within cycle limits, otherwise the block will be rejected by CKB nodes. #### See Also + - [Estimate cycles](https://nervos-ckb-docs-git-v1-cryptape.vercel.app/docs/essays/faq/#estimate-cycles) - [Max_block_cycles](#max_block_cycles) -- [Rules for calculating cycles in RFC on Nervos Network Github](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0014-vm-cycle-limits/0014-vm-cycle-limits.md ) +- [Rules for calculating cycles in RFC on Nervos Network Github](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0014-vm-cycle-limits/0014-vm-cycle-limits.md) - [Script](#script) - [RISC-V](#risc-v) - [Ethereum's Gas](https://ethereum.org/en/glossary/#gas) @@ -392,79 +462,98 @@ This is a similar concept to Ethereum's Gas, we set cycles to ensure optimal per --- ### DAO + A decentralized autonomous organization (DAO) is an organization represented by rules encoded as a computer program that is transparent, controlled by the organization members and not influenced by a centralized entity, in other words they are member-owned communities without centralized leadership. A DAO's financial transaction record and program rules are maintained on a blockchain. #### See Also + - [DAO on Wikipedia](https://en.wikipedia.org/wiki/Decentralized_autonomous_organization) --- ### DApp + Decentralized application. At a minimum, it is a smart contract and a web user interface. In a broader sense, dApps are web applications that are built on top of open, decentralized, peer-to-peer infrastructure services. Additionally, many dApps include decentralized storage and/or a message protocol and platform. --- ### Data + In Cell Model, `data` is a field in a Cell which can store arbitrary bytes. #### See Also + - [Cell](#cell) - [Cell Model](#cell-model) --- ### Decentralization + In blockchain, decentralization refers to the transfer of control and decision-making from a centralized entity (individual, organization, or group thereof) to a distributed network. + #### See Also + - [Distributed](#distributed) - [Decentralization on Wikipedia](https://en.wikipedia.org/wiki/Decentralization) --- ### DeFi + Short for "decentralized finance", a broad category of dApps aiming to provide financial services backed by the blockchain, without any intermediaries, so anyone with an internet connection can participate. --- ### Digital Asset + A digital asset is an individual piece of data that has value, or represents another entity that has value. Digital assets are most commonly represented as tokens, which may be used as digital currency or represent physical items such as real estate. #### Synonyms + - [Asset](#asset) - [Token](#token) --- ### Digital Currency + A type of currency that primarily exists digitally over the internet. Physical representations of the currency, in the form of cards, bills, or coins, may exist, but are secondary mediums. #### See Also + - [Cryptocurrency](#cryptocurrency) --- ### Distributed + A system where components are spread across multiple nodes to parallelize workloads, add redundancy, or eliminate single points of failure. #### See Also + - [Decentralization](#decentralization) --- ### Digital Object (DOB) + A non-fungible encrypted asset with its content fully stored on-chain, establishing an intrinsic link between content and value. #### See Also + - [Non-Fungible-Token](#non-fungible-token) --- ### Double-Spending + Double-spending is the risk that a digital token is spent twice or more. In the context of blockchain, it happens when the transaction spending a digital token is cancelled after confirmation, and the same token is spent in another transaction. #### See Also + - [Confirmation](#confirmation) - [Cryptocurrency](#cryptocurrency) - [Token](#token) @@ -473,19 +562,23 @@ Double-spending is the risk that a digital token is spent twice or more. In the --- ### Epoch -An epoch is a period of time for a set of blocks. + +An epoch is a period of time for a set of blocks. In Nervos, the PoW difficulty changes on a new epoch. All the blocks in the same epoch share the same difficulty target. The difficulty adjustment algorithm aims to stabilize the orphan block rate at 2.5% and the epoch duration at 4 hours. #### See Also + - [Block](#block) --- ### Fee + The sender of a transaction often includes a fee to the network for processing the requested transaction. There's no minimum fee rate set in consensus, but there's a minimum fee rate 1,000 Shannons/KB in CKB's [P2P](#p2p) network. (1 Shannon = 10-8 CKB) #### See Also + - [Shannon](#shannon) - [Fee rate](#fee-rate) - [Fee rate in RFC on Nervos Network Github](https://github.com/nervosnetwork/ckb/tree/develop/rpc#error-poolrejectedtransactionbyminfeerate) @@ -493,28 +586,34 @@ The sender of a transaction often includes a fee to the network for processing t --- ### Fee Rate + A tip per byte that a user offers to the miners for including his transaction in a block on the blockchain. This is a same concept to Bitcoin's [Fee Rate(often spelled feerate)](https://en.bitcoin.it/wiki/Miner_fees#Feerates). #### See Also + - [Fee](#fee) ### First-Class Assets -Assets that 1. the asset itself (rather than a reference to the asset) can be passed directly in smart contract interactions, and 2. directly controlled by owners without any intermediaries. + +Assets that 1. the asset itself (rather than a reference to the asset) can be passed directly in smart contract interactions, and 2. directly controlled by owners without any intermediaries. #### See Also + - [First-Class Asset](https://medium.com/nervosnetwork/first-class-asset-ff4feaf370c4) - [Introduction to First-Class Asset](https://talk.nervos.org/t/first-class-asset/1293) --- ### Fork + A change in protocol causing the creation of an alternative chain, or a temporal divergence in two potential block paths during mining. --- ### Full Node + A full node is an essential component of the CKB network. It stores and syncs the entire blockchain, verifies the validity of blocks and transactions, and enforces the network's consensus rules. ``` @@ -522,6 +621,7 @@ ckb init --chain Mainnet && ckb run ``` #### See Also + - [Node](#node) - [Light Node](#light-node) - [Mining Node](#mining-node) @@ -529,16 +629,18 @@ ckb init --chain Mainnet && ckb run --- ### Full Payload Format + The deprecated full payload format directly encodes all data field of lock script. The encode rule of deprecated full payload format is [Bech32](https://en.bitcoin.it/wiki/Bech32). #### See Also + - [Lock Script](#lock-script) --- ### Fungible Token -A fungible token can be fiat currencies like the dollar or a cryptocurrency like Bitcoin. +A fungible token can be fiat currencies like the dollar or a cryptocurrency like Bitcoin. Fungible tokens or assets are divisible and non-unique. @@ -555,19 +657,23 @@ Fungible tokens or assets are divisible and non-unique. The maximum amount of gas a transaction or block may consume. #### See Also + - [Ethereum's Gas](https://ethereum.org/en/glossary/#gas) --- ### Hard-Fork + A permanent divergence in the blockchain; also known as a hard-forking change. One commonly occurs when nonupgraded nodes can’t validate blocks created by upgraded nodes that follow newer consensus rules. Not to be confused with a fork, soft fork, software fork, or Git fork. --- ### Hardware Wallet + A hardware wallet is a form of cold wallet. A hardware wallet is a cryptocurrency wallet that stores the user's private keys (a critical piece of information used to authorize outgoing transactions on the blockchain network) in a secure hardware device. #### See Also + - [Cold Storage](#cold-storage) - [Cold Wallet](#cold-wallet) - [Private Key](#private-key) @@ -576,33 +682,40 @@ A hardware wallet is a form of cold wallet. A hardware wallet is a cryptocurrenc --- ### Hash + A fixed-length fingerprint of variable-size input, produced by a hash function. --- ### Hash Rate + Hash rate is a measure of the computational power per second used when mining. These operations are known as "hashing". #### See Also + - [Miner](#miner) - [Network Hash Rate](#network-hash-rate) --- ### Height + A shorthand name for block height. #### Synonyms + - [Block Height](#block-height) --- ### Light Client + As a low-resource node, a light client allows users to sync with a blockchain in a cryptographically secure manner without having to store the whole blockchain. --- ### Light Node + A light node downloads only the headers of the blockchain, conserving resources. It relies on other nodes for full transaction data and is a lightweight option for network participation. ``` @@ -610,26 +723,30 @@ ckb-light-client run --config-file ./testnet.toml ``` #### See Also + - [Node](#node) - [Full Node](#full-node) - [Mining Node](#mining-node) - --- ### Mempool + Short for "memory pool". A waiting area on full nodes for transactions that have been broadcasted to the network but have not yet been confirmed on the blockchain. #### See Also + - [Confirmation](#confirmation) - [Transaction](#transaction) --- ### Metadata + Metadata is data that provides information about other data. `capacity`, `type` and `lock` in Cells are metadata, they occupy Cell capacity and incur a state cost as well. #### See Also + - [Capacity](#capacity) - [Cell](#cell) - [Lock](#lock) @@ -638,38 +755,47 @@ Metadata is data that provides information about other data. `capacity`, `type` --- ### Micro-State + A small piece of state that is isolated and often able to be acted upon independently without knowing the total state of the network. On Nervos, micro-state is represented by a Cell. #### Synonyms + - [Cell](#cell) #### See Also + - [State](#state) --- ### Miner + A network node that finds valid proof of work for new blocks, by repeated hashing. #### See Also + - [Proof of Work](#proof-of-work) --- ### Miner Fee + Another term for transaction fee. #### Synonyms + - [Transaction Fee](#transaction-fee) --- ### Mining + Mining is the process by which a blockchain node get new token reward by verifying new transactions, finding valid proof of work and creating new blocks. #### See Also + - [Block](#block) - [Blockchain](#blockchain) - [Mining Reward](#mining-reward) @@ -678,6 +804,7 @@ Mining is the process by which a blockchain node get new token reward by verifyi --- ### Mining Node + Mining nodes create new blocks by solving computational puzzles. They contribute to the network's security and consensus by actively validating and adding blocks to the blockchain. ``` @@ -685,6 +812,7 @@ ckb init --chain Mainnet && ckb miner ``` #### See Also + - [Block](#block) - [Consensus](#consensus) - [Miner](#miner) @@ -696,9 +824,11 @@ ckb init --chain Mainnet && ckb miner --- ### Mining Reward + Native tokens paid to miners as a reward for providing the necessary computing resources for mining. #### See Also + - [Miner](#miner) - [Mining](#mining) - [Native Token](#native-token) @@ -706,23 +836,28 @@ Native tokens paid to miners as a reward for providing the necessary computing r --- ### Multisig + The term multisig stands for multi-signature, which is a specific type of digital signatures that can be created through the combination of multiple unique signatures. --- ### Native Token + The token issued as reward to a blockchain's consensus nodes. Nervos CKB's native token is CKByte. #### See Also + - [CKByte](#ckbyte) - [Token](#token) --- ### NC-MAX + Nervos CKB's consensus algorithm, which follows NC's backbone protocol. The main innovation here is a two-step transaction confirmation mechanism #### See Also + - [Consensus](#consensus) - [Nervos Blockchain](#nervos-blockchain) - [NC-MAC](https://eprint.iacr.org/2020/1101) @@ -730,18 +865,22 @@ Nervos CKB's consensus algorithm, which follows NC's backbone protocol. The main --- ### Neighbor + A node that is directly connected to another node in the blockchain peer to peer network. #### See Also + - [Node](#node) - [Peer to Peer](#peer-to-peer) --- ### Nervos Blockchain + The layer 1 blockchain of the Nervos Network known as the Common Knowledge Base. #### Synonyms + - [Common Knowledge Base](#common-knowledge-base) - [Layer 1](#layer-1) - [Nervos CKB](#nervos-ckb) @@ -749,9 +888,11 @@ The layer 1 blockchain of the Nervos Network known as the Common Knowledge Base. --- ### Nervos DAO + Nervos DAO enable users to lock CKBytes to get compensation from Nervos CKB secondary issuance. This process is similar to staking on other platforms. Nervos DAO provides a "virtual hardcap" for CKByte holders to insulate them from inflation. #### See Also + - [CKByte](#ckbyte) - [DAO](#dao) - [Secondary Issuance](#secondary-issuance) @@ -762,18 +903,22 @@ Nervos DAO enable users to lock CKBytes to get compensation from Nervos CKB seco --- ### Network Hash Rate + A measurement of the total computational processing power which is dedicated to providing security to the network. #### See Also + - [Hash Rate](#hash-rate) - [Miner](#miner) --- ### Node + A software client that participates in the network. #### See Also + - [Full Node](#full-node) - [Light Node](#light-node) - [Mining Node](#mining-node) @@ -781,18 +926,22 @@ A software client that participates in the network. --- ### Nonce + In cryptography, a value that can only be used once. Nonce can refer to two things in blockchain context: 1. a proof-of-work nonce is the random value in a block satisfying the proof of work requirement; 2. an account nonce is a transaction counter in each account, which is used to prevent replay attacks. #### See Also + - [Block](#block) - [Proof of Work](#proof-of-work) --- ### Non-Fungible Token + Non-fungible tokens or NFTs are cryptographic assets on a blockchain with unique identification codes and metadata that distinguish them from each other. #### See Also + - [DOB](#digital-object-dob) - [Fungible Token](#fungible-token) - [Token](#token) @@ -801,55 +950,68 @@ Non-fungible tokens or NFTs are cryptographic assets on a blockchain with unique --- ### Open Source + A piece of software where source code is freely available for examination or alteration by any third-party. #### See Also + - [What is Open Source at OpenSource.com](https://opensource.com/resources/what-open-source) --- ### P2P + A shortname name for peer to peer. #### Synonyms + - [Peer to Peer](#peer-to-peer) --- ### Paper Wallet + A form of storing a recovery phrase or private keys offline by printing them on a piece of paper. This document would then be stored by traditional means in a secured location of the user's choosing, such as a safe. #### See Also + - [Private Key](#private-key) - [Wallet](#wallet) --- ### Payment Address -A string of letters and numbers that cryptocurrency and assets can be sent to and from. + +A string of letters and numbers that cryptocurrency and assets can be sent to and from. Nervos CKB Mainnet addresses always begin with the prefix "ckb". #### Synonyms + - [Address](#address) --- ### Payment Channel + A micropayment channel or payment channel is class of techniques designed to allow users to make multiple payment transactions without committing all of the transactions to the layer 1 blockchain. In a typical payment channel, only two transactions are added to the block chain but an unlimited or nearly unlimited number of payments can be made between the participants. #### See Also + - [Layer 1](#layer-1) --- ### Peer to Peer + A peer-to-peer (P2P) service is a decentralized platform whereby two individuals interact directly with each other, without intermediation by a third party. #### Synonyms + - [P2P](#p2p) #### See Also + - [Node](#node) --- @@ -869,11 +1031,12 @@ A private key, also known as a secret key, is a variable in cryptography, known ### Proof of Work -PoW asks users to solve a cryptographic puzzle to prove ownershipo of a certain amount of computational resource to participate in the consensus. In general PoW is a more permissionless consensus mechanism than PoS. +PoW asks users to solve a cryptographic puzzle to prove ownershipo of a certain amount of computational resource to participate in the consensus. In general PoW is a more permissionless consensus mechanism than PoS. In contrast to wildly spread misconception, PoW is not a "waste" of energy and does not induce more carbon emission. PoW is used in the Nervos layer 1 blockchain CKB. #### See Also + - [Block](#block) - [Consensus](#consensus) - [Mining Reward](#mining-reward) @@ -883,9 +1046,11 @@ In contrast to wildly spread misconception, PoW is not a "waste" of energy and d --- ### Proof of Stake + PoS asks users to prove ownership of a certain amount of cryptocurrency (their “stake” in the network) in order to be able to participate in the consensus. PoS relies on weak-subjectivity due to unsolvable issues like long-range attack. In PoS system the future consensus quorum is decided by existing participants completely. PoS is used in layer 2 protocols on Nervos Network. #### See Also + - [Consensus](#consensus) - [Mining Reward](#mining-reward) - [Proof of Work](#proof-of-work) @@ -894,26 +1059,31 @@ PoS asks users to prove ownership of a certain amount of cryptocurrency (their --- ### Propagation + A shorthand name for Block Propagation. #### Synonyms -- [Block Propagation](#block-propagation) +- [Block Propagation](#block-propagation) --- ### Public Key + A notion used only in public-key cryptography, a.k.a. asymmetric cryptography. A public key is a piece of information that can be known to others without compromising security. Unique for each user, a public key is associated with a private key known only to the user. The public key can be used to encrypt a message so that it can only be decrypted with the corresponding private key, or to verify that a message is authorized by the user with the corresponding private key. #### See Also + - [Private Key](#private-key) --- ### Reward + An amount of CKBytes included in each new block as a reward by the network to the miner who found the proof-of-work solution. #### See Also + - [CKByte](#ckbyte) - [Base Reward](#base-reward) - [Block Reward](#block-reward) @@ -925,51 +1095,63 @@ An amount of CKBytes included in each new block as a reward by the network to th --- ### Signature + A shorthand name for cryptographic signature. #### Synonyms + - [Cryptographic Signature](#cryptographic-signature) --- ### Smart Contract -A smart contract is a self-executing contract with the terms of the agreement between contract creators and contract users being directly written into lines of code. The code and the agreements contained therein exist across a distributed, decentralized blockchain network. Also known as script on Nervos CKB. + +A smart contract is a self-executing contract with the terms of the agreement between contract creators and contract users being directly written into lines of code. The code and the agreements contained therein exist across a distributed, decentralized blockchain network. Also known as script on Nervos CKB. --- ### State + Data stored on the blockchain. In most contexts this this means current data and excludes historical data. #### See Also + - [Blockchain](#blockchain) --- ### State Bloat + The unlimited increase of state data in Ethereum. State bloat slows down node synchronization, raises the barrier of full node, thus hurts network decentralization. --- -### State Channel +### State Channel + A layer 2 solution where a channel is set up between participants, where they can transact freely and cheaply. Only a transaction to set up the channel and close the channel is sent to Mainnet. This allows for very high transaction throughput, but does rely on knowing number of participants up front and locking up of funds. --- ### Tip + A shorthand name for tip block. #### Synonyms + - [Tip Block](#tip-block) --- ### Tip Block + The most recent block to be confirmed in a blockchain. The tip block has the highest block height in the blockchain. #### Synonyms + - [Tip](#tip) #### See Also + - [Block](#block) - [Block Height](#block-height) - [Blockchain](#blockchain) @@ -977,9 +1159,11 @@ The most recent block to be confirmed in a blockchain. The tip block has the hig --- ### Transaction + Transaction is the basic object created and signed by users to interact with distributed ledger. Transactions update ledger state at users requests. A CKB transaction destroys some outputs created in previous transactions and creates some new outputs. We call the transaction output a Cell in CKB. #### See Also + - [Blockchain](#blockchain) - [Nervos Blockchain](#nervos-blockchain) - [UTXO](#utxo) @@ -987,12 +1171,15 @@ Transaction is the basic object created and signed by users to interact with dis --- ### Transaction Fee + A fee which is paid in the native token to miners in exchange for processing a transaction. #### Synonyms + - [Miner Fee](#miner-fee) #### See Also + - [Miner](#miner) - [Native Token](#native-token) - [Transaction](#transaction) @@ -1000,62 +1187,76 @@ A fee which is paid in the native token to miners in exchange for processing a t --- ### Token + A “token” often refers to non-native token on smart contract platform, such as UDT on Nervos Network or ERC20 on Ethereum. #### See Also + - [Blockchain](#blockchain) - [Digital Asset](#digital-asset) - [Transaction](#transaction) --- -### Turing Complete +### Turing Complete + Turing Complete refers to a machine that, given enough time and memory along with the necessary instructions, can solve any computational problem, no matter how complex. The term is normally used to describe modern programming languages as most of them are Turing Complete (C++, Python, JavaScript, etc.). --- ### UDT + Short for User-Defined Token, a customised token created with properties defined by the user. In normal usage, this most commonly refers to fungible tokens. #### Synonyms + - [User-Defined Token](#user-defined-token) --- ### Unconfirmed + The state of a transaction that has not yet been confirmed. An unconfirmed transaction is not finalized and cannot be guaranteed. #### Synonyms + - [Unconfirmed Transaction](#unconfirmed-transaction) #### See Also + - [Confirmation](#confirmation) - [Transaction](#transaction) --- ### Unconfirmed Transaction + A transaction that has not yet been confirmed. An unconfirmed transaction is not finalized and cannot be guaranteed. #### Synonyms + - [Unconfirmed](#unconfirmed) #### See Also + - [Confirmation](#confirmation) - [Transaction](#transaction) --- ### User-Defined Token + A custom token created with properties defined by the user. In normal usage, this most commonly refers to fungible tokens. A User-Defined Token is usually referred to by its abbreviation, UDT. #### Synonyms + - [Fungible Token](#fungible-token) - [UDT](#udt) #### See Also + - [ERC20 on Ethereum.org](https://eips.ethereum.org/EIPS/eip-20) - [ERC777 on Ethereum.org](https://eips.ethereum.org/EIPS/eip-777) - [Simple UDT Draft Spec on Nervos Talk](https://talk.nervos.org/t/rfc-simple-udt-draft-spec/4333) @@ -1063,18 +1264,22 @@ A User-Defined Token is usually referred to by its abbreviation, UDT. --- ### UTXO + Abbreviated from Unspent Transaction Output, UTXO denotes the remaining amount of tokens after a transaction, available for future use. Transactions consume existing UTXOs as inputs and generate new ones as outputs, where each UTXO is spent only once. #### See Also + - [Transaction](#transaction) - [The UTXO Model Explained](https://www.nervos.org/knowledge-base/utxo_model_explained) --- ### Wallet + User-facing software used to interact with on-chain entities such as assets, smart contracts and dApps. A wallet can include key management itself or delegate key management to external hardware for improved security. #### See Also + - [Paper Wallet](#paper-wallet) - [Private Key](#private-key) - [Payment Address](#payment-address) @@ -1085,11 +1290,13 @@ User-facing software used to interact with on-chain entities such as assets, sma ## Economics Glossary ### Base Issuance + Base issuance is the basic CKByte issuance with a fixed and decreasing schedule. Base issuance is awarded to miners as incentives to protect the network and also as an indirect token distribution method. -Base issuance is limited to a finite total supply 33.6G (33.6 billion) CKBytes. +Base issuance is limited to a finite total supply 33.6G (33.6 billion) CKBytes. #### See Also + - [Base Reward](#base-reward) - [CKByte](#ckbyte) - [Secondary Issuance](#secondary-issuance) @@ -1099,9 +1306,11 @@ Base issuance is limited to a finite total supply 33.6G (33.6 billion) CKBytes. --- ### Base Reward + Base reward is the block reward (in CKBytes) to miners generated from the base issuance. Base reward halves approximately every 4 years until eventually reaching 0, like Bitcoin. #### See Also + - [Base Issuance](#base-issuance) - [CKByte](#ckbyte) - [Miner](#miner) @@ -1110,9 +1319,11 @@ Base reward is the block reward (in CKBytes) to miners generated from the base i --- ### Commit Reward + A reward paid to miners in CKBytes for committing a previously proposed transaction. After the transaction has been committed it is confirmed. #### See Also + - [CKByte](#ckbyte) - [Confirmation](#confirmation) - [Miner](#miner) @@ -1121,23 +1332,28 @@ A reward paid to miners in CKBytes for committing a previously proposed transact --- ### Economic Abstraction + With proper tool support, users can use tokens other than CKByte (for example, stable coins) to pay transactions fees, a concept known as "Economic Abstraction". --- ### Fiat Currency + Fiat currencies are a medium of exchange established as money, often by government regulation. Fiat money does not have intrinsic value and does not have use value. It has value only because a government maintains its value, or because parties engaging in exchange agree on its value. #### See Also + - [Cryptocurrency](#cryptocurrency) - [Digital Currency](#digital-currency) --- ### Heavy Asset Problem + A common problem found in multi-asset blockchain platforms where the value of the assets stored on the chain gains significant value but the native token of the chain does not. This raises the incentive to attack the network, but does not increase the security because the value of the native token is what is used to secure the network. #### See Also + - [Asset](#asset) - [Starving Layer 1 Problem](#starving-layer-1-problem) - [Tragedy of the Security Commons](#tragedy-of-the-security-commons) @@ -1145,17 +1361,21 @@ A common problem found in multi-asset blockchain platforms where the value of th --- ### Liquidity + The ability for an asset to be bought or sold easily without causing a significant change in the current market price. #### See Also + - [Asset](#asset) --- ### Proposal Reward + A reward paid to miners in CKBytes for proposing an unconfirmed transaction. #### See Also + - [CKByte](#ckbyte) - [Confirmation](#confirmation) - [Miner](#miner) @@ -1164,9 +1384,11 @@ A reward paid to miners in CKBytes for proposing an unconfirmed transaction. --- ### Secondary Issuance + The creation of new CKBytes that is paid to miners through secondary rewards. Secondary issuance follows a fixed inflation schedule of 1.344 billion CKBytes per year. Nervos DAO stakers are not affected by secondary issuance. #### See Also + - [Base Issuance](#base-issuance) - [CKByte](#ckbyte) - [Nervos DAO](#nervos-dao) @@ -1177,11 +1399,13 @@ The creation of new CKBytes that is paid to miners through secondary rewards. Se --- ### Secondary Reward + A subsidy paid to miners in CKBytes for providing the compute and storage requirements required for processing transactions and persisting data on Nervos. Secondary rewards are created from secondary issuance, and continuously pay miners for the verification of transactions and preservation of blockchain state. #### See Also + - [CKByte](#ckbyte) - [Miner](#miner) - [Secondary Issuance](#secondary-issuance) @@ -1190,17 +1414,21 @@ Secondary rewards are created from secondary issuance, and continuously pay mine --- ### Selfish Mining Attack + Selfish mining is a concept that was addressed by Cornell University researchers in detail in a 2013 report. In this attack, malicious miners gain unfair block rewards by deliberately orphaning blocks mined by others. #### See Also + - [Selfish Mining Related Paper](https://www.cs.cornell.edu/~ie53/publications/btcProcFC.pdf) --- ### Starving Layer 1 Problem + A scenario that can arise in multi-layer blockchain platforms where the vast majority of the transaction traffic moves from layer 1 to layer 2, taking the vast majority of transaction fees with it. If layer 1 relies exclusively on transaction fees to support the security of the platform, it may end up not having enough incentives available to properly secure it. #### See Also + - [Heavy Asset Problem](#heavy-asset-problem) - [Layer 1](#layer-1) - [Layer 2](#layer-2) @@ -1210,11 +1438,13 @@ A scenario that can arise in multi-layer blockchain platforms where the vast maj --- ### State Rent -A recurring fee that is paid to persist and secure state data. + +A recurring fee that is paid to persist and secure state data. On Nervos, secondary issuance is used to boost the payment of state rent by users who occupy space on the Nervos blockchain. #### See Also + - [Secondary Issuance](#secondary-issuance) - [Nervos Blockchain](#nervos-blockchain) - [Crypto-Economics RFC on Nervos Network GitHub](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0015-ckb-cryptoeconomics/0015-ckb-cryptoeconomics.md) @@ -1222,38 +1452,46 @@ On Nervos, secondary issuance is used to boost the payment of state rent by user --- ### Store of Assets + Similar to the concept of "Store of Value" in the context of Bitcoin, we call the utility "Store of Assets" when a blockchain keeps any crypto-assets securely and censorship-resistantly. Nervos CKB is such a Store of Assets or SoA. #### See Also + - [Store of Value](#store-of-value) --- ### Store of Value + Assets which can maintain their worth over time without depreciating A good store of value either match or outpace the inflation rate of fiat currency, and has a reasonable amount of liquidity, allowing the asset to be easily sold. #### See Also + - [Store of Assets](#store-of-assets) - [Liquidity](#liquidity) --- ### Tail Emission + A type of reward that is paid to miners through a fixed amount of inflation. #### See Also + - [Secondary Reward](#secondary-reward) --- ### Targeted Inflation + A form of inflation that only affects a specific subset of users. Nervos uses Secondary Issuance to create targeted inflation on users who occupy space on the Nervos blockchain to pay State Rent. Long-term holders of CKBytes have the option of locking them in the Nervos DAO, which acts and an inflation shelter. #### See Also + - [CKByte](#ckbyte) - [Secondary Issuance](#secondary-issuance) - [Nervos Blockchain](#nervos-blockchain) @@ -1263,18 +1501,22 @@ Nervos uses Secondary Issuance to create targeted inflation on users who occupy --- ### Tragedy of the Commons + A situation in a system where the participants act in accordance with their own self interest and deplete or destroy a shared resource through their collective action. #### See Also + - [Tragedy of the Security Commons](#tragedy-of-the-security-commons) - [Tragedy of the Storage Commons](#tragedy-of-the-storage-commons) --- ### Tragedy of the Security Commons + A situation that can emerge on multi-asset blockchain platforms where asset tokens rely on the storage and security of the blockchain platform, but do not contribute back to the platform. As the number of assets that "ride for free" increases, so does the burden placed on the underlying blockchain platform. If the assets do not contribute to the underlying platform, the available security may not properly support the network. #### See Also + - [Heavy Asset Problem](#heavy-asset-problem) - [Tragedy of the Commons](#tragedy-of-the-commons) - [Tragedy of the Storage Commons](#tragedy-of-the-storage-commons) @@ -1282,9 +1524,11 @@ A situation that can emerge on multi-asset blockchain platforms where asset toke --- ### Tragedy of the Storage Commons + A situation that can emerge on incentivized blockchain platforms where mining rewards are paid for inclusion of data to the blockchain, but no rewards exist for the long-term persistence of the blockchain data. As the size of the chain grows, so do the costs associated with persisting the data. If there is no direct incentive for persisting data, fewer and fewer nodes will do so. Eventually, too few nodes will be available to properly support the network. #### See Also + - [Tragedy of the Commons](#tragedy-of-the-commons) - [Tragedy of the Security Commons](#tragedy-of-the-security-commons) @@ -1293,12 +1537,15 @@ A situation that can emerge on incentivized blockchain platforms where mining re ## Technical Glossary ### Active Cell + Or Live Cell, a Cell exists in the current CKB state. Only active Cells can be used as inputs to new transactions. #### Synonyms + - [Live Cell](#live-cell) #### See Also + - [Cell](#cell) - [Input](#input) - [Transaction](#transaction) @@ -1306,6 +1553,7 @@ Or Live Cell, a Cell exists in the current CKB state. Only active Cells can be u --- ### Aggron + The first Nervos CKB Testnet corresponding to Mainnet Lina. - **CKB version**: >= v0.101.0 (latest stable is recommended) @@ -1315,18 +1563,22 @@ The first Nervos CKB Testnet corresponding to Mainnet Lina. - **ckb2021 activated at**: 2021-10-24 03:00:00 UTC #### Synonyms + - [Testnet](#testnet) #### Not To Be Confused With + - [Lina](#lina) - [Mainnet](#mainnet) --- ### Animagus + A framework layer that runs on top of Nervos CKB which provides an easy way to query for account balances without having to go through the Cell collection process. #### See Also + - [Cell Collection](#cell-collection) - [Nervos CKB](#nervos-ckb) - [Animagus Introduction on the Nervos Blog](https://medium.com/nervosnetwork/https-medium-com-nervosnetwork-animagus-part-1-introduction-66fa8ce27ccd-cfb361a7d883) @@ -1334,11 +1586,13 @@ A framework layer that runs on top of Nervos CKB which provides an easy way to q --- ### Args + Args is short for arguments. Arguments are data provided to the lock script or type script of a Cell, similar to args provided to a function or method call. Arguments are stored as part of the Cell when it is created. #### See Also + - [Cell](#cell) - [Lock Script](#lock-script) - [Type Script](#type-script) @@ -1346,72 +1600,87 @@ Arguments are stored as part of the Cell when it is created. --- ### Axon + Axon is a chain-based layer 2 protocol and framework with a practical security and economic model. Axon chains allow anyone to stake tokens on CKB to become a validator and participate in consensus. #### See Also + - [Layer 2](#layer-2) - [Nervos CKB](#nervos-ckb) --- ### Blake2b + A cryptographic hash function. BLAKE2b (or BLAKE2) is optimized for 64-bit platforms including NEON-enabled ARMs and produces digests of any size between 1 and 64 bytes. BLAKE2b is optimized for 8- to 32-bit platforms, and produces digests of any size between 1 and 32 bytes. CKB uses BLAKE2b as the default hash algorithm. #### See Also + - [Blake2b paper](https://blake2.net/blake2.pdf) - [Ckbhash](#ckbhash) -- [Blake Hash Function on Wikipedia](https://en.wikipedia.org/wiki/BLAKE_(hash_function)) +- [Blake Hash Function on Wikipedia]() - [Hash Function on Wikipedia](https://en.wikipedia.org/wiki/Hash_function) --- ### Block Subsidy + A payment that is made in the native currency of the blockchain that is paid to miners for providing the computational resources create a block and secure the blockchain. The subsidy consists is the portion of the total block reward that is issued out of inflation for creating the block, but does not include any additional transaction fees that may be paid on top. #### Synonyms + - [Block Reward](#block-reward) - [Transaction Fee](#transaction-fee) --- ### Boxer + A lightweight Rust library for verifying the Nervos layer 1 blockchain, the Common Knowledge Base. #### See Also + - [Common Knowledge Base](#common-knowledge-base) - [Boxer on GitHub](https://github.com/xxuejie/ckb-boxer) - --- + ### `block_version` + Version of a block. This field is reserved for the system, set to 0 by default. ``` pub const BLOCK_VERSION: Version = 0; ``` + #### See Also + - [Block](#block) --- ### Cell Collection + The process of gathering Cells that meet certain criteria. For example: To find the balance of a particular account, all active Cells for the address would need to be collected. #### See Also + - [Cell](#cell) --- ### Cellbase + The transaction in each block that is responsible for the minting of new CKBytes. This is the equivalent of a coinbase transaction in Bitcoin. #### See Also + - [CKByte](#ckbyte) - [Coinbase on Bitcoin.org](https://developer.bitcoin.org/glossary.html) @@ -1427,6 +1696,7 @@ EpochNumberWithFraction::new_unchecked(4, 0, 1); ``` #### See Also + - [Cellbase](#cellbase) --- @@ -1444,6 +1714,7 @@ Find more in the essay [Script dependencies](https://nervos-ckb-docs-git-v1-cryp --- ### Ckbhash + CKB uses blake2b as the default hash algorithm with the following configurations: - output digest size in bytes: `32` @@ -1468,7 +1739,9 @@ class TestCKBBlake2b(unittest.TestCase): if __name__ == '__main__': unittest.main() ``` + #### See Also + - [Blake2b](#blake2b) --- @@ -1484,6 +1757,7 @@ ckbhash(left || right) > `ckbhash` is the hash function, `||` denotes binary concatenation. #### See Also + - [Merkle Tree for Static Data](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0006-merkle-tree/0006-merkle-tree.md) - [Ckbhash](#ckbhash) - [Merkle Tree on Wikipedia](https://en.wikipedia.org/wiki/Merkle_tree) @@ -1491,9 +1765,11 @@ ckbhash(left || right) --- ### Code Hash + A field in a Cell that contains a hash value which could refer to a specific piece of data, or a specific Cell referenced by Type ID. #### See Also + - [Cell](#cell) - [Data](#data) - [Type ID](#type_id) @@ -1501,11 +1777,13 @@ A field in a Cell that contains a hash value which could refer to a specific pie --- ### Commit + The process of taking a proposed transaction and adding it to the blockchain. After the transaction has been committed it is confirmed. Miners are incentivized to commit transactions by being paid a commit reward. #### See Also + - [Commit Reward](#commit-reward) - [Confirmation](#confirmation) - [Propose](#propose) @@ -1514,9 +1792,11 @@ Miners are incentivized to commit transactions by being paid a commit reward. --- ### Commitment Zone + Section of the block that contains transaction commitments. The commitment zone can only contain valid transactions which have appeared in the proposal zone of one of the previous 2 to 10 blocks. #### See Also + - [Block](#block) - [Proposal Zone](#proposal-zone) - [Transaction](#transaction) @@ -1524,11 +1804,13 @@ Section of the block that contains transaction commitments. The commitment zone --- ### Consume + The process of using a Live Cell as an input to a transaction. The process of consumption marks the Live Cell as a Dead Cell. This is the equivalent of marking a UTXO as spent in Bitcoin. #### See Also + - [Cell](#cell) - [Cell Model](#cell-model) - [Dead Cell](#dead-cell) @@ -1538,45 +1820,54 @@ The process of consumption marks the Live Cell as a Dead Cell. This is the equiv --- ### Crypto Primitives + Well-established, low-level cryptographic algorithm commonly used to build out a cryptographic protocol. #### See Also + - [Cryptographic Primitive on Wikipedia](https://en.wikipedia.org/wiki/Cryptographic_primitive) --- ### `dao_type_hash` -NervosDAO’s `type_hash`. + +NervosDAO’s `type_hash`. Find more in [CKB Genesis Script List](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0024-ckb-genesis-script-list/0024-ckb-genesis-script-list.md#ckb-genesis-script-list). #### See Also + - [Type Script Hash](#type-script-hash) --- ### Data + In Nervos specific contexts, data may refer to the data structure within a Cell. This structure is used to hold any form of information that needs to be stored on the Nervos blockchain. In more general contexts, data may refer to any form of information. #### See Also + - [Cell](#cell) - [Cell Model](#cell-model) --- ### Dead Cell -A Cell that has been used as an input to a previous transaction and is consumed. + +A Cell that has been used as an input to a previous transaction and is consumed. A Dead Cell cannot be used as an input to a new transaction, nor can it be used as a dependency. It is effectively destroyed and removed from the active state of the network. A Dead Cell is the equivalent of a "spent UTXO" in Bitcoin. #### Synonyms + - [Historical Cell](#historical-cell) #### See Also + - [Cell](#cell) - [Cell Model](#cell-model) - [Consume](#consume) @@ -1586,9 +1877,11 @@ A Dead Cell is the equivalent of a "spent UTXO" in Bitcoin. --- ### Dep Group + A method for referencing multiple dependencies which are commonly used together using a single dependency field. #### See Also + - [Dep Type](#dep-type) - [Dependencies](#dependencies) - [CKB Transaction Structure on GitHub](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0022-transaction-structure/0022-transaction-structure.md) @@ -1596,9 +1889,11 @@ A method for referencing multiple dependencies which are commonly used together --- ### Dep Type + A field that specifies the type of the dependency. #### See Also + - [Dep Group](#dep-group) - [Dependencies](#dependencies) - [CKB Transaction Structure on GitHub](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0022-transaction-structure/0022-transaction-structure.md) @@ -1606,20 +1901,25 @@ A field that specifies the type of the dependency. --- ### Deps + A shorthand name for dependencies. #### Synonyms + - [Dependencies](#dependencies) --- ### Dependencies -Dependencies are commonly referred to as deps. Dependencies are Cells that are referenced in a transaction. Cells that are referenced as dependencies are read-only and made available to any scripts executing within the transaction. Dependencies, or deps, are not consumed. + +Dependencies are commonly referred to as deps. Dependencies are Cells that are referenced in a transaction. Cells that are referenced as dependencies are read-only and made available to any scripts executing within the transaction. Dependencies, or deps, are not consumed. #### Synonyms + - [Deps](#deps) #### See Also + - [Cell](#cell) - [Consume](#consume) - [Script](#script) @@ -1628,37 +1928,45 @@ Dependencies are commonly referred to as deps. Dependencies are Cells that are r --- ### Duktape + Duktape is an embeddable Javascript engine, with a focus on portability and compact footprint. Duktape is used to run JavaScript based smart contracts on Nervos. #### See Also + - [Duktape Official Website](https://duktape.org/) --- ### Difficulty + A measurement of how difficult it is to solve the [Proof of Work](#proof-of-work) cryptographic puzzle required to create a block. Networks automatically adjust the difficulty to control the speed at which blocks are generated as mining participants enter and exit the network. #### See Also + - [Proof of Work](#proof-of-work) --- ### Diviner + A deterministic testing framework for Rust. #### See Also + - [Diviner on GitHub](https://github.com/xxuejie/diviner) --- ### Eaglesong -Eaglesong is a new hash function developed specifically for Nervos CKB proof-of-work, which is also suitable in other use cases in which a secure hash function is needed. + +Eaglesong is a new hash function developed specifically for Nervos CKB proof-of-work, which is also suitable in other use cases in which a secure hash function is needed. #### See Also + - [Eaglesong RFC on the Nervos Github](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0010-eaglesong/0010-eaglesong.md) - [Introducing Eaglesong, Nervos’s New Hash Function for CKB Proof-of-Work](https://medium.com/nervosnetwork/the-proof-of-work-function-of-nervos-ckb-3cc8364464d9) @@ -1666,25 +1974,27 @@ Eaglesong is a new hash function developed specifically for Nervos CKB proof-of- ### `epoch_duration_target` -The estimated epoch duration specified by NC-Max. Set as 4 hours in CKB. +The estimated epoch duration specified by NC-Max. Set as 4 hours in CKB. ``` pub(crate) const DEFAULT_EPOCH_DURATION_TARGET: u64 = 4 * 60 * 60; // 4 hours, unit: second ``` #### See Also + - [Epoch](#epoch) - [NC-Max](#nc-max) --- - ### ERC20 + An Ethereum token standard for basic fungible tokens. An sUDT on Nervos is the equivalent of Ethereum tokens standards ERC20 or ERC777. #### See Also + - [ERC777](#erc777) - [Fungible Token](#fungible-token) - [Token](#token) @@ -1694,9 +2004,11 @@ An sUDT on Nervos is the equivalent of Ethereum tokens standards ERC20 or ERC777 --- ### ERC721 + An Ethereum token standard for non-fungible tokens. #### See Also + - [Non-Fungible Token](#non-fungible-token) - [Token](#token) - [ERC721 on Ethereum.org](https://eips.ethereum.org/EIPS/eip-721) @@ -1704,11 +2016,13 @@ An Ethereum token standard for non-fungible tokens. --- ### ERC777 + An updated Ethereum token standard for basic fungible tokens that is backwards compatible with ERC20. An sUDT on Nervos is the equivalent of Ethereum tokens standards ERC20 or ERC777. #### See Also + - [ERC20](#erc20) - [Fungible Token](#fungible-token) - [Token](#token) @@ -1718,9 +2032,11 @@ An sUDT on Nervos is the equivalent of Ethereum tokens standards ERC20 or ERC777 --- ### ERC1155 + An Ethereum token standard that supports the creation any number of fungible or non-fungible tokens on a single contract. #### See Also + - [Fungible Token](#fungible-token) - [Non-Fungible Token](#non-fungible-token) - [Token](#token) @@ -1742,20 +2058,21 @@ An address format used on Nervos that includes the full code hash of the lock sc ### Generator -A program used to create transactions that can be broadcast to the Nervos CKB network. +A program used to create transactions that can be broadcast to the Nervos CKB network. Generators run locally on the client side (off-chain). They utilize user input and existing Cells as program inputs, to create new Cells with new states as output. --- ### Genesis Block + The first block in the blockchain, used to initialize the global state. The genesis block is unique because it does not contain a reference to the previous block because it is the first. #### See Also + - [Block](#block) - [Blockchain](#blockchain) - --- ### `genesis_hash` @@ -1774,18 +2091,22 @@ The genesis block contains two main components: --- ### Godwoken + Godwoken is a layer 2 rollup framework for Nervos CKB. It provides scaling capability, as well as an abstract account model to CKB. #### See Also + - [Godwoken on GitHub](https://github.com/nervosnetwork/godwoken) - [Godwoken Documentation Site](https://docs.godwoken.io/) --- ### Governance Script + A type script which defines the monetary policy of a User Defined Token (UDT). #### See Also + - [Governance Script Hash](#governance-script-hash) - [UDT](#udt) - [User Defined Token](#user-defined-token) @@ -1794,12 +2115,15 @@ A type script which defines the monetary policy of a User Defined Token (UDT). --- ### Governance Script Hash + A Blake2b hash of a type script which is used as an identifier for the script when referenced by a Cell. #### Synonyms + - [Type Script Hash](#type-script-hash) #### See Also + - [Governance Script](#governance-script) - [UDT](#udt) - [User Defined Token](#user-defined-token) @@ -1808,21 +2132,26 @@ A Blake2b hash of a type script which is used as an identifier for the script wh --- ### Historical Cell + An alternative term for [Dead Cell](#dead-cell). #### Synonyms + - [Dead Cell](#dead-cell) #### See Also + - [Cell](#cell) - [Cell Model](#cell-model) --- ### Inbound Connection + Inbound connection means it is initiated by the remote peer; and the connection itself is outgoing connection when we switch the subject to the remote peer. #### See Also + - [Outbound Connection](#outbound-connection) --- @@ -1840,7 +2169,7 @@ An application or library to trace Live Cells that comply with criteria specifie ### `initial_primary_epoch_reward` -Incentives paid to miners in CKBytes by epoch in CKB base issuance. Under CKB's consensus, block interval is uncertain, while epoch can be fixed at approximately 4 hours, so reward issuance is determined by epoch. Each epoch issues 1_917_808_21917808 Shannons of CKBytes, whose total amount is fixed but halves every 4 years. +Incentives paid to miners in CKBytes by epoch in CKB base issuance. Under CKB's consensus, block interval is uncertain, while epoch can be fixed at approximately 4 hours, so reward issuance is determined by epoch. Each epoch issues 1_917_808_21917808 Shannons of CKBytes, whose total amount is fixed but halves every 4 years. The initial base issuance is 4.2 billion CKBytes per year. Similar to Bitcoin, the base issuance halves approximately every 4 years until it stops. @@ -1851,6 +2180,7 @@ pub(crate) const INITIAL_PRIMARY_EPOCH_REWARD: Capacity = Capacity::shannons(1_9 ``` #### See Also + - [Block Reward](#block-reward) - [Epoch](#epoch) - [`secondary_epoch_reward`](#secondary_epoch_reward) @@ -1876,27 +2206,32 @@ A Live Cell that is used in a transaction. If the transaction is accepted by the A specification of how to manage wallet Lock Scripts which apply to a specific user. #### See Also + - [Lock Script](#lock-script) - [Keyper on GitHub](https://github.com/ququzone/keyper) --- ### Late Spawning + When a node joins a blockchain network for the first time after the network has already been in operation for a period of time. A network is said to support late spawning if that participant can download and verify the entire blockchain without having to trust any of the participants in the network to feed them unaltered data. #### See Also + - [Genesis Block](#genesis-block) --- ### Layer 1 + Layer 1 of a decentralized ecosystem is the underlying blockchain architecture. -A proof of work blockchain known as the Common Knowledge Base (CKB) that serves as the base layer for the Nervos Network. +A proof of work blockchain known as the Common Knowledge Base (CKB) that serves as the base layer for the Nervos Network. #### See Also + - [CKB](#ckb) - [Common Knowledge Base](#common-knowledge-base) - [Layer 2](#layer-2) @@ -1904,16 +2239,19 @@ A proof of work blockchain known as the Common Knowledge Base (CKB) that serves --- ### Layer 2 -Layer 2 refers to a secondary framework or protocol that is built on top of an existing blockchain system. + +Layer 2 refers to a secondary framework or protocol that is built on top of an existing blockchain system. The main goal of these protocols is to solve the transaction speed and scaling difficulties that are being faced by the major cryptocurrency networks. #### See Also + - [Layer 1](#layer-1) --- ### Lina + The name of public Mainnet of the Nervos CKB. - **CKB version**: >= v0.25.2 (latest stable is recommended) @@ -1922,26 +2260,32 @@ The name of public Mainnet of the Nervos CKB. - **Launched at**: 2019-11-15 21:11:00 UTC #### Synonyms + - [Mainnet](#mainnet) #### Not To Be Confused With + - [Aggron](#aggron) - [Testnet](#testnet) #### See Also + - [Nervos CKB](#nervos-ckb) --- ### Live Cell + A Cell that has not been consumed and is available for use. This is similar to an unspent transaction output (UTXO) in Bitcoin. #### Synonyms + - [Active Cell](#active-cell) #### See Also + - [Cell](#cell) - [Cell Model](#cell-model) - [UTXO on Bitcoin.org](https://developer.bitcoin.org/glossary.html) @@ -1949,15 +2293,19 @@ This is similar to an unspent transaction output (UTXO) in Bitcoin. --- ### Lock -A script that represents the ownership of a Cell. A user successfully unlocks a Cell and is able to consume it if the Cell's lock script exits normally. + +A script that represents the ownership of a Cell. A user successfully unlocks a Cell and is able to consume it if the Cell's lock script exits normally. #### See Also + - [Lock Script](#lock-script) ### Lock Script + A script that enforces access and ownership of a Cell. This script controls who has permission to use the Cell as an input. Lock scripts accept user generated proofs or witnesses and including transaction as inputs. #### See Also + - [Cell](#cell) - [Type Script](#type-script) - [Script](#script) @@ -1965,28 +2313,34 @@ A script that enforces access and ownership of a Cell. This script controls who --- ### Lock Script Hash + A [Blake2b](#blake2b) hash of a lock script which is used as an identifier for the script when referenced by a Cell. #### See Also + - [Cell](#cell) - [Lock Script](#lock-script) --- ### Mainnet + Short for "main network", the running Nervos CKB public blockchain. The name of the Nervos CKB Mainnet is [Lina](#lina). #### Synonyms + - [CKB](#ckb) - [Common Knowledge Base](#common-knowledge-base) - [Lina](#lina) - [Nervos CKB](#nervos-ckb) #### Not To Be Confused With + - [Aggron](#aggron) - [Testnet](#testnet) --- + ### `max_block_bytes` The maximum transaction size limit allowed in a block in bytes. Estimated based on the size consumed by 1000 2-in-2-out secp256k1 transactions. @@ -1996,6 +2350,7 @@ pub const MAX_BLOCK_BYTES: u64 = TWO_IN_TWO_OUT_BYTES * TWO_IN_TWO_OUT_COUNT; ``` --- + ### `max_block_cycles` The maximum transaction cycle limit allowed in a block. Estimated based on the cycles consumed by 1000 2-in-2-out secp256k1 transactions. @@ -2010,9 +2365,11 @@ pub(crate) const MAX_BLOCK_CYCLES: u64 = TWO_IN_TWO_OUT_CYCLES * TWO_IN_TWO_OUT_ ``` #### See Also + - [Cycles](#cycles) --- + ### `max_block_proposals_limit` The maximum amount of proposals contained in one block. The default value starts from 1.5. @@ -2023,9 +2380,11 @@ pub const MAX_BLOCK_PROPOSALS_LIMIT: u64 = 1_500; ``` #### See Also + - [Proposal Zone](#proposal-zone) --- + ### `max_uncles_num` The maximum number (Uint64) of uncle blocks allowed for one block. Set as 2 by default. @@ -2035,6 +2394,7 @@ const MAX_UNCLE_NUM: usize = 2; ``` #### See Also + - [Uncle](#uncle) --- @@ -2050,148 +2410,180 @@ const MEDIAN_TIME_BLOCK_COUNT: usize = 37; --- ### Minting + The process of creating of new tokens. #### See Also + - [Token](#token) --- ### Molecule + A serialization framework for encoding data widely used on the Nervos Network. #### See Also + - [Molecule Specification](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0008-serialization/0008-serialization.md) - [Molecule on Github](https://github.com/nervosnetwork/molecule) --- ### Muta + A highly customizable, high-performance blockchain framework designed to support proof of stake, BFT consensus and smart contracts. #### See Also + - [Muta on GitHub](https://github.com/nervosnetwork/muta) - [Proof of Stake](#proof-of-stake) --- ### Nervos CKB + The layer 1 blockchain of the Nervos Network, the Common Knowledge Base. Nervos CKB is often referred to as the Nervos Blockchain. #### Synonyms + - [CKB](#ckb) - [Common Knowledge Base](#common-knowledge-base) - [Nervos Blockchain](#nervos-blockchain) #### See Also + - [Layer 1](#layer-1) --- ### Off-Chain Computation + A programming model where all computation is done off-chain to reduce the burden on the nodes in the network and provide higher levels of scalability. Nervos uses off-chain computation and on-chain verification. #### See Also + - [On-Chain Computation](#on-chain-computation) - [On-Chain Verification](#on-chain-verification) --- ### Off-Chain Scaling + Off-chain scaling is the approach that only using the blockchain as a secure asset and settlement platform in conjunction with transferring almost all transactions off the blockchain. #### See Also + - [On-Chain Scaling](#on-chain-scaling) --- ### Off-Chain State + The data of an application that is not stored on the blockchain, or is not accessible by on-chain smart contracts. #### See Also + - [On-Chain State](#on-chain-state) --- ### On-Chain Computation + A programming model where all computation by smart contracts is done on-chain by every node on the network simultaneously. Ethereum uses on-chain computation. #### See Also + - [Off-Chain Computation](#off-chain-computation) --- ### On-Chain Scaling + On-chain scaling solution refer to extending the throughput of the consensus process, or increasing network throughput as node number increases. #### See Also + - [Off-chain Scaling](#off-chain-scaling) --- ### On-Chain State + The data of an application that is stored on the blockchain and is accessible by on-chain smart contracts. Nervos provides on-chain state for all smart contracts. #### See Also + - [Off-Chain State](#off-chain-state) --- ### On-Chain Verification + A programming model where all computation is done off-chain to reduce the burden on the nodes in the network, but verification of the resulting data is done on-chain to enforce the smart contract rules created by the developer. Nervos uses off-chain computation and on-chain verification. #### See Also + - [On-Chain Computation](#on-chain-computation) --- ### Open Transaction + A signed piece of a transaction that is incomplete and invalid on its own. When combined with other signed transaction pieces can form a complete transaction which can be processed. One use of open transactions is to create the functionality required for a trustless decentalized exchange. #### See Also + - [Cryptographic Signature](#cryptographic-signature) - [Transaction](#transaction) --- ### Optimistic Rollup + A rollup of transactions that use fraud proofs to offer increased layer 2 transaction throughput while using the security and data availability provided by layer 1. #### See Also + - [Layer 1](#layer-1) - [Layer 2](#layer-2) --- ### Orphan + A shorthand name for Orphan Block. #### Synonyms + - [Orphan Block](#orphan-block) - [Uncle](#uncle) --- ### Orphan Block + An orphan block is a valid block that is not included in the main fork due to, for example, a lag within the network itself. There can be two miners who solve a block simultaneously in NC-Max. They are non-main-chain blocks, also known as stale blocks. In Nervos, orphan blocks are better described as Uncles. #### Synonyms + - [Orphan](#orphan) - [Uncle](#uncle) #### See Also + - [Block](#block) - [NC-Max](#nc-max) - [Orphan Rate](#orphan-rate) @@ -2199,15 +2591,18 @@ In Nervos, orphan blocks are better described as Uncles. --- ### Orphan Rate + A measure of the speed at which Orphan blocks occur within the blockchain network. #### See Also + - [Orphan Block](#orphan-block) - [`orphan_rate_target`](#orphan_rate_target) --- ### `orphan_rate_target` + The estimated orphan block rate specified in NC-max. Set as 2.5% in CKB. ``` @@ -2216,33 +2611,40 @@ pub(crate) const DEFAULT_ORPHAN_RATE_TARGET: (u32, u32) = (1, 40); ``` #### See Also + - [Orphan Rate](#orphan-rate) - [Orphan Block](#orphan-block) --- -### Orphan Transactions +### Orphan Transactions + Orphan transactions are those whose parental transactions are missing at the time that they are processed. These transactions are not propagated to other nodes until all of their missing parents are received, and they thus end up languishing in a local buffer until evicted or their parents are found. #### See Also + - [Orphan Block](#orphan-block) --- ### Outbound Connection + Also knowns as "outgoing connection". A TCP connection is outgoing for the node if it was initiated (sent the TCP SYN packet) by the node in the context. #### See Also + - [Inbound Connection](#inbound-connection) --- ### Outpoint + A particular output Cell in a transaction. #### See Also + - [Cell](#cell) - [Output](#output) - [Transaction](#transaction) @@ -2250,9 +2652,11 @@ A particular output Cell in a transaction. --- ### Output + A Live Cell that is created in a transaction. #### See Also + - [Cell](#cell) - [Live Cell](#live-cell) - [Transaction](#transaction) @@ -2260,31 +2664,37 @@ A Live Cell that is created in a transaction. --- ### Overlord + A byzantine fault tollerant consensus algorithm designed by Nervos for Huobi which can support thousands of transactions per second. #### See Also + - [Overlord on Medium](https://medium.com/nervosnetwork/overlord-a-new-consensus-algorithm-3cc51690d269) --- ### P2WSH + A Pay-to-Witness-Script-Hash (P2WSH) is a type of Bitcoin transaction similar to a [P2SH](https://en.bitcoin.it/wiki/Pay_to_script_hash) transaction in most ways, except that it uses [SegWit](https://en.wikipedia.org/wiki/SegWit). --- ### `permanent_difficulty_in_dummy` + Keeps the difficulty permanent if PoW is dummy when dev-chain disables NC-MAX difficulty adjustment. As `boolean`, it can be enabled through configuration. #### See Also + - [Difficulty](#difficulty) --- - ### Polyjuice + Polyjuice provides an Ethereum compatible runtime on Godwoken. #### See Also + - [Godwoken](#godwoken) - [Polyjuice on GitHub](https://github.com/nervosnetwork/polyjuice) @@ -2300,25 +2710,30 @@ pub(crate) const DEFAULT_PRIMARY_EPOCH_REWARD_HALVING_INTERVAL: EpochNumber = ``` #### See Also + - [`initial_primary_epoch_reward`](#initial_primary_epoch_reward) --- ### Proposal Zone + Section of the block that contains transaction proposals. #### See Also + - [Commitment Zone](#commitment-zone) - [Propose](#propose) --- ### Propose + The process of taking an unconfirmed transaction out of the mempool and proposing it for commitment. A transaction is not confirmed until after it has been committed. Miners are incentivized to propose transactions by being paid a proposal reward. #### See Also + - [Commit](#commit) - [Confirmation](#confirmation) - [Mempool](#mempool) @@ -2329,6 +2744,7 @@ Miners are incentivized to propose transactions by being paid a proposal reward. --- ### `proposer_reward_ratio` + The reward ratio from transaction fees for miners who submit proposals specified by NC-Max. It is set as 40% in CKB, meaning the miner who first submits the transaction proposal will be rewarded with 40% of the transaction fee. ``` @@ -2336,38 +2752,44 @@ const PROPOSER_REWARD_RATIO: Ratio = Ratio::new(4, 10); ``` #### See Also + - [Proposal Reward](#proposal-reward) - [NC-Max](#nc-max) --- - ### RISC-V + An open standard instruction set architecture (ISA) for general computing. RISC-V is the instruction set used by the CKB-VM. #### See Also + - [CKB-VM](#ckb-vm) - [RISC-V on Wikipedia](https://en.wikipedia.org/wiki/RISC-V) --- ### Schnorr Signature + A cryptographic signature scheme for signing and verification. #### See Also + - [Schnorr Signature on Wikipedia](https://en.wikipedia.org/wiki/Schnorr_signature) --- ### Script + A script in Nervos CKB is a binary executable on the CKB-VM. Compared to Bitcoin script, CKB script is Turing-complete, equivalent to smart contract. A Script can be one of two types: - Lock Script - Used to control ownership and access to a Cell. - Type Script - Used to control how a Cell is used in a transaction. #### See Also + - [CKB-VM](#risc-v) - [Lock Script](#lock-script) - [RISC-V](#risc-v) @@ -2377,7 +2799,8 @@ A script in Nervos CKB is a binary executable on the CKB-VM. Compared to Bitcoin --- ### `secondary_epoch_reward` -The secondary reward per epoch. Issued according to CKB’s tokenomics detailed in [RFC0015](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0015-ckb-cryptoeconomics/0015-ckb-cryptoeconomics.md). + +The secondary reward per epoch. Issued according to CKB’s tokenomics detailed in [RFC0015](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0015-ckb-cryptoeconomics/0015-ckb-cryptoeconomics.md). Secondary issuance is designed to collect state rent, and has an issuance amount that is constant over time. After base issuance stops, there will only be secondary issuance. @@ -2386,7 +2809,9 @@ Secondary issuance has two parts. One is a fixed amount of base incentive (appro ``` pub(crate) const DEFAULT_SECONDARY_EPOCH_REWARD: Capacity = Capacity::shannons(613_698_63013698); ``` + #### See also + - [`initial_primary_epoch_reward`](#initial_primary_epoch_reward) - [Secondary Reward](#secondary-reward) - [Secondary Issuance](#secondary-issuance) @@ -2410,19 +2835,23 @@ Find more details [here](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/ --- ### Seed Cell + A design pattern on Nervos from creating unique identifiers used to create unforgeable assets. #### See Also + - [Cell](#cell) --- ### Shannon + A fractional denomination of CKBytes. One CKByte is equal to 100,000,000 Shannons. A Shannon is the equivalent of a Bitcoin Satoshi. #### See Also + - [CKByte](#ckbyte) - [Common Knowledge Byte](#common-knowledge-byte) - [Satoshi (denomination) on Bitcoin.org](https://developer.bitcoin.org/glossary.html) @@ -2430,14 +2859,17 @@ A Shannon is the equivalent of a Bitcoin Satoshi. --- ### Short Address + An address format on Nervos that does not include a code hash of the associated lock script, instead using one of the many common lock scripts. The short address format is the most common address format used, and is often referred to as simply "address". #### Synonyms + - [Address](#address) #### See Also + - [Code Hash](#code-hash) - [Lock Script](#lock-script) - [Full Address](#full-address) @@ -2445,14 +2877,17 @@ The short address format is the most common address format used, and is often re --- ### Simple UDT -A standard that defines a the most basic implementation of a UDT fungible token on Nervos. + +A standard that defines a the most basic implementation of a UDT fungible token on Nervos. An sUDT on Nervos is the equivalent of Ethereum tokens standards ERC20 or ERC777. #### Synonyms + - [SUDT](#sudt) #### See Also + - [Token](#token) - [UDT](#udt) - [User-Defined Token](#user-defined-token) @@ -2462,59 +2897,73 @@ An sUDT on Nervos is the equivalent of Ethereum tokens standards ERC20 or ERC777 --- ### Since + `since` is the u64 (unsigned 64-bit integer) field in transaction input for preventing inclusion before a certain block timestamp or a block number. #### See Also + - [Cell](#cell) --- ### SPV + An abbreviation for Simplified Payment Verification. A protocol for using a blockchain cryptocurrency without having to operate a full node. SPV clients require far less data to be stored, but also must requires the trust of the network clients it is connected to directly. #### See Also + - [SPV Wallet](#spv-wallet) - [Simplified Payment Verification on BitcoinWiki](https://en.bitcoinwiki.org/wiki/Simplified_Payment_Verification) --- ### SPV Wallet + A light-weight cryptocurrency wallet that uses the SPV protocol. #### See Also + - [SPV](#spv) --- ### SUDT + An abbreviation for Simple UDT. #### Synonyms + - [Simple UDT](#simple-udt) --- ### Testnet + Short for “test network,” a network used to simulate the behavior of the [Mainnet](#mainnet). The name of the Nervos CKB Testnet is [Aggron](#aggron). #### Synonyms + - [Aggron](#aggron) #### Not To Be Confused With + - [Lina](#lina) - [Mainnet](#mainnet) --- + ### Transaction Confirmation Number -The number of confirmations required for a transaction to be added to a block. + +The number of confirmations required for a transaction to be added to a block. As permissionless blockchain designs offer only probabilistic finality, a transaction can never be fully confirmed, facing an adversary with infinite computational power. Therefore, users and apps can choose a number they deem secure. We briefly discuss one factor here that influences the level of security: the recent orphan rate. It takes 6 confirmations to fully settle a transaction when the orphan rate is 0, and 24 confirmations when the rate reaches 2.5% to achieve the same level of security (See the rationale and calculation [here](https://nervos-ckb-docs-git-v1-cryptape.vercel.app/docs/essays/tx-confirmation/)). In blockchain settlement assurance, transaction confirmation is one of the variables that cannot be easily quantified (See Nic Carter’s [article](https://medium.com/@nic__carter/its-the-settlement-assurances-stupid-5dcd1c3f4e41)). The exact number is open to adjustment depending on the security level that users desire. Nervos CKB sets a minimum of 15 confirmations, which should be considered conservative. #### See Also + - [Confirmation](#confirmation) - [NC-Max](#nc-max) - [Orphan Block](#orphan-block) @@ -2536,6 +2985,7 @@ table Transaction { Transaction hash is generated by the serialized `raw` structure through [ckbhash](#ckbhash). #### See Also + - [Transaction Witness Hash](#transaction-witness-hash) - [Molecule](#molecule) - [Ckbhash](#ckbhash) @@ -2555,6 +3005,7 @@ table Transaction { ``` #### See Also + - [Transaction Hash](#transaction-hash) - [Molecule](#molecule) - [Ckbhash](#ckbhash) @@ -2571,11 +3022,12 @@ ckbhash(T || W) > `ckbhash` is the hash function, `||` denotes binary concatenation. -T is the root of a [CKB Merkle Tree](#ckb-merkle-tree), which items are the [transaction hashes](#transaction-hash) of all the transactions in the block. +T is the root of a [CKB Merkle Tree](#ckb-merkle-tree), which items are the [transaction hashes](#transaction-hash) of all the transactions in the block. W is also the root of a [CKB Merkle Tree](#ckb-merkle-tree), but the items are the [Transaction Witness Hash](#transaction-witness-hash) of all the transactions in the block. #### See Also + - [Ckbhash](#ckbhash) - [CKB Merkle Tree](#ckb-merkle-tree) - [Transaction Witness Hash](#transaction-witness-hash) @@ -2583,6 +3035,7 @@ W is also the root of a [CKB Merkle Tree](#ckb-merkle-tree), but the items are t --- ### `tx_proposal_window` + Interval for submitting proposals in the second stage specified by NC-Max. Set between 2 and 10 blocks in CKB. @@ -2596,11 +3049,13 @@ pub(crate) const TX_PROPOSAL_WINDOW: ProposalWindow = ProposalWindow(2, 10); --- ### `tx_version` + The version of a transaction. This field is set to 0 and is reserved for the system. ``` pub const TX_VERSION: Version = 0; ``` + --- ### `type_id` @@ -2610,6 +3065,7 @@ One of the CKB `system_scripts`. A unique feature of Type ID is that it‘s a CK For a deeper understanding of Type ID, check out this blog post: [Introduction to CKB Script Programming 6: Type ID](https://xuejie.space/2020_02_03_introduction_to_ckb_script_programming_type_id/) (also translated into [Chinese](https://talk.nervos.org/t/ckb-type-id/4258)). #### See Also + - [Script](#script) - [Type Script](#type-script) @@ -2625,11 +3081,12 @@ The `code_hash` of `type_id`. In view of the specificity of `type_id`, `type_id_ --- - ### Type Script + A script that enforces the rules that must be followed in a transaction for a Cell to be consumed as an input or for a Cell to be created as an output. #### See Also + - [Cell](#cell) - [Lock Script](#lock-script) - [Script](#script) @@ -2645,18 +3102,18 @@ The two entities in the data structure of CKB’s Cell are `lock` and `type`. Ty Type scripts can implement economic constructs as well. NervosDAO is completely implemented as a type script with minimal support from the consensus layer. - #### See Also + - [Cell](#cell) - [Script](#script) - [Type Script](#type-script) - [Lock Script](#lock-script) - [NervosDAO](https://github.com/nervosnetwork/ckb-system-scripts/blob/66d7da8ec72dffaa7e9c55904833951eca2422a9/c/dao.c) - --- ### Uncle + Or Uncle Block. Uncle blocks are created when two blocks are mined and submitted to the ledger at roughly the same time. Only one can enter the ledger as an included block, and the other does not. Uncles are paid a reduced block reward when they are found and reported. @@ -2671,10 +3128,10 @@ An uncle block has to meet the following conditions: ``` - if !snapshot.is_main_chain(&uncle.hash()) // It should not be on the main chain. -- && !snapshot.is_uncle(&uncle.hash()) // It should not be an uncle twice. -- && uncle.number() < candidate_number // The block number of the uncle should be smaller than that of any block on the main chain. -- && (uncles.iter().any(|u| u.hash() == parent_hash) -|| snapshot.is_main_chain(&parent_hash) // Uncle block should not be parentless. The parent of un uncle must be a block on the main chain or another uncle. +- && !snapshot.is_uncle(&uncle.hash()) // It should not be an uncle twice. +- && uncle.number() < candidate_number // The block number of the uncle should be smaller than that of any block on the main chain. +- && (uncles.iter().any(|u| u.hash() == parent_hash) +|| snapshot.is_main_chain(&parent_hash) // Uncle block should not be parentless. The parent of un uncle must be a block on the main chain or another uncle. || snapshot.is_uncle(&parent_hash)) ``` @@ -2687,13 +3144,15 @@ Similarly, B4 can be the uncle of A5 (be included by A5). Although B4‘s parent C2 and C3 cannot be linked to the main chain as their parent is unknown, therefore, they cannot be uncles. #### See Also -- [`max_uncles_num`](#max_uncles_num) +- [`max_uncles_num`](#max_uncles_num) #### Synonyms + - [Orphan Block](#orphan-block) #### See Also + - [Block Interval](#block-interval) - [Orphan Rate](#orphan-rate) - [Uncle](#uncle) @@ -2703,15 +3162,18 @@ C2 and C3 cannot be linked to the main chain as their parent is unknown, therefo ### Uncle Rate #### See Also + - [Orphan Rate](#orphan-rate) - [Uncle](#uncle) --- ### Validator + A script that is used to ensure that the transactions created by the generators are valid. Validators are scripts that run in CKB-VM as either lock scripts or type scripts. #### See Also + - [CKB-VM](#ckb-vm) - [Lock Script](#lock-script) - [Type Script](#type-script) @@ -2720,14 +3182,17 @@ A script that is used to ensure that the transactions created by the generators --- ### Witness + A set of cryptographic proof containing the data required to prove authorization of the resources used in the transaction. #### See Also + - [Transaction](#transaction) --- ### XUDT + An extended UDT standard upon sUDT (Simple UDT) to accommodate additional functionalities, including regulatory compliance. Also written as Extensible UDT. #### See Also @@ -2739,11 +3204,13 @@ An extended UDT standard upon sUDT (Simple UDT) to accommodate additional functi --- ### Zk-SNARK + A form of cryptographic proof, that when used in cryptocurrencies, allows for privacy features which do not reveal the amounts or participants in transactions. Zk-SNARKs require a trusted setup, but are otherwise trustless. #### See Also + - [Transaction](#transaction) - [Zk-STARK](#zk-stark) - [Non-interactive zero-knowledge proofs on Wikipedia](https://en.wikipedia.org/wiki/Non-interactive_zero-knowledge_proof) @@ -2751,11 +3218,13 @@ Zk-SNARKs require a trusted setup, but are otherwise trustless. --- ### Zk-STARK + A form of cryptographic proof, that when used in cryptocurrencies, allows for privacy features which do not reveal the amounts or participants in transactions. Unlike Zk-SNARKs, Zk-STARKs do not require a trusted setup. #### See Also + - [Transaction](#transaction) - [Zk-SNARK](#zk-snark) - [Non-interactive zero-knowledge proofs on Wikipedia](https://en.wikipedia.org/wiki/Non-interactive_zero-knowledge_proof) diff --git a/website/docs/tech-explanation/nervos-blockchain.md b/website/docs/tech-explanation/nervos-blockchain.md index eb9d70016..9ca568495 100644 --- a/website/docs/tech-explanation/nervos-blockchain.md +++ b/website/docs/tech-explanation/nervos-blockchain.md @@ -13,12 +13,12 @@ Trade-offs are inevitable in designing any decentralized system. A common exampl An example on how layering helps improve this: -* Layer 1 focuses on security and decentralization, providing trust to higher layers. -* Layer 2 focuses on scalability, providing nearly instantaneous transactions for millions of users. +- Layer 1 focuses on security and decentralization, providing trust to higher layers. +- Layer 2 focuses on scalability, providing nearly instantaneous transactions for millions of users. These two layers function together to achieve higher levels of decentralization, security, and scalability. -The Nervos blockchain represents the layer 1 of a multi-layer architecture that prioritizes security and decentralization as core design principles. +The Nervos blockchain represents the layer 1 of a multi-layer architecture that prioritizes security and decentralization as core design principles. ## What is a CKByte? diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 2be9cfb30..6f14514cb 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -2,8 +2,8 @@ import path from "path"; import math from "remark-math"; import katex from "rehype-katex"; -const lightCodeTheme = require('./src/prism/light'); -const darkCodeTheme = require('./src/prism/dark'); +const lightCodeTheme = require("./src/prism/light"); +const darkCodeTheme = require("./src/prism/dark"); /** @type {import('@docusaurus/types').Config} */ const config = { @@ -73,10 +73,10 @@ const config = { }, docs: { path: "./docs", - breadcrumbs:false, + breadcrumbs: false, showLastUpdateTime: true, showLastUpdateAuthor: false, - sidebarPath: require.resolve('./sidebars.js'), + sidebarPath: require.resolve("./sidebars.js"), remarkPlugins: [math], rehypePlugins: [katex], editUrl: @@ -98,13 +98,13 @@ const config = { ], function myPlugin() { return { - name: 'custom-webpack-plugin', + name: "custom-webpack-plugin", configureWebpack() { return { resolve: { alias: { - '@components': path.resolve(__dirname, 'src/components'), - '@css': path.resolve(__dirname, 'src/css'), + "@components": path.resolve(__dirname, "src/components"), + "@css": path.resolve(__dirname, "src/css"), }, }, }; @@ -128,26 +128,27 @@ const config = { src: "img/logo-dark.png", width: 89, height: 32, - alt:'Nervos CKB Docs', - href:'/' + alt: "Nervos CKB Docs", + href: "/", }, items: [ { - type: 'search', - position: 'right', - className: 'navbar-search', + type: "search", + position: "right", + className: "navbar-search", }, { - type: 'html', - position: 'right', - value: 'Discord for help

Get Help

', - className: 'navbar-help' - } - ] + type: "html", + position: "right", + value: + 'Discord for help

Get Help

', + className: "navbar-help", + }, + ], }, image: "img/undraw_online.svg", footer: { - style: 'dark', + style: "dark", links: [ { title: "Foundation", diff --git a/website/sidebars.js b/website/sidebars.js index 0c5cf263a..157009915 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -9,7 +9,7 @@ export default { "getting-started/how-ckb-works", "getting-started/quick-start", "getting-started/devtool", - ] + ], }, { type: "category", @@ -21,7 +21,7 @@ export default { "dapp/write-message", "dapp/create-token", "dapp/create-dob", - ] + ], }, { type: "category", @@ -34,17 +34,14 @@ export default { "script/minimal-script", "script/js-script", "script/common-script-error-code", - ] + ], }, { type: "category", label: "Integrate Wallets", className: "category-integrate-wallets", collapsible: false, - items: [ - "integrate-wallets/intro-to-wallets", - "integrate-wallets/joyid", - ] + items: ["integrate-wallets/intro-to-wallets", "integrate-wallets/joyid"], }, { type: "category", @@ -52,12 +49,12 @@ export default { className: "category-node", collapsible: false, items: [ - "node/rpcs", - "node/run-mainnet-node", - "node/run-testnet-node", - "node/run-devnet-node", - "node/run-public-rpc-node", - ] + "node/rpcs", + "node/run-mainnet-node", + "node/run-testnet-node", + "node/run-devnet-node", + "node/run-public-rpc-node", + ], }, { type: "category", @@ -72,7 +69,7 @@ export default { "mining/hardware", "mining/guide", "mining/info-stats", - ] + ], }, { type: "category", @@ -86,16 +83,14 @@ export default { "tech-explanation/consensus", "tech-explanation/economics", "tech-explanation/glossary", - ] + ], }, { type: "category", label: "Ecosystem", className: "category-ecosystem", collapsible: false, - items: [ - "ecosystem/projects", - ] + items: ["ecosystem/projects"], }, { type: "category", @@ -117,8 +112,8 @@ export default { type: "link", label: "CKB Dev Log", href: "https://github.com/nervosnetwork/ckb/discussions/categories/dev-log", - } - ] + }, + ], }, ], }; diff --git a/website/src/components/Button/index.tsx b/website/src/components/Button/index.tsx index c3d1ad165..cc9466c7c 100644 --- a/website/src/components/Button/index.tsx +++ b/website/src/components/Button/index.tsx @@ -3,18 +3,32 @@ import Link from "@docusaurus/Link"; import styles from "./styles.module.css"; interface ButtonProps { - link: string; - internal?: boolean; - children: React.ReactNode; - className?: string; + link: string; + internal?: boolean; + children: React.ReactNode; + className?: string; } -export default function Button({ link, internal = true, children, className }:ButtonProps): JSX.Element { - if (internal) { - return ( - {children} - ) - } +export default function Button({ + link, + internal = true, + children, + className, +}: ButtonProps): JSX.Element { + if (internal) { return ( - {children} + + {children} + ); + } + return ( + + {children} + + ); } diff --git a/website/src/components/Button/styles.module.css b/website/src/components/Button/styles.module.css index d180a3f04..5d79c207b 100644 --- a/website/src/components/Button/styles.module.css +++ b/website/src/components/Button/styles.module.css @@ -1,55 +1,55 @@ -@import '@css/customVariables.css'; +@import "@css/customVariables.css"; .solidBtn { - display: flex; - align-items: center; - justify-content: center; - padding: 0 1.5rem; - color: var(--dark-text-inverse) !important; - text-decoration: none !important; - border-radius: 80px; - font-weight: bold; - font-size: 1em; - line-height: 3em; - border: none; - box-shadow: var(--dark-btn-shadow); - backdrop-filter: blur(15px); - cursor: pointer; - width: fit-content; - position: relative; - overflow: hidden; - z-index: 1; + display: flex; + align-items: center; + justify-content: center; + padding: 0 1.5rem; + color: var(--dark-text-inverse) !important; + text-decoration: none !important; + border-radius: 80px; + font-weight: bold; + font-size: 1em; + line-height: 3em; + border: none; + box-shadow: var(--dark-btn-shadow); + backdrop-filter: blur(15px); + cursor: pointer; + width: fit-content; + position: relative; + overflow: hidden; + z-index: 1; } .solidBtn:after { - content: ''; - position: absolute; - bottom: 0; - left: 0; - width: 100%; - height: 100%; - background-color: var(--dark-text-link); - border-radius: 80px; - z-index: -2; + content: ""; + position: absolute; + bottom: 0; + left: 0; + width: 100%; + height: 100%; + background-color: var(--dark-text-link); + border-radius: 80px; + z-index: -2; } .solidBtn:before { - content: ''; - position: absolute; - bottom: 0; - left: 0; - width: 0%; - height: 100%; - background-color: #5DF6C2; - transition: all 0.25s; - border-radius: 80px; - z-index: -1; + content: ""; + position: absolute; + bottom: 0; + left: 0; + width: 0%; + height: 100%; + background-color: #5df6c2; + transition: all 0.25s; + border-radius: 80px; + z-index: -1; } .solidBtn:hover:before { - width: 100%; + width: 100%; } @media (max-width: 768px) { - .solidBtn { - line-height: 2.5rem; - width: 100%; - } -} \ No newline at end of file + .solidBtn { + line-height: 2.5rem; + width: 100%; + } +} diff --git a/website/src/components/Card/index.tsx b/website/src/components/Card/index.tsx index 8b98cbf40..77b1191fe 100644 --- a/website/src/components/Card/index.tsx +++ b/website/src/components/Card/index.tsx @@ -1,60 +1,78 @@ import clsx from "clsx"; import Link from "@docusaurus/Link"; import styles from "./styles.module.css"; -import ThemedImage from '@theme/ThemedImage'; +import ThemedImage from "@theme/ThemedImage"; import { CardLinks } from "@site/src/pages/homeContents"; - export interface CardProps { - title: string; - description: string; - link: string; - type: 'tool' | 'tutorial' | 'concept'; - links?: CardLinks[]; - internal?: boolean; - className?: string; + title: string; + description: string; + link: string; + type: "tool" | "tutorial" | "concept"; + links?: CardLinks[]; + internal?: boolean; + className?: string; } -export default function Card({ title, description, link, type, links, internal = true, className }: CardProps): JSX.Element { - const props = { title, description, link, type, links, className }; - if (internal) { - return ( - - - - ) - } +export default function Card({ + title, + description, + link, + type, + links, + internal = true, + className, +}: CardProps): JSX.Element { + const props = { title, description, link, type, links, className }; + if (internal) { return ( - - - + + + ); + } + return ( + + + + ); } function CardContent({ title, description, type, links }: CardProps) { - return ( - <> -
- -
-
-

{title}

- {links && links.length > 0 && ( -
- {links.map((link, index) => ( - - {link.label} - - ))} -
- )} -

{description}

-
- - ); -} \ No newline at end of file + return ( + <> +
+ +
+
+

{title}

+ {links && links.length > 0 && ( +
+ {links.map((link, index) => ( + + {link.label} + + ))} +
+ )} +

{description}

+
+ + ); +} diff --git a/website/src/components/Card/styles.module.css b/website/src/components/Card/styles.module.css index 58e2d1c58..ed08944d1 100644 --- a/website/src/components/Card/styles.module.css +++ b/website/src/components/Card/styles.module.css @@ -1,4 +1,4 @@ -@import '@css/customVariables.css'; +@import "@css/customVariables.css"; .cardContainer { width: 100%; @@ -42,4 +42,4 @@ } .links > a:not(:last-child) { margin-right: 1rem; -} \ No newline at end of file +} diff --git a/website/src/components/CardLayout/index.tsx b/website/src/components/CardLayout/index.tsx index 0843d452d..dca6c0337 100644 --- a/website/src/components/CardLayout/index.tsx +++ b/website/src/components/CardLayout/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React from "react"; import styles from "./styles.module.css"; interface CardLayoutProps { @@ -8,17 +8,24 @@ interface CardLayoutProps { gap?: number; } -const CardLayout: React.FC = ({ children, topMargin = 16, colNum = [2, 1, 2, 1], gap = 24 }) => { +const CardLayout: React.FC = ({ + children, + topMargin = 16, + colNum = [2, 1, 2, 1], + gap = 24, +}) => { return ( -
{children} @@ -26,4 +33,4 @@ const CardLayout: React.FC = ({ children, topMargin = 16, colNu ); }; -export default CardLayout; \ No newline at end of file +export default CardLayout; diff --git a/website/src/components/CardLayout/styles.module.css b/website/src/components/CardLayout/styles.module.css index b1c4c8fa2..e3878ab46 100644 --- a/website/src/components/CardLayout/styles.module.css +++ b/website/src/components/CardLayout/styles.module.css @@ -2,23 +2,44 @@ display: grid; width: 100%; grid-gap: var(--gap); - grid-template-columns: repeat(var(--columnL), minmax(0, calc((100% - (var(--columnL) - 1) * var(--gap)) / var(--columnL)))); + grid-template-columns: repeat( + var(--columnL), + minmax(0, calc((100% - (var(--columnL) - 1) * var(--gap)) / var(--columnL))) + ); } @media (min-width: 997px) and (max-width: 1439px) { .layoutContainer { - grid-template-columns: repeat(var(--columnM), minmax(0, calc((100% - (var(--columnM) - 1) * var(--gap)) / var(--columnM)))); + grid-template-columns: repeat( + var(--columnM), + minmax( + 0, + calc((100% - (var(--columnM) - 1) * var(--gap)) / var(--columnM)) + ) + ); } } @media (min-width: 769px) and (max-width: 996px) { .layoutContainer { - grid-template-columns: repeat(var(--columnS), minmax(0, calc((100% - (var(--columnS) - 1) * var(--gap)) / var(--columnS)))); + grid-template-columns: repeat( + var(--columnS), + minmax( + 0, + calc((100% - (var(--columnS) - 1) * var(--gap)) / var(--columnS)) + ) + ); } } @media (max-width: 768px) { .layoutContainer { - grid-template-columns: repeat(var(--columnXS), minmax(0, calc((100% - (var(--columnXS) - 1) * var(--gap)) / var(--columnXS)))); + grid-template-columns: repeat( + var(--columnXS), + minmax( + 0, + calc((100% - (var(--columnXS) - 1) * var(--gap)) / var(--columnXS)) + ) + ); } -} \ No newline at end of file +} diff --git a/website/src/components/CookieConsent/index.tsx b/website/src/components/CookieConsent/index.tsx index 50c05507e..6859c0810 100644 --- a/website/src/components/CookieConsent/index.tsx +++ b/website/src/components/CookieConsent/index.tsx @@ -1,37 +1,38 @@ -import React, { useState, useEffect } from 'react'; -import styles from './styles.module.css'; +import React, { useState, useEffect } from "react"; +import styles from "./styles.module.css"; const CookieConsent: React.FC = () => { - const [isVisible, setIsVisible] = useState(false); + const [isVisible, setIsVisible] = useState(false); - useEffect(() => { - // Check if the user has already given consent - const consent = localStorage.getItem('cookieConsent'); - if (consent !== 'given') { - setIsVisible(true); - } - }, []); + useEffect(() => { + // Check if the user has already given consent + const consent = localStorage.getItem("cookieConsent"); + if (consent !== "given") { + setIsVisible(true); + } + }, []); - const handleAccept = () => { - // Store the consent in localStorage - localStorage.setItem('cookieConsent', 'given'); - setIsVisible(false); - }; - if (!isVisible) return null; + const handleAccept = () => { + // Store the consent in localStorage + localStorage.setItem("cookieConsent", "given"); + setIsVisible(false); + }; + if (!isVisible) return null; - return ( -
-
-

We use cookies

-
- We use cookies and other tracking technologies to improve your browsing experience on our doc. -
-
- + return ( +
+
+

We use cookies

+
+ We use cookies and other tracking technologies to improve your + browsing experience on our doc.
- ); +
+ +
+ ); }; export default CookieConsent; diff --git a/website/src/components/CookieConsent/styles.module.css b/website/src/components/CookieConsent/styles.module.css index eeb3d3391..0e567e2ba 100644 --- a/website/src/components/CookieConsent/styles.module.css +++ b/website/src/components/CookieConsent/styles.module.css @@ -1,46 +1,46 @@ .cookieBanner { - position: fixed; - bottom: 0px; - right: 0px; - background-color: var(--dark-surface-01); - padding: 1.25rem 4rem; - z-index: 1000; - width: 100%; - border: 1px solid var(--dark-border-invisible); - display: flex; - justify-content: space-between; - align-items: end; + position: fixed; + bottom: 0px; + right: 0px; + background-color: var(--dark-surface-01); + padding: 1.25rem 4rem; + z-index: 1000; + width: 100%; + border: 1px solid var(--dark-border-invisible); + display: flex; + justify-content: space-between; + align-items: end; } .text { - margin-right: 2rem; + margin-right: 2rem; } .description { - color: var(--dark-text-secondary); + color: var(--dark-text-secondary); } .button { - height: 2rem; - padding: 0 1rem; - line-height: 2rem; - background-color: var(--dark-text-link); - font-size: 0.875rem; - color: var(--dark-text-inverse); - border: none; - border-radius: 8px; - cursor: pointer; + height: 2rem; + padding: 0 1rem; + line-height: 2rem; + background-color: var(--dark-text-link); + font-size: 0.875rem; + color: var(--dark-text-inverse); + border: none; + border-radius: 8px; + cursor: pointer; } @media (max-width: 768px) { - .cookieBanner { - flex-direction: column; - align-items: start; - padding: 1rem; - } - .text { - margin-right: 0; - margin-bottom: 1rem; - } - .button { - width: 100%; - } -} \ No newline at end of file + .cookieBanner { + flex-direction: column; + align-items: start; + padding: 1rem; + } + .text { + margin-right: 0; + margin-bottom: 1rem; + } + .button { + width: 100%; + } +} diff --git a/website/src/components/EcoCard/index.tsx b/website/src/components/EcoCard/index.tsx index 15490d8e9..c984206b3 100644 --- a/website/src/components/EcoCard/index.tsx +++ b/website/src/components/EcoCard/index.tsx @@ -1,48 +1,72 @@ import clsx from "clsx"; import Link from "@docusaurus/Link"; -import ThemedImage from '@theme/ThemedImage'; +import ThemedImage from "@theme/ThemedImage"; import styles from "./styles.module.css"; import { CardLinks } from "@site/src/pages/homeContents"; export interface EcoCardProps { - title: string; - description: string; - href: string; - bannerSrc: string; - tags: string[]; - links: CardLinks[]; - className?: string; + title: string; + description: string; + href: string; + bannerSrc: string; + tags: string[]; + links: CardLinks[]; + className?: string; } -export default function EcoCard({ title, description, href, bannerSrc, tags, links, className }: EcoCardProps): JSX.Element { - return ( - -
- {bannerSrc} -
-
-

{title}

-
- {tags.map((tag) => ( -
{tag}
- ))} -
-

{description}

-
- {links.map((link, index) => ( - - - - ))} -
-
- - ); -} \ No newline at end of file +export default function EcoCard({ + title, + description, + href, + bannerSrc, + tags, + links, + className, +}: EcoCardProps): JSX.Element { + return ( + +
+ {bannerSrc} +
+
+

{title}

+
+ {tags.map((tag) => ( +
{tag}
+ ))} +
+

{description}

+
+ {links.map((link, index) => ( + + + + ))} +
+
+ + ); +} diff --git a/website/src/components/EcoCard/styles.module.css b/website/src/components/EcoCard/styles.module.css index 7d2092c7e..cf748948c 100644 --- a/website/src/components/EcoCard/styles.module.css +++ b/website/src/components/EcoCard/styles.module.css @@ -1,4 +1,4 @@ -@import '@css/customVariables.css'; +@import "@css/customVariables.css"; .cardContainer { width: 100%; @@ -67,7 +67,9 @@ overflow: hidden; text-overflow: ellipsis; } -.title, .description, .tagList { +.title, +.description, +.tagList { margin-bottom: 0.5rem; } .links { @@ -90,4 +92,4 @@ } .iconContainer:hover { background-color: var(--surface-03-hover); -} \ No newline at end of file +} diff --git a/website/src/components/Home/index.tsx b/website/src/components/Home/index.tsx index 1a25b0079..e5d0735aa 100644 --- a/website/src/components/Home/index.tsx +++ b/website/src/components/Home/index.tsx @@ -6,260 +6,382 @@ import CardLayout from "../CardLayout"; import Link from "@docusaurus/Link"; import EcoCard, { EcoCardProps } from "../EcoCard"; import Button from "../Button"; -import { contactUsContents, devToolSectionContents, homeCardContents } from "../../pages/homeContents"; +import { + contactUsContents, + devToolSectionContents, + homeCardContents, +} from "../../pages/homeContents"; import { walletCardContents } from "../../../docs/integrate-wallets/CardContents"; import ecoCardContents from "../../../docs/ecosystem/EcoCardContents"; - interface EcoSectionProps { - title: string; - icon: 'wallet' | 'project' | 'tool'; - topMargin?: number; - children: React.ReactNode; + title: string; + icon: "wallet" | "project" | "tool"; + topMargin?: number; + children: React.ReactNode; } // Card componnet at the top of the home page function HomeCardSection() { - return ( - - {homeCardContents.map((card, index)=> -
-
- sparkles decoration -
-
- {card.icon}/ -
-

{card.title}

-
- {card.links.map((link, index) => ( - - {link.label} - {"Navigate - - ))} -
-
- )} -
- ); + return ( + + {homeCardContents.map((card, index) => ( +
+
+ sparkles decoration +
+
+ {card.icon} +
+

{card.title}

+
+ {card.links.map((link, index) => ( + + {link.label} + {"Navigate + + ))} +
+
+ ))} +
+ ); } // General Component for Ecosytem section -function EcoSection({title, icon, topMargin = 0, children}: EcoSectionProps): JSX.Element { - return ( -
-
-
- {icon} -
-

{title}

-
- {children} +function EcoSection({ + title, + icon, + topMargin = 0, + children, +}: EcoSectionProps): JSX.Element { + return ( +
+
+
+ {icon}
- ); +

{title}

+
+ {children} +
+ ); } // Wallet - A subsection under Ecosystem section function WalletDisplay(): JSX.Element { - const [currentTag, setCurrentTag] = useState('All'); + const [currentTag, setCurrentTag] = useState("All"); const [tags, setTags] = useState([]); const [filteredCards, setFilteredCards] = useState([]); // Generate a list of unique tags useEffect(() => { - const tagsArray: string[] = []; - walletCardContents.forEach(card => { - card.tags.forEach(tag => { - if (!tagsArray.includes(tag)) { - tagsArray.push(tag); // Add tag if not already included - } - }); + const tagsArray: string[] = []; + walletCardContents.forEach((card) => { + card.tags.forEach((tag) => { + if (!tagsArray.includes(tag)) { + tagsArray.push(tag); // Add tag if not already included + } }); - setTags(tagsArray); + }); + setTags(tagsArray); }, [walletCardContents]); // Filter cards based on the currentTag useEffect(() => { - setFilteredCards(currentTag === 'All' ? walletCardContents : walletCardContents.filter(card => card.tags.includes(currentTag))); + setFilteredCards( + currentTag === "All" + ? walletCardContents + : walletCardContents.filter((card) => card.tags.includes(currentTag)) + ); }, [currentTag, walletCardContents]); // Render filters and cards return ( - -
-
- - {tags.map((tag, index) => ( - - ))} -
- - {filteredCards.map((card, index) => ( - - ))} - + +
+
+ + {tags.map((tag, index) => ( + + ))}
- View wallets → + + {filteredCards.map((card, index) => ( + + ))} + +
+ + View wallets → +
); } // Dev Tool - A subsection under Ecosystem section function ToolDisplay(): JSX.Element { - // Render filters and cards - return ( - - -
-
Development & Deployment
-
- {devToolSectionContents - .filter(tool => tool.category === 'Development & Deployment') - .map((tool, index) => ( - {tool.title} - ))} -
-
-
-
Utilities & Testing
-
- {devToolSectionContents - .filter(tool => tool.category === 'Utilities & Testing') - .map((tool, index) => ( - {tool.title} - ))} -
-
-
- View dev tools → -
- ); + // Render filters and cards + return ( + + +
+
+ Development & Deployment +
+
+ {devToolSectionContents + .filter((tool) => tool.category === "Development & Deployment") + .map((tool, index) => ( + + {tool.title} + + ))} +
+
+
+
+ Utilities & Testing +
+
+ {devToolSectionContents + .filter((tool) => tool.category === "Utilities & Testing") + .map((tool, index) => ( + + {tool.title} + + ))} +
+
+
+ View dev tools → +
+ ); } function ProjectDisplay(): JSX.Element { - const [filteredContent, setFilteredContent] = useState([]); - const [currentIndex, setCurrentIndex] = useState(0); - const [windowWidth, setWindowWidth] = useState(0); + const [filteredContent, setFilteredContent] = useState([]); + const [currentIndex, setCurrentIndex] = useState(0); + const [windowWidth, setWindowWidth] = useState(0); - useEffect(() => { - function updateDimensions() { - setWindowWidth(window.innerWidth); - } - updateDimensions(); // Set initial size at client-side - window.addEventListener('resize', updateDimensions); - return () => window.removeEventListener('resize', updateDimensions); - }, []); + useEffect(() => { + function updateDimensions() { + setWindowWidth(window.innerWidth); + } + updateDimensions(); // Set initial size at client-side + window.addEventListener("resize", updateDimensions); + return () => window.removeEventListener("resize", updateDimensions); + }, []); - const getCardsToShow = (): number => { - if (windowWidth >= 996) { - return 3; // for >=996px - } else if (windowWidth >= 769) { - return 2; // for 768px to 996px - } - return 1; - }; + const getCardsToShow = (): number => { + if (windowWidth >= 996) { + return 3; // for >=996px + } else if (windowWidth >= 769) { + return 2; // for 768px to 996px + } + return 1; + }; - const cardsToShow = getCardsToShow(); + const cardsToShow = getCardsToShow(); - const goToPrevious = () => { - setCurrentIndex((prevIndex) => - prevIndex > 0 ? prevIndex - 1 : filteredContent.length - 1 - ); - }; + const goToPrevious = () => { + setCurrentIndex((prevIndex) => + prevIndex > 0 ? prevIndex - 1 : filteredContent.length - 1 + ); + }; - const goToNext = () => { - setCurrentIndex((prevIndex) => - prevIndex + 1 < filteredContent.length ? prevIndex + 1 : 0 - ); - }; + const goToNext = () => { + setCurrentIndex((prevIndex) => + prevIndex + 1 < filteredContent.length ? prevIndex + 1 : 0 + ); + }; - useEffect(() => { - const filtered = ecoCardContents.filter( - (content) => !content.tags.includes('Wallet') - ); - setFilteredContent(filtered); - }, []); + useEffect(() => { + const filtered = ecoCardContents.filter( + (content) => !content.tags.includes("Wallet") + ); + setFilteredContent(filtered); + }, []); - // Creating a looped set of cards - const items = []; - if (filteredContent && filteredContent.length > 0) { - for (let i = 0; i < cardsToShow; i++) { - items.push(filteredContent[(currentIndex + i) % filteredContent.length]); - } + // Creating a looped set of cards + const items = []; + if (filteredContent && filteredContent.length > 0) { + for (let i = 0; i < cardsToShow; i++) { + items.push(filteredContent[(currentIndex + i) % filteredContent.length]); } + } - return ( - -
- - {items?.map((card, index) => ( - - ))} - -
-
- - - -
-
- ); + return ( + +
+ + {items?.map((card, index) => ( + + ))} + +
+
+ + + +
+
+ ); } function DevLogSection(): JSX.Element { - return ( -
-
-
-

Discover Dev Log

-
Dive into the continuous evolution of the Nervos CKB through our Dev Log, where we document the journey of innovation, feature enhancements, and the collaborative efforts that drive the ecosystem forward.
- -
-
- {'dev -
-
+ return ( +
+
+
+

Discover Dev Log

+
+ Dive into the continuous evolution of the Nervos CKB through our Dev + Log, where we document the journey of innovation, feature + enhancements, and the collaborative efforts that drive the ecosystem + forward. +
+ +
+
+ {"dev
- ) +
+
+ ); } function ContactUsSection(): JSX.Element { - return ( -
-

Contact us:

-
- {contactUsContents.map((media, index) => ( - - {media.label} - - ))} -
-
- ) + return ( +
+

Contact us:

+
+ {contactUsContents.map((media, index) => ( + + {media.label} + + ))} +
+
+ ); } -export { HomeCardSection, EcoSection, WalletDisplay, ToolDisplay, ProjectDisplay, DevLogSection, ContactUsSection } \ No newline at end of file +export { + HomeCardSection, + EcoSection, + WalletDisplay, + ToolDisplay, + ProjectDisplay, + DevLogSection, + ContactUsSection, +}; diff --git a/website/src/components/Home/styles.module.css b/website/src/components/Home/styles.module.css index bd1b51fac..b7eaea921 100644 --- a/website/src/components/Home/styles.module.css +++ b/website/src/components/Home/styles.module.css @@ -1,284 +1,286 @@ -@import '@css/customVariables.css'; +@import "@css/customVariables.css"; /* General styling */ .section { - background: var(--dark-card-bg); - border-radius: 40px; - box-shadow: var(--dark-card-shadow); - padding: 2.5rem; - z-index: 1; - width: 100%; - position: relative; + background: var(--dark-card-bg); + border-radius: 40px; + box-shadow: var(--dark-card-shadow); + padding: 2.5rem; + z-index: 1; + width: 100%; + position: relative; } .section::before { - content: ""; - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - background-image: url('/img/bg-noise.webp'); - background-position: center; - background-size: cover; - background-repeat: repeat; - opacity: 0.5; - z-index: -1; + content: ""; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-image: url("/img/bg-noise.webp"); + background-position: center; + background-size: cover; + background-repeat: repeat; + opacity: 0.5; + z-index: -1; } .flexCol { - display:flex; - flex-direction: column; - gap: 2.5rem; + display: flex; + flex-direction: column; + gap: 2.5rem; } .noGap { - gap: 0; + gap: 0; } .flexCenter { - display: flex; - align-items: center; - gap: 1rem; + display: flex; + align-items: center; + gap: 1rem; } .flexBetween { - display: flex; - justify-content: space-between; - align-items: center; + display: flex; + justify-content: space-between; + align-items: center; } .flexWrap { - display: flex; - flex-wrap: wrap; + display: flex; + flex-wrap: wrap; } .alignMiddle { - justify-content: center; + justify-content: center; } .iconContainer { - display: flex; - align-items: center; - justify-content: center; - object-fit: fill; - width: 4rem; - height: 4rem; + display: flex; + align-items: center; + justify-content: center; + object-fit: fill; + width: 4rem; + height: 4rem; } .iconContainer img { - max-width: fit-content; + max-width: fit-content; } -.section h3, .section h2, .section h1{ - margin: 0; - color: var(--dark-text-primary); +.section h3, +.section h2, +.section h1 { + margin: 0; + color: var(--dark-text-primary); } -.section a { - margin: 0; +.section a { + margin: 0; } - /* Home card used in header section */ .homeCard { - color: var(--dark-text-primary); - position: relative; + color: var(--dark-text-primary); + position: relative; } .sparkles { - position: absolute; - display: none; - right: 1.25rem; - top: 1.25rem; + position: absolute; + display: none; + right: 1.25rem; + top: 1.25rem; } .homeCard:hover { - transition: 0.2s; + transition: 0.2s; } .homeCard:hover .sparkles { - display: block; + display: block; } .cardTitle { - margin-top: 1.5rem; - margin-bottom: 3rem; + margin-top: 1.5rem; + margin-bottom: 3rem; } .cardLinks { - margin-top: 1.25rem; - margin-left: -0.5rem; - margin-right: -0.5rem; + margin-top: 1.25rem; + margin-left: -0.5rem; + margin-right: -0.5rem; } .cardLinks > .borderBtm:not(:last-child) { - border-bottom: 1px solid var(--dark-border-subtle); + border-bottom: 1px solid var(--dark-border-subtle); } .link { - line-height: 3rem; - color: var(--dark-text-secondary) !important; - text-decoration: none !important; + line-height: 3rem; + color: var(--dark-text-secondary) !important; + text-decoration: none !important; } .line { - cursor: pointer; - padding: 0 0.5rem; + cursor: pointer; + padding: 0 0.5rem; } .line:hover { - background-color: var(--dark-hover); - border-radius: 2px; + background-color: var(--dark-hover); + border-radius: 2px; } /* wallet section specific */ .filters { - width: 100%; - display: flex; - align-items: center; - flex-wrap: wrap; + width: 100%; + display: flex; + align-items: center; + flex-wrap: wrap; } .tag { - display: flex; - align-items: center; - justify-content: center; - height: 2rem; - font-size: 0.875rem; - background-color: var(--dark-surface-03); - color: var(--dark-text-tertiary); - line-height: 2rem; - border-radius: 32px; - border: 1px solid var(--dark-border-subtle); - box-shadow: none; - cursor: pointer; - margin: 0 1rem 1rem 0; - padding: 0 0.75rem; + display: flex; + align-items: center; + justify-content: center; + height: 2rem; + font-size: 0.875rem; + background-color: var(--dark-surface-03); + color: var(--dark-text-tertiary); + line-height: 2rem; + border-radius: 32px; + border: 1px solid var(--dark-border-subtle); + box-shadow: none; + cursor: pointer; + margin: 0 1rem 1rem 0; + padding: 0 0.75rem; } .tag:hover { - background-color: var(--dark-surface-03-hover); + background-color: var(--dark-surface-03-hover); } .activeTag { - background-color: var(--dark-alert-success-bg) !important; - border: 1px solid var(--dark-alert-success); - color: var(--dark-text-primary); + background-color: var(--dark-alert-success-bg) !important; + border: 1px solid var(--dark-alert-success); + color: var(--dark-text-primary); } /* Dev tools section specific */ .tableContainer { - display: flex; - justify-content: space-between; + display: flex; + justify-content: space-between; } .column { - display: flex; - flex-direction: column; - color: var(--dark-text-primary); - flex: 1; + display: flex; + flex-direction: column; + color: var(--dark-text-primary); + flex: 1; } .cell { - border: 1px solid var(--dark-border-subtle); - height: 3.5rem; - line-height: 3.5rem; - display: flex; - align-items: center; - justify-content: center; - cursor: pointer; - text-decoration: none !important; - color: var(--dark-text-primary); - font-weight: bold; - flex: 1 1 50%; + border: 1px solid var(--dark-border-subtle); + height: 3.5rem; + line-height: 3.5rem; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + text-decoration: none !important; + color: var(--dark-text-primary); + font-weight: bold; + flex: 1 1 50%; } .cell:hover { - background-color: var(--dark-hover); - border-color: var(--dark-border-accent); + background-color: var(--dark-hover); + border-color: var(--dark-border-accent); } .columnHeader { - background-color: var(--dark-surface-03) !important; - border: 1px solid var(--dark-border-subtle) !important; - color: var(--dark-text-secondary); - cursor: default; + background-color: var(--dark-surface-03) !important; + border: 1px solid var(--dark-border-subtle) !important; + color: var(--dark-text-secondary); + cursor: default; } /* Project Display specific */ .carouselContainer { - width: 100%; + width: 100%; } .carouselController { - gap: 0.5rem; -} -.arrowLeft, .arrowRight { - width: 3rem; - min-width: 3rem; - height: 3rem; - display: flex; - align-items: center; - justify-content: center; - border: none; - cursor: pointer; - color: var(--dark-text-primary); - background: var(--dark-surface-03); - border-radius: 50%; -} -.arrowLeft:hover, .arrowRight:hover{ - background: var(--dark-surface-03-hover); + gap: 0.5rem; +} +.arrowLeft, +.arrowRight { + width: 3rem; + min-width: 3rem; + height: 3rem; + display: flex; + align-items: center; + justify-content: center; + border: none; + cursor: pointer; + color: var(--dark-text-primary); + background: var(--dark-surface-03); + border-radius: 50%; +} +.arrowLeft:hover, +.arrowRight:hover { + background: var(--dark-surface-03-hover); } .arrowLeft { - transform: scaleX(-1); + transform: scaleX(-1); } /* Dev Log specific */ .illusContainer { - width: 418px; + width: 418px; } .leftContainer { - max-width: 50%; + max-width: 50%; } .description { - color: var(--dark-text-secondary); + color: var(--dark-text-secondary); } /* contact section specific */ .contactSection { - background: linear-gradient(87deg, #00CE88 -2.44%, #04E7F4 98.1%); - box-shadow: var(--dark-btn-shadow); - backdrop-filter: blur(15px); + background: linear-gradient(87deg, #00ce88 -2.44%, #04e7f4 98.1%); + box-shadow: var(--dark-btn-shadow); + backdrop-filter: blur(15px); } .contactTitle { - color: var(--dark-text-inverse) !important; + color: var(--dark-text-inverse) !important; } .icons { - flex-wrap: wrap; - justify-content: center; + flex-wrap: wrap; + justify-content: center; } .iconBG { - display: flex; - align-items: center; - justify-content: center; - width: 3.5rem; - height: 3.5rem; - background-color: #F8FDFF; - border-radius: 50%; - cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + width: 3.5rem; + height: 3.5rem; + background-color: #f8fdff; + border-radius: 50%; + cursor: pointer; } .iconBG:hover { - background-color: #EEFCFD; + background-color: #eefcfd; } /* Responsiveness */ @media (max-width: 996px) { - .illusContainer { - width: 100%; - } - .devlogSection { - flex-direction: column-reverse; - align-items: start; - } - .leftContainer { - max-width: 100%; - } - .contactSection { - flex-direction: column; - gap: 1.25rem; - } + .illusContainer { + width: 100%; + } + .devlogSection { + flex-direction: column-reverse; + align-items: start; + } + .leftContainer { + max-width: 100%; + } + .contactSection { + flex-direction: column; + gap: 1.25rem; + } } @media (max-width: 768px) { - .section { - padding: 2.5rem 1.25rem; - border-radius: 20px; - } - .flexCol { - gap: 1.25rem; - } - .solidBtn { - line-height: 2.5rem; - width: 100%; - } - .arrowLeft, .arrowRight { - width: 2.5rem; - min-width: 2.5rem; - height: 2.5rem; - } + .section { + padding: 2.5rem 1.25rem; + border-radius: 20px; + } + .flexCol { + gap: 1.25rem; + } + .solidBtn { + line-height: 2.5rem; + width: 100%; + } + .arrowLeft, + .arrowRight { + width: 2.5rem; + min-width: 2.5rem; + height: 2.5rem; + } } - - diff --git a/website/src/components/ImgContainer/index.tsx b/website/src/components/ImgContainer/index.tsx index 295224475..a2cc3f04a 100644 --- a/website/src/components/ImgContainer/index.tsx +++ b/website/src/components/ImgContainer/index.tsx @@ -1,14 +1,17 @@ import styles from "./styles.module.css"; interface ImgContainerProps { - alt?: string; - src: string; + alt?: string; + src: string; } -export default function ImgContaienr({ alt, src }: ImgContainerProps): JSX.Element { - return ( -
- {alt} -
- ); -} \ No newline at end of file +export default function ImgContaienr({ + alt, + src, +}: ImgContainerProps): JSX.Element { + return ( +
+ {alt} +
+ ); +} diff --git a/website/src/components/ImgContainer/styles.module.css b/website/src/components/ImgContainer/styles.module.css index ffbd9f7fd..484c9bc78 100644 --- a/website/src/components/ImgContainer/styles.module.css +++ b/website/src/components/ImgContainer/styles.module.css @@ -1,10 +1,10 @@ .imgContainer { - width: 100%; - height: auto; - border-radius: 20px; - background: linear-gradient(87deg, #A1E1BC -2.44%, #73F7FF 98.1%); - display: flex; - align-items: center; - justify-content: center; - padding: 1rem; -} \ No newline at end of file + width: 100%; + height: auto; + border-radius: 20px; + background: linear-gradient(87deg, #a1e1bc -2.44%, #73f7ff 98.1%); + display: flex; + align-items: center; + justify-content: center; + padding: 1rem; +} diff --git a/website/src/components/TagFilter/index.tsx b/website/src/components/TagFilter/index.tsx index c8607a2e1..fd58bcf7a 100644 --- a/website/src/components/TagFilter/index.tsx +++ b/website/src/components/TagFilter/index.tsx @@ -1,37 +1,41 @@ -import React, { useState, useEffect } from 'react'; -import clsx from 'clsx'; -import EcoCard, { EcoCardProps } from '../EcoCard'; -import CardLayout from '../CardLayout'; +import React, { useState, useEffect } from "react"; +import clsx from "clsx"; +import EcoCard, { EcoCardProps } from "../EcoCard"; +import CardLayout from "../CardLayout"; import styles from "./styles.module.css"; - interface TagFilterProps { cardData: EcoCardProps[]; } const TagFilter: React.FC = ({ cardData }) => { - const [currentTag, setCurrentTag] = useState('All'); + const [currentTag, setCurrentTag] = useState("All"); const [tags, setTags] = useState>({}); const [filteredCards, setFilteredCards] = useState([]); // Compute unique tags and their counts useEffect(() => { - const tagCounts = cardData.reduce((acc: Record, card: EcoCardProps) => { - card.tags.forEach(tag => { - acc[tag] = (acc[tag] || 0) + 1; - }); - return acc; - }, {}); + const tagCounts = cardData.reduce( + (acc: Record, card: EcoCardProps) => { + card.tags.forEach((tag) => { + acc[tag] = (acc[tag] || 0) + 1; + }); + return acc; + }, + {} + ); setTags(tagCounts); }, [cardData]); // Filter cards based on the currentTag useEffect(() => { - if (currentTag === 'All') { + if (currentTag === "All") { setFilteredCards(cardData); } else { - const filtered = cardData.filter(card => card.tags.includes(currentTag)); + const filtered = cardData.filter((card) => + card.tags.includes(currentTag) + ); setFilteredCards(filtered); } }, [currentTag, cardData]); @@ -40,12 +44,19 @@ const TagFilter: React.FC = ({ cardData }) => { return (
- {Object.entries(tags).map(([tag, count]) => ( -
diff --git a/website/src/components/TagFilter/styles.module.css b/website/src/components/TagFilter/styles.module.css index 99460fd5c..4f2f76472 100644 --- a/website/src/components/TagFilter/styles.module.css +++ b/website/src/components/TagFilter/styles.module.css @@ -1,31 +1,31 @@ -@import '@css/customVariables.css'; +@import "@css/customVariables.css"; .filters { - width: 100%; - display: flex; - align-items: center; - flex-wrap: wrap; + width: 100%; + display: flex; + align-items: center; + flex-wrap: wrap; } .tag { - display: flex; - align-items: center; - justify-content: center; - font-size: 0.875em; - background-color: var(--surface-03); - color: var(--text-tertiary); - line-height: 170%; - border-radius: 4px; - border: none; - box-shadow: none; - cursor: pointer; - margin: 0 1rem 1rem 0; - padding: 0.25rem 0.5rem; + display: flex; + align-items: center; + justify-content: center; + font-size: 0.875em; + background-color: var(--surface-03); + color: var(--text-tertiary); + line-height: 170%; + border-radius: 4px; + border: none; + box-shadow: none; + cursor: pointer; + margin: 0 1rem 1rem 0; + padding: 0.25rem 0.5rem; } .tag:hover { - background-color: var(--surface-03-hover); + background-color: var(--surface-03-hover); } .activeTag { - background-color: var(--text-link) !important; - color: var(--text-inverse); -} \ No newline at end of file + background-color: var(--text-link) !important; + color: var(--text-inverse); +} diff --git a/website/src/components/TutorialHeader/index.tsx b/website/src/components/TutorialHeader/index.tsx index 713165fbb..c743b8ea0 100644 --- a/website/src/components/TutorialHeader/index.tsx +++ b/website/src/components/TutorialHeader/index.tsx @@ -17,10 +17,13 @@ export default function TutorialHeader({ return (

Tutorial Overview

-
⏰ Estimated Time: {time}
- {topics && +
+ ⏰ Estimated Time: + {time} +
+ {topics && (
- 💡 Topics: + 💡 Topics: {topics.map((topic, index) => ( {index > 0 && ", "} @@ -28,8 +31,10 @@ export default function TutorialHeader({ ))}
- } -
🔧 Tools You Need:
+ )} +
+ 🔧 Tools You Need: +
    {tools.map((list, index) => (
  • {list}
  • diff --git a/website/src/components/TutorialHeader/styles.module.css b/website/src/components/TutorialHeader/styles.module.css index c655e44d8..f96c528ce 100644 --- a/website/src/components/TutorialHeader/styles.module.css +++ b/website/src/components/TutorialHeader/styles.module.css @@ -1,6 +1,6 @@ -@import '@css/customVariables.css'; +@import "@css/customVariables.css"; -.box{ +.box { border-radius: 20px; padding: 1.5rem; text-decoration: none !important; diff --git a/website/src/components/WalletCard/index.tsx b/website/src/components/WalletCard/index.tsx index 330a30776..13aa3e5e3 100644 --- a/website/src/components/WalletCard/index.tsx +++ b/website/src/components/WalletCard/index.tsx @@ -3,39 +3,56 @@ import Link from "@docusaurus/Link"; import styles from "./styles.module.css"; export interface WalletCardProps { - title: string; - href: string; - tags: string[]; - size?: 'default' | "small"; - className?: string; + title: string; + href: string; + tags: string[]; + size?: "default" | "small"; + className?: string; } -export default function WalletCard({ title, href, tags, size = 'default', className }: WalletCardProps): JSX.Element { - const logoSrc = title.toLowerCase().replace(/\s+/g, ''); - const logoSize = size === 'default' ? 48 : 32; - return ( - -
    - {`logo -
    -
    -
    {title}
    - {size === 'default' && -
    - {tags.map((tag, index) =>

    {tag}

    )} -
    - } -
    - - ); -} \ No newline at end of file +export default function WalletCard({ + title, + href, + tags, + size = "default", + className, +}: WalletCardProps): JSX.Element { + const logoSrc = title.toLowerCase().replace(/\s+/g, ""); + const logoSize = size === "default" ? 48 : 32; + return ( + +
    + {`logo +
    +
    +
    {title}
    + {size === "default" && ( +
    + {tags.map((tag, index) => ( +

    + {tag} +

    + ))} +
    + )} +
    + + ); +} diff --git a/website/src/components/WalletCard/styles.module.css b/website/src/components/WalletCard/styles.module.css index 6cfaa8fed..49817b781 100644 --- a/website/src/components/WalletCard/styles.module.css +++ b/website/src/components/WalletCard/styles.module.css @@ -1,4 +1,4 @@ -@import '@css/customVariables.css'; +@import "@css/customVariables.css"; .cardContainer { width: 100%; @@ -41,7 +41,7 @@ flex-wrap: wrap; } .tags > p:not(:last-child)::after { - content: ','; + content: ","; } .tag { font-size: 0.75em; diff --git a/website/src/css/customTheme.css b/website/src/css/customTheme.css index 6a81cb63e..48a057f1c 100644 --- a/website/src/css/customTheme.css +++ b/website/src/css/customTheme.css @@ -1,26 +1,26 @@ -@import '@css/customVariables.css'; +@import "@css/customVariables.css"; @font-face { - font-family: 'Poppins-Bold'; - src: url('../../static/fonts/Poppins-Bold.ttf') format('truetype'); + font-family: "Poppins-Bold"; + src: url("../../static/fonts/Poppins-Bold.ttf") format("truetype"); } @font-face { - font-family: 'Lato'; - src: url('../../static/fonts/Lato-Regular.ttf') format('truetype'); + font-family: "Lato"; + src: url("../../static/fonts/Lato-Regular.ttf") format("truetype"); } -:root{ +:root { /* Override the default with our brand color */ --ifm-color-primary: var(--text-link); --ifm-background-color: var(--surface-01) !important; --ifm-hover-overlay: var(--hover); /* Fonts */ - --ifm-heading-font-family: 'Poppins-Bold', sans-serif; + --ifm-heading-font-family: "Poppins-Bold", sans-serif; --ifm-heading-color: var(--text-primary); - --ifm-font-family-base: 'Lato', sans-serif; + --ifm-font-family-base: "Lato", sans-serif; --ifm-font-color-base: var(--text-secondary); - --ifm-font-family-monospace:'Space Mono', monospace; + --ifm-font-family-monospace: "Space Mono", monospace; --ifm-blockquote-color: var(--text-secondary); --ifm-container-width-xl: 1022px; @@ -134,7 +134,8 @@ background-color: var(--surface-02) !important; border-bottom: var(--border-subtle); } -.aa-DetachedContainer, .aa-DetachedContainer .aa-Panel { +.aa-DetachedContainer, +.aa-DetachedContainer .aa-Panel { background-color: var(--surface-02) !important; background: var(--surface-02) !important; } @@ -142,13 +143,15 @@ background-color: transparent !important; border: 1px solid var(--border-subtle) !important; } -.aa-Label svg, .aa-ClearButton { +.aa-Label svg, +.aa-ClearButton { color: var(--text-tertiary) !important; } .aa-Form:hover { background-color: var(--hover) !important; } -.aa-Form:focus, .aa-Form:focus-within { +.aa-Form:focus, +.aa-Form:focus-within { border: 1px solid var(--border-accent) !important; box-shadow: none !important; } @@ -185,12 +188,13 @@ /* Sidebar Menu */ .menu { - padding: 1rem 1rem 3rem 1rem!important; + padding: 1rem 1rem 3rem 1rem !important; } .theme-doc-sidebar-item-category:not(:first-child) { margin-top: 1rem; } -.menu__link, .menu__list-item-collapsible { +.menu__link, +.menu__list-item-collapsible { padding-left: 0; padding-right: 0; } @@ -222,55 +226,55 @@ /* Add icon next to the menus */ .category-getting-started > div > a:before { - content:url('/svg/icon-sidebar-rocket.svg'); + content: url("/svg/icon-sidebar-rocket.svg"); margin-right: 0.5rem; width: 1.5rem; height: 1.5rem; } .category-dapp > div > a:before { - content:url('/svg/icon-sidebar-tutorial.svg'); + content: url("/svg/icon-sidebar-tutorial.svg"); margin-right: 0.5rem; width: 1.5rem; height: 1.5rem; } .category-script > div > a:before { - content:url('/svg/icon-sidebar-script.svg'); + content: url("/svg/icon-sidebar-script.svg"); margin-right: 0.5rem; width: 1.5rem; height: 1.5rem; } .category-integrate-wallets > div > a:before { - content:url('/svg/icon-sidebar-wallet.svg'); + content: url("/svg/icon-sidebar-wallet.svg"); margin-right: 0.5rem; width: 1.5rem; height: 1.5rem; } .category-node > div > a:before { - content:url('/svg/icon-sidebar-node.svg'); + content: url("/svg/icon-sidebar-node.svg"); margin-right: 0.5rem; width: 1.5rem; height: 1.5rem; } .category-mining > div > a:before { - content:url('/svg/icon-sidebar-mining.svg'); + content: url("/svg/icon-sidebar-mining.svg"); margin-right: 0.5rem; width: 1.5rem; height: 1.5rem; } .category-tech-explanation > div > a:before { - content:url('/svg/icon-sidebar-concept.svg'); + content: url("/svg/icon-sidebar-concept.svg"); margin-right: 0.5rem; width: 1.5rem; height: 1.5rem; } .category-ecosystem > div > a:before { - content:url('/svg/icon-sidebar-ecosystem.svg'); + content: url("/svg/icon-sidebar-ecosystem.svg"); margin-right: 0.5rem; width: 1.5rem; height: 1.5rem; } .category-resources > div > a:before { - content:url('/svg/icon-sidebar-resource.svg'); + content: url("/svg/icon-sidebar-resource.svg"); margin-right: 0.5rem; width: 1.5rem; height: 1.5rem; @@ -324,45 +328,54 @@ } /* Doc Content */ -h1, h2, h3 { +h1, +h2, +h3 { font-weight: 700; line-height: 1.2; } h4 { - font-family: 'Lato', sans-serif; + font-family: "Lato", sans-serif; font-weight: 700; line-height: 1.4; } button { - font-family: 'Lato', sans-serif; + font-family: "Lato", sans-serif; line-height: 1.2; } -p, blockquote, ul, ol { +p, +blockquote, +ul, +ol { font-weight: 400; line-height: 1.7; font-size: 1rem; margin: 1rem 0 1rem; } -.markdown > h1, h1 { +.markdown > h1, +h1 { font-size: 2.5rem; margin: 3rem 0 2rem; } -.markdown > h2, h2 { +.markdown > h2, +h2 { font-size: 1.75rem; margin: 3.5rem 0 1.5rem; } -.markdown > h3, h3 { +.markdown > h3, +h3 { font-size: 1.5rem; margin: 2rem 0 1.5rem; } -.markdown > h4, h4 { +.markdown > h4, +h4 { font-size: 1.25rem; - margin-bottom: 1rem; + margin-bottom: 1rem; } .markdown li::marker { color: var(--text-link); @@ -411,9 +424,9 @@ pre > code { font-size: 0.75rem; } .theme-edit-this-page { - font-size:0.75rem; + font-size: 0.75rem; } -.theme-edit-this-page > svg{ +.theme-edit-this-page > svg { display: none; } @@ -470,13 +483,12 @@ details { align-items: center; justify-content: center; background-color: var(--dark-surface-02); - color:var(--dark-text-secondary); + color: var(--dark-text-secondary); } #oldSiteLink a { color: var(--dark-text-link); } - /* Responsive */ @media only screen and (min-width: 1024px) { .navigationSlider { @@ -524,11 +536,11 @@ details { margin-right: 0px; } .aa-DetachedSearchButtonPlaceholder { - display: none; + display: none; } - .markdown > h1, h1 { + .markdown > h1, + h1 { font-size: 2rem; margin: 3rem 0 2rem; } } - diff --git a/website/src/css/customVariables.css b/website/src/css/customVariables.css index 777cb7834..1eafc6300 100644 --- a/website/src/css/customVariables.css +++ b/website/src/css/customVariables.css @@ -1,119 +1,125 @@ -:root{ - /* Text Variables*/ - --text-primary: #003247; - --text-secondary: #255063; - --text-tertiary: #637F8A; - --text-inverse: #E4F7FF; - --text-link: #0C865C; - - /* Surface Variables*/ - --surface-01: #F8FDFF; - --surface-02: #F2FCFF; - --surface-03: #E7F8F9; - --surface-accent: #E4F7FF; - - /* Border Variables*/ - --border-subtle:#D0E1E7; - --border-invisible:#EAF3F6; - --border-accent: #0C865C; - - /* Conditional Variables*/ - --hover: rgba(0, 224, 211, 0.04); - --surface-03-hover: #DEF0F2; - --selected: rgba(0, 224, 211, 0.08); - - /* Alert Variables */ - --alert-success: #0C865C; - --alert-success-bg: rgba(12, 134, 92, 0.05); - --alert-secondary: #D0E1E7; - --alert-secondary-bg: rgba(208, 225, 231, 0.05); - --alert-info: #2047D1; - --alert-info-bg: rgba(32, 71, 209, 0.05); - --alert-warning: #CBC125; - --alert-warning-bg: rgba(203, 193, 37, 0.05); - --alert-danger: #C51C1C; - --alert-danger-bg: rgba(197, 28, 28, 0.05); - - /* Code Variables*/ - --code-plain: #255063; - --code-comment: #637F8A; - --code-function: #0C865C; - --code-keyword:#0184AD; - --code-constant: #BB15D6; - - --dark-text-primary: #E4F7FF; - --dark-text-secondary: rgba(228, 247, 255, 0.85); - --dark-text-tertiary: #637F8A; - --dark-text-inverse: #003247; - --dark-text-link: #18EFB1; - - --dark-surface-01: #071C27; - --dark-surface-02: #132831; - --dark-surface-03: #18323B; - --dark-surface-accent: #18323B; - - --dark-border-subtle:#3D535B; - --dark-border-invisible: #25373E; - --dark-border-accent: #18EFB1; - - --dark-hover:rgba(228, 247, 255, 0.06); - --dark-surface-03-hover: #243E47; - --dark-selected: rgba(228, 247, 255, 0.12); - - --dark-alert-success: #18EFB1; - --dark-alert-success-bg: rgba(24, 239, 177, 0.1); - --dark-alert-secondary: #3D535B; - --dark-alert-secondary-bg: rgba(61, 83, 91, 0.1); - --dark-alert-info: #828EF9; - --dark-alert-info-bg: rgba(130, 142, 249, 0.1); - --dark-alert-warning: #FFF778; - --dark-alert-warning-bg: rgba(255, 247, 120, 0.1); - --dark-alert-danger: #FD7777; - --dark-alert-danger-bg: rgba(253, 119, 119, 0.1); - - --dark-btn-shadow: -2px -2px 4px 0px rgba(228, 247, 255, 0.10), 4px 4px 11px 0px rgba(7, 28, 39, 0.16); - --dark-btn-hover: #00C584; - --dark-card-shadow: 0px 10px 10px -5px rgba(7, 28, 39, 0.80), 0px 20px 25px -5px rgba(7, 28, 39, 0.80), 0px 1px 2px 0px #3D535B inset; - --dark-card-bg: linear-gradient(180deg, #132831 0%, #071C27 119.54%); - --dark-card-bg-hover: linear-gradient(0deg, var(--hover, rgba(228, 247, 255, 0.06)) 0%, var(--hover, rgba(228, 247, 255, 0.06)) 100%), linear-gradient(180deg, #132831 0%, #071C27 119.54%); +:root { + /* Text Variables*/ + --text-primary: #003247; + --text-secondary: #255063; + --text-tertiary: #637f8a; + --text-inverse: #e4f7ff; + --text-link: #0c865c; + + /* Surface Variables*/ + --surface-01: #f8fdff; + --surface-02: #f2fcff; + --surface-03: #e7f8f9; + --surface-accent: #e4f7ff; + + /* Border Variables*/ + --border-subtle: #d0e1e7; + --border-invisible: #eaf3f6; + --border-accent: #0c865c; + + /* Conditional Variables*/ + --hover: rgba(0, 224, 211, 0.04); + --surface-03-hover: #def0f2; + --selected: rgba(0, 224, 211, 0.08); + + /* Alert Variables */ + --alert-success: #0c865c; + --alert-success-bg: rgba(12, 134, 92, 0.05); + --alert-secondary: #d0e1e7; + --alert-secondary-bg: rgba(208, 225, 231, 0.05); + --alert-info: #2047d1; + --alert-info-bg: rgba(32, 71, 209, 0.05); + --alert-warning: #cbc125; + --alert-warning-bg: rgba(203, 193, 37, 0.05); + --alert-danger: #c51c1c; + --alert-danger-bg: rgba(197, 28, 28, 0.05); + + /* Code Variables*/ + --code-plain: #255063; + --code-comment: #637f8a; + --code-function: #0c865c; + --code-keyword: #0184ad; + --code-constant: #bb15d6; + + --dark-text-primary: #e4f7ff; + --dark-text-secondary: rgba(228, 247, 255, 0.85); + --dark-text-tertiary: #637f8a; + --dark-text-inverse: #003247; + --dark-text-link: #18efb1; + + --dark-surface-01: #071c27; + --dark-surface-02: #132831; + --dark-surface-03: #18323b; + --dark-surface-accent: #18323b; + + --dark-border-subtle: #3d535b; + --dark-border-invisible: #25373e; + --dark-border-accent: #18efb1; + + --dark-hover: rgba(228, 247, 255, 0.06); + --dark-surface-03-hover: #243e47; + --dark-selected: rgba(228, 247, 255, 0.12); + + --dark-alert-success: #18efb1; + --dark-alert-success-bg: rgba(24, 239, 177, 0.1); + --dark-alert-secondary: #3d535b; + --dark-alert-secondary-bg: rgba(61, 83, 91, 0.1); + --dark-alert-info: #828ef9; + --dark-alert-info-bg: rgba(130, 142, 249, 0.1); + --dark-alert-warning: #fff778; + --dark-alert-warning-bg: rgba(255, 247, 120, 0.1); + --dark-alert-danger: #fd7777; + --dark-alert-danger-bg: rgba(253, 119, 119, 0.1); + + --dark-btn-shadow: -2px -2px 4px 0px rgba(228, 247, 255, 0.1), + 4px 4px 11px 0px rgba(7, 28, 39, 0.16); + --dark-btn-hover: #00c584; + --dark-card-shadow: 0px 10px 10px -5px rgba(7, 28, 39, 0.8), + 0px 20px 25px -5px rgba(7, 28, 39, 0.8), 0px 1px 2px 0px #3d535b inset; + --dark-card-bg: linear-gradient(180deg, #132831 0%, #071c27 119.54%); + --dark-card-bg-hover: linear-gradient( + 0deg, + var(--hover, rgba(228, 247, 255, 0.06)) 0%, + var(--hover, rgba(228, 247, 255, 0.06)) 100% + ), + linear-gradient(180deg, #132831 0%, #071c27 119.54%); } /* Override values for dark theme */ -html[data-theme='dark'] { - --text-primary: var(--dark-text-primary); - --text-secondary: var(--dark-text-secondary); - --text-tertiary: var(--dark-text-tertiary); - --text-inverse: var(--dark-text-inverse); - --text-link: var(--dark-text-link); - - --surface-01: var(--dark-surface-01); - --surface-02: var(--dark-surface-02); - --surface-03: var(--dark-surface-03); - --surface-accent: var(--dark-surface-accent); - - --border-subtle: var(--dark-border-subtle); - --border-invisible: var(--dark-border-invisible); - --border-accent: var(--dark-border-accent); - - --hover: var(--dark-hover); - --surface-03-hover: var(--dark-surface-03-hover); - --selected: var(--dark-selected); - - --alert-success: var(--dark-alert-success); - --alert-success-bg: var(--dark-alert-success-bg); - --alert-secondary: var(--dark-alert-secondary); - --alert-secondary-bg: var(--dark-alert-secondary-bg); - --alert-info: var(--dark-alert-info); - --alert-info-bg: var(--dark-alert-info-bg); - --alert-warning: var(--dark-alert-warning); - --alert-warning-bg: var(--dark-alert-warning-bg); - --alert-danger: var(--dark-alert-danger); - --alert-danger-bg: var(--dark-alert-danger-bg); - - --code-plain:#E4F7FF; - --code-comment: rgba(228, 247, 255, 0.5); - --code-function: #E4E0A5; - --code-keyword: #5BD8FF; - --code-constant: #D2A8FF; +html[data-theme="dark"] { + --text-primary: var(--dark-text-primary); + --text-secondary: var(--dark-text-secondary); + --text-tertiary: var(--dark-text-tertiary); + --text-inverse: var(--dark-text-inverse); + --text-link: var(--dark-text-link); + + --surface-01: var(--dark-surface-01); + --surface-02: var(--dark-surface-02); + --surface-03: var(--dark-surface-03); + --surface-accent: var(--dark-surface-accent); + + --border-subtle: var(--dark-border-subtle); + --border-invisible: var(--dark-border-invisible); + --border-accent: var(--dark-border-accent); + + --hover: var(--dark-hover); + --surface-03-hover: var(--dark-surface-03-hover); + --selected: var(--dark-selected); + + --alert-success: var(--dark-alert-success); + --alert-success-bg: var(--dark-alert-success-bg); + --alert-secondary: var(--dark-alert-secondary); + --alert-secondary-bg: var(--dark-alert-secondary-bg); + --alert-info: var(--dark-alert-info); + --alert-info-bg: var(--dark-alert-info-bg); + --alert-warning: var(--dark-alert-warning); + --alert-warning-bg: var(--dark-alert-warning-bg); + --alert-danger: var(--dark-alert-danger); + --alert-danger-bg: var(--dark-alert-danger-bg); + + --code-plain: #e4f7ff; + --code-comment: rgba(228, 247, 255, 0.5); + --code-function: #e4e0a5; + --code-keyword: #5bd8ff; + --code-constant: #d2a8ff; } - \ No newline at end of file diff --git a/website/src/pages/homeContents.tsx b/website/src/pages/homeContents.tsx index 1574fb2ab..01b7e24de 100644 --- a/website/src/pages/homeContents.tsx +++ b/website/src/pages/homeContents.tsx @@ -1,100 +1,140 @@ export interface CardLinks { - label: string; - link: string; + label: string; + link: string; } export interface DevToolProps { - title: string; - href: string; - category: string; + title: string; + href: string; + category: string; } export interface HomeCardProps { - title: string; - links: CardLinks[]; - icon: string; + title: string; + links: CardLinks[]; + icon: string; } const homeCardContents: HomeCardProps[] = [ - { - title: 'Getting Started', - links: [ - { label: "How CKB Works", link: "/docs/getting-started/how-ckb-works"}, - { label: "Quick Start (5 min)", link: "/docs/getting-started/quick-start"}, - { label: "Dev Tools", link: "/docs/getting-started/devtool"}, - ], - icon: 'rocket', - }, - { - title: 'Dapp Tutorials', - links: [ - { label: "Transfer CKB", link: "/docs/dapp/transfer-ckb"}, - { label: "Write an On-Chain Message", link: "/docs/dapp/write-message"}, - { label: "Create a DOB", link: "/docs/dapp/create-dob"}, - ], - icon: 'dapp', - }, - { - title: 'Scripts', - links: [ - { label: "Intro to Script", link: "/docs/script/intro-to-script"}, - { label: "Tutorial: A Minimal Script", link: "/docs/script/minimal-script"}, - { label: "Tutorial: Run JS on CKB", link: "/docs/script/js-script"}, - ], - icon: 'script', - }, - { - title: 'Run a Node', - links: [ - { label: "Run a Mainnet Node", link: "/docs/node/run-mainnet-node"}, - { label: "Run a Testnet Node", link: "/docs/node/run-testnet-node"}, - { label: "Run a Devnet Node", link: "/docs/node/run-devnet-node"}, - ], - icon: 'node', - }, - { - title: 'Mining', - links: [ - { label: "Rewards", link: "/docs/mining/rewards"}, - { label: "Cost and Profit", link: "/docs/mining/cost-and-profit"}, - { label: "Guide", link: "/docs/mining/guide"}, - ], - icon: 'mining', - }, - { - title: 'Tech Explanation', - links: [ - { label: "Nervos Blockchain", link: "/docs/tech-explanation/nervos-blockchain"}, - { label: "Cell Model", link: "/docs/tech-explanation/cell-model"}, - { label: "Tokenomics", link: "/docs/tech-explanation/economics"}, - ], - icon: 'concept', - }, + { + title: "Getting Started", + links: [ + { label: "How CKB Works", link: "/docs/getting-started/how-ckb-works" }, + { + label: "Quick Start (5 min)", + link: "/docs/getting-started/quick-start", + }, + { label: "Dev Tools", link: "/docs/getting-started/devtool" }, + ], + icon: "rocket", + }, + { + title: "Dapp Tutorials", + links: [ + { label: "Transfer CKB", link: "/docs/dapp/transfer-ckb" }, + { label: "Write an On-Chain Message", link: "/docs/dapp/write-message" }, + { label: "Create a DOB", link: "/docs/dapp/create-dob" }, + ], + icon: "dapp", + }, + { + title: "Scripts", + links: [ + { label: "Intro to Script", link: "/docs/script/intro-to-script" }, + { + label: "Tutorial: A Minimal Script", + link: "/docs/script/minimal-script", + }, + { label: "Tutorial: Run JS on CKB", link: "/docs/script/js-script" }, + ], + icon: "script", + }, + { + title: "Run a Node", + links: [ + { label: "Run a Mainnet Node", link: "/docs/node/run-mainnet-node" }, + { label: "Run a Testnet Node", link: "/docs/node/run-testnet-node" }, + { label: "Run a Devnet Node", link: "/docs/node/run-devnet-node" }, + ], + icon: "node", + }, + { + title: "Mining", + links: [ + { label: "Rewards", link: "/docs/mining/rewards" }, + { label: "Cost and Profit", link: "/docs/mining/cost-and-profit" }, + { label: "Guide", link: "/docs/mining/guide" }, + ], + icon: "mining", + }, + { + title: "Tech Explanation", + links: [ + { + label: "Nervos Blockchain", + link: "/docs/tech-explanation/nervos-blockchain", + }, + { label: "Cell Model", link: "/docs/tech-explanation/cell-model" }, + { label: "Tokenomics", link: "/docs/tech-explanation/economics" }, + ], + icon: "concept", + }, ]; const devToolSectionContents: DevToolProps[] = [ - { title: 'Lumos', href: 'https://github.com/ckb-js/lumos', category: 'Development & Deployment' }, - { title: 'CKB SDKs', href: 'https://github.com/nervosnetwork/ckb-sdk-rust', category: 'Development & Deployment' }, - { title: 'CKB-CLI', href: 'https://github.com/nervosnetwork/ckb-cli', category: 'Development & Deployment' }, - { title: 'OffCKB', href: 'https://github.com/RetricSu/offckb/tree/7d87d018be7626e1672a039b52f8bf4db9dd4eae', category: 'Development & Deployment' }, - { title: 'CKB Debugger', href: 'https://github.com/nervosnetwork/ckb-standalone-debugger', category: 'Utilities & Testing' }, - { title: 'CKB Address', href: 'https://ckb.tools/address', category: 'Utilities & Testing' }, - { title: 'Nervos Pudge Faucet', href: 'https://faucet.nervos.org/', category: 'Utilities & Testing' }, + { + title: "Lumos", + href: "https://github.com/ckb-js/lumos", + category: "Development & Deployment", + }, + { + title: "CKB SDKs", + href: "https://github.com/nervosnetwork/ckb-sdk-rust", + category: "Development & Deployment", + }, + { + title: "CKB-CLI", + href: "https://github.com/nervosnetwork/ckb-cli", + category: "Development & Deployment", + }, + { + title: "OffCKB", + href: "https://github.com/RetricSu/offckb/tree/7d87d018be7626e1672a039b52f8bf4db9dd4eae", + category: "Development & Deployment", + }, + { + title: "CKB Debugger", + href: "https://github.com/nervosnetwork/ckb-standalone-debugger", + category: "Utilities & Testing", + }, + { + title: "CKB Address", + href: "https://ckb.tools/address", + category: "Utilities & Testing", + }, + { + title: "Nervos Pudge Faucet", + href: "https://faucet.nervos.org/", + category: "Utilities & Testing", + }, ]; -const contactUsContents: CardLinks[]= [ - { label: 'github', link: 'https://github.com/nervosnetwork'}, - { label: 'discord', link: 'https://discord.gg/nervosnetwork'}, - { label: 'reddit', link: 'https://www.reddit.com/r/NervosNetwork/'}, - { label: 'nervostalk', link: 'https://talk.nervos.org/'}, - { label: 'telegram', link: 'https://t.me/nervosnetwork'}, - { label: 'twitter', link: 'https://twitter.com/nervosnetwork'}, - { label: 'medium', link: 'https://medium.com/nervosnetwork'}, - { label: 'youtube', link: 'https://www.youtube.com/channel/UCONuJGdMzUY0Y6jrPBOzH7A'}, -] +const contactUsContents: CardLinks[] = [ + { label: "github", link: "https://github.com/nervosnetwork" }, + { label: "discord", link: "https://discord.gg/nervosnetwork" }, + { label: "reddit", link: "https://www.reddit.com/r/NervosNetwork/" }, + { label: "nervostalk", link: "https://talk.nervos.org/" }, + { label: "telegram", link: "https://t.me/nervosnetwork" }, + { label: "twitter", link: "https://twitter.com/nervosnetwork" }, + { label: "medium", link: "https://medium.com/nervosnetwork" }, + { + label: "youtube", + link: "https://www.youtube.com/channel/UCONuJGdMzUY0Y6jrPBOzH7A", + }, +]; // Just to include a default export const HomeContentsPage: React.FC = () => { - return null; + return null; }; export default HomeContentsPage; -export { homeCardContents, devToolSectionContents, contactUsContents } ; +export { homeCardContents, devToolSectionContents, contactUsContents }; diff --git a/website/src/pages/index.tsx b/website/src/pages/index.tsx index 0a40ca2b0..619e6f066 100644 --- a/website/src/pages/index.tsx +++ b/website/src/pages/index.tsx @@ -1,32 +1,52 @@ import { useEffect } from "react"; -import LogRocket from 'logrocket'; +import LogRocket from "logrocket"; import Layout from "@theme/Layout"; import styles from "./styles.module.css"; import CardLayout from "../components/CardLayout"; import clsx from "clsx"; -import { HomeCardSection, WalletDisplay, ToolDisplay, DevLogSection, ContactUsSection, ProjectDisplay } from "../components/Home"; -import { useColorMode } from '@docusaurus/theme-common'; +import { + HomeCardSection, + WalletDisplay, + ToolDisplay, + DevLogSection, + ContactUsSection, + ProjectDisplay, +} from "../components/Home"; +import { useColorMode } from "@docusaurus/theme-common"; import CookieConsent from "../components/CookieConsent"; - export default function Home() { useEffect(() => { // Initialize LogRocket - LogRocket.init('ghkibu/nervos-doc'); + LogRocket.init("ghkibu/nervos-doc"); }, []); return ( - +
    -
    Nervos CKB Documentation
    -

    Discover the power of Nervos CKB through tutorials, guides, and concepts

    +
    Nervos CKB Documentation
    +

    + Discover the power of Nervos CKB through tutorials, guides, and + concepts +

    -
    -
    Explore Ecosystem
    -
    Explore our curated selection of featured tools and resources designed to empower your development on Nervos CKB
    +
    +
    + Explore Ecosystem +
    +
    + Explore our curated selection of featured tools and resources designed + to empower your development on Nervos CKB +
    @@ -34,8 +54,16 @@ export default function Home() {
    -
    -
    Unveil Latest Update
    +
    +
    + Unveil Latest Update +
    @@ -50,10 +78,7 @@ function SwtichToDark() { const { setColorMode } = useColorMode(); useEffect(() => { - setColorMode('dark'); + setColorMode("dark"); }, []); return null; } - - - diff --git a/website/src/pages/styles.module.css b/website/src/pages/styles.module.css index 0880c663a..752a9b8a3 100644 --- a/website/src/pages/styles.module.css +++ b/website/src/pages/styles.module.css @@ -1,72 +1,73 @@ -@import '@css/customVariables.css'; +@import "@css/customVariables.css"; /* General styling */ .homeLayout { - width: 100%; - background: url('/svg/header-bg.svg') no-repeat top center; - background-color: var(--dark-surface-01) !important; + width: 100%; + background: url("/svg/header-bg.svg") no-repeat top center; + background-color: var(--dark-surface-01) !important; } .relative { - position: relative; + position: relative; } .header1 { - font-size: 3.5em; - margin: 7.5rem 0 1.25rem; + font-size: 3.5em; + margin: 7.5rem 0 1.25rem; } .header2 { - font-size: 3em; - margin: 8.75rem 0 1.25rem; + font-size: 3em; + margin: 8.75rem 0 1.25rem; } -.header1, .header2 { - font-family: "Poppins-Bold", sans-serif; - line-height: 1.2; - text-align: center; - color: var(--dark-text-primary); +.header1, +.header2 { + font-family: "Poppins-Bold", sans-serif; + line-height: 1.2; + text-align: center; + color: var(--dark-text-primary); } .description { - text-align: center; - color: var(--dark-text-secondary); + text-align: center; + color: var(--dark-text-secondary); } .titleBtm { - margin-bottom: 2rem; + margin-bottom: 2rem; } .flexCol { - display: flex; - flex-direction: column; - align-items: center; - width: 100%; + display: flex; + flex-direction: column; + align-items: center; + width: 100%; } .sectionContainer { - width: 100%; - max-width: 1440px; - margin: 0 auto; - display: flex; - flex-direction: column; - align-items: center; - padding: 0 4rem; - margin-bottom: 10rem; + width: 100%; + max-width: 1440px; + margin: 0 auto; + display: flex; + flex-direction: column; + align-items: center; + padding: 0 4rem; + margin-bottom: 10rem; } .textHighlight { - color: var(--dark-text-link); + color: var(--dark-text-link); } .ecoBG { - background: url('/svg/bg-eco-header.svg') no-repeat top center; + background: url("/svg/bg-eco-header.svg") no-repeat top center; } .updateBG { - background: url('/svg/bg-update-header.svg') no-repeat top center; + background: url("/svg/bg-update-header.svg") no-repeat top center; } @media (max-width: 768px) { - .header1 { - font-size: 2.5rem; - margin: 3rem 0 1.25rem; - } - .header2 { - font-size: 2em; - margin: 8rem 0 1.25rem; - } - .sectionContainer { - padding: 0 1rem; - margin-bottom: 5rem; - } -} \ No newline at end of file + .header1 { + font-size: 2.5rem; + margin: 3rem 0 1.25rem; + } + .header2 { + font-size: 2em; + margin: 8rem 0 1.25rem; + } + .sectionContainer { + padding: 0 1rem; + margin-bottom: 5rem; + } +} diff --git a/website/src/prism/dark.js b/website/src/prism/dark.js index 75fbb2bbd..b9303174c 100644 --- a/website/src/prism/dark.js +++ b/website/src/prism/dark.js @@ -1,41 +1,41 @@ -import {themes as prismThemes} from 'prism-react-renderer'; +import { themes as prismThemes } from "prism-react-renderer"; module.exports = { plain: { - color: 'var(--code-plain)', - backgroundColor: 'var(--surface-02)', + color: "var(--code-plain)", + backgroundColor: "var(--surface-02)", }, styles: [ ...prismThemes.vsDark.styles, { - types: ['comment', 'prolog', 'doctype', 'cdata'], + types: ["comment", "prolog", "doctype", "cdata"], style: { - color: 'var(--code-comment)', + color: "var(--code-comment)", }, }, { - types: ['operator'], + types: ["operator"], style: { - color: 'var(--text-secondary)', + color: "var(--text-secondary)", }, }, { - types: ['constant'], - style: { - color: 'var(--code-constant)', - }, + types: ["constant"], + style: { + color: "var(--code-constant)", + }, }, { - types: ['function', 'attr-name'], + types: ["function", "attr-name"], style: { - color: 'var(--code-function)', + color: "var(--code-function)", }, }, { - types: ['keyword', 'attr-value'], + types: ["keyword", "attr-value"], style: { - color: 'var(--code-keyword)', + color: "var(--code-keyword)", }, }, -], -}; \ No newline at end of file + ], +}; diff --git a/website/src/prism/light.js b/website/src/prism/light.js index 01c76d088..571f788e7 100644 --- a/website/src/prism/light.js +++ b/website/src/prism/light.js @@ -1,42 +1,41 @@ -import {themes as prismThemes} from 'prism-react-renderer'; - +import { themes as prismThemes } from "prism-react-renderer"; module.exports = { plain: { - color: 'var(--code-plain)', - backgroundColor: 'var(--surface-02)', + color: "var(--code-plain)", + backgroundColor: "var(--surface-02)", }, styles: [ ...prismThemes.vsLight.styles, { - types: ['comment', 'prolog', 'doctype', 'cdata'], + types: ["comment", "prolog", "doctype", "cdata"], style: { - color: 'var(--code-comment)', + color: "var(--code-comment)", }, }, { - types: ['constant'], - style: { - color: 'var(--code-constant)', - }, + types: ["constant"], + style: { + color: "var(--code-constant)", + }, }, { - types: ['operator'], + types: ["operator"], style: { - color: 'var(--text-secondary)', + color: "var(--text-secondary)", }, }, { - types: ['function', 'attr-name'], + types: ["function", "attr-name"], style: { - color: 'var(--code-function)', + color: "var(--code-function)", }, }, { - types: ['keyword', 'attr-value'], + types: ["keyword", "attr-value"], style: { - color: 'var(--code-keyword)', + color: "var(--code-keyword)", }, }, ], -}; \ No newline at end of file +}; diff --git a/website/src/theme/CodeBlock/Container/index.tsx b/website/src/theme/CodeBlock/Container/index.tsx index 99f8dcf1b..e034ad854 100644 --- a/website/src/theme/CodeBlock/Container/index.tsx +++ b/website/src/theme/CodeBlock/Container/index.tsx @@ -1,13 +1,13 @@ -import React, {type ComponentProps} from 'react'; -import clsx from 'clsx'; -import {ThemeClassNames, usePrismTheme} from '@docusaurus/theme-common'; -import {getPrismCssVariables} from '@docusaurus/theme-common/internal'; -import styles from './styles.module.css'; +import React, { type ComponentProps } from "react"; +import clsx from "clsx"; +import { ThemeClassNames, usePrismTheme } from "@docusaurus/theme-common"; +import { getPrismCssVariables } from "@docusaurus/theme-common/internal"; +import styles from "./styles.module.css"; -export default function CodeBlockContainer({ +export default function CodeBlockContainer({ as: As, ...props -}: {as: T} & ComponentProps): JSX.Element { +}: { as: T } & ComponentProps): JSX.Element { const prismTheme = usePrismTheme(); const prismCssVariables = getPrismCssVariables(prismTheme); return ( @@ -18,7 +18,7 @@ export default function CodeBlockContainer({ className={clsx( props.className, styles.codeBlockContainer, - ThemeClassNames.common.codeBlock, + ThemeClassNames.common.codeBlock )} /> ); diff --git a/website/src/theme/CodeBlock/Content/Element.tsx b/website/src/theme/CodeBlock/Content/Element.tsx index eef574172..d5ee34da2 100644 --- a/website/src/theme/CodeBlock/Content/Element.tsx +++ b/website/src/theme/CodeBlock/Content/Element.tsx @@ -1,9 +1,9 @@ -import React from 'react'; -import clsx from 'clsx'; -import Container from '@theme/CodeBlock/Container'; -import type {Props} from '@theme/CodeBlock/Content/Element'; +import React from "react"; +import clsx from "clsx"; +import Container from "@theme/CodeBlock/Container"; +import type { Props } from "@theme/CodeBlock/Content/Element"; -import styles from './styles.module.css'; +import styles from "./styles.module.css"; //
     tags in markdown map to CodeBlocks. They may contain JSX children. When
     // the children is not a simple string, we just return a styled block without
    @@ -16,7 +16,8 @@ export default function CodeBlockJSX({
         
    +      className={clsx(styles.codeBlockStandalone, "thin-scrollbar", className)}
    +    >
           {children}
         
       );
    diff --git a/website/src/theme/CodeBlock/Content/String.tsx b/website/src/theme/CodeBlock/Content/String.tsx
    index f8afb89f9..358bbbf04 100644
    --- a/website/src/theme/CodeBlock/Content/String.tsx
    +++ b/website/src/theme/CodeBlock/Content/String.tsx
    @@ -1,21 +1,21 @@
    -import React from 'react';
    -import clsx from 'clsx';
    -import {useThemeConfig, usePrismTheme} from '@docusaurus/theme-common';
    +import React from "react";
    +import clsx from "clsx";
    +import { useThemeConfig, usePrismTheme } from "@docusaurus/theme-common";
     import {
       parseCodeBlockTitle,
       parseLanguage,
       parseLines,
       containsLineNumbers,
       useCodeWordWrap,
    -} from '@docusaurus/theme-common/internal';
    -import {Highlight, type Language} from 'prism-react-renderer';
    -import Line from '@theme/CodeBlock/Line';
    -import CopyButton from '@theme/CodeBlock/CopyButton';
    -import WordWrapButton from '@theme/CodeBlock/WordWrapButton';
    -import Container from '@theme/CodeBlock/Container';
    -import type {Props} from '@theme/CodeBlock/Content/String';
    +} from "@docusaurus/theme-common/internal";
    +import { Highlight, type Language } from "prism-react-renderer";
    +import Line from "@theme/CodeBlock/Line";
    +import CopyButton from "@theme/CodeBlock/CopyButton";
    +import WordWrapButton from "@theme/CodeBlock/WordWrapButton";
    +import Container from "@theme/CodeBlock/Container";
    +import type { Props } from "@theme/CodeBlock/Content/String";
     
    -import styles from './styles.module.css';
    +import styles from "./styles.module.css";
     
     // Prism languages are always lowercase
     // We want to fail-safe and allow both "php" and "PHP"
    @@ -26,17 +26,17 @@ function normalizeLanguage(language: string | undefined): string | undefined {
     
     export default function CodeBlockString({
       children,
    -  className: blockClassName = '',
    +  className: blockClassName = "",
       metastring,
       title: titleProp,
       showLineNumbers: showLineNumbersProp,
       language: languageProp,
     }: Props): JSX.Element {
       const {
    -    prism: {defaultLanguage, magicComments},
    +    prism: { defaultLanguage, magicComments },
       } = useThemeConfig();
       const language = normalizeLanguage(
    -    languageProp ?? parseLanguage(blockClassName) ?? defaultLanguage,
    +    languageProp ?? parseLanguage(blockClassName) ?? defaultLanguage
       );
     
       const prismTheme = usePrismTheme();
    @@ -47,7 +47,7 @@ export default function CodeBlockString({
       // "title=\"xyz\"" => title: "\"xyz\""
       const title = parseCodeBlockTitle(metastring) || titleProp;
     
    -  const {lineClassNames, code} = parseLines(children, {
    +  const { lineClassNames, code } = parseLines(children, {
         metastring,
         language,
         magicComments,
    @@ -62,26 +62,30 @@ export default function CodeBlockString({
             blockClassName,
             language &&
               !blockClassName.includes(`language-${language}`) &&
    -          `language-${language}`,
    -      )}>
    +          `language-${language}`
    +      )}
    +    >
           {title && 
    {title}
    }
    - {({className, style, tokens, getLineProps, getTokenProps}) => ( + language={(language ?? "text") as Language} + > + {({ className, style, tokens, getLineProps, getTokenProps }) => (
    +              className={clsx(className, styles.codeBlock, "thin-scrollbar")}
    +              style={style}
    +            >
                   
    +                  showLineNumbers && styles.codeBlockLinesWithNumbering
    +                )}
    +              >
                     {tokens.map((line, i) => (
                       (undefined);
       const handleCopyCode = useCallback(() => {
    @@ -27,28 +27,29 @@ export default function CopyButton({code, className}: Props): JSX.Element {
           aria-label={
             isCopied
               ? translate({
    -              id: 'theme.CodeBlock.copied',
    -              message: 'Copied',
    -              description: 'The copied button label on code blocks',
    +              id: "theme.CodeBlock.copied",
    +              message: "Copied",
    +              description: "The copied button label on code blocks",
                 })
               : translate({
    -              id: 'theme.CodeBlock.copyButtonAriaLabel',
    -              message: 'Copy code to clipboard',
    -              description: 'The ARIA label for copy code blocks button',
    +              id: "theme.CodeBlock.copyButtonAriaLabel",
    +              message: "Copy code to clipboard",
    +              description: "The ARIA label for copy code blocks button",
                 })
           }
           title={translate({
    -        id: 'theme.CodeBlock.copy',
    -        message: 'Copy',
    -        description: 'The copy button label on code blocks',
    +        id: "theme.CodeBlock.copy",
    +        message: "Copy",
    +        description: "The copy button label on code blocks",
           })}
           className={clsx(
    -        'clean-btn',
    +        "clean-btn",
             className,
             styles.copyButton,
    -        isCopied && styles.copyButtonCopied,
    +        isCopied && styles.copyButtonCopied
           )}
    -      onClick={handleCopyCode}>
    +      onClick={handleCopyCode}
    +    >