This is a Minimal Template for CKB Full-Stack Dapps generated by offckb.
Offckb does not do the magic. It just wraps the new CKB smart contract template and the CKB javascript Dapp framework into one mono-repo. Under the hook, it uses:
- ckb-scripts-template for smart contract development
- next-js and ccc for frontend development
By default, this template comes with a single simple smart contract hello-world: contracts/hello-world/src/main.rs.
The smart contract is written in Rust lang. In order to develop, the following dependencies are required:
git,make,sed,bash,sha256sumand others Unix utilities.Rustwithriscv64 target:rustup target add riscv64imac-unknown-none-elfClang 18+cargo-generate
Check out the ckb-script-templates for more detail
add a new smart-contract:
make generatebuild smart-contract:
make buildrun test:
make testFor more detail, check out ckb-script-templates
first, enter the frontend workspace:
cd frontendstart the app:
npm i && npm run devchange the CKB blockchain network:
edit .env file:
NEXT_PUBLIC_NETWORK=devnet # devnet, testnet or mainnetOnce you build your smart contracts, you can deploy them to CKB blockchain with ckb-cli or any other tools.
If you want to test them in devnet/testnet blockchain, then offckb might be the ideal selection.
offckb will look for the offckb.config.ts file to read config information. so you will need to enter the frontend workspace to do the instruction:
cd frontend
offckb deploy --network devnetIf successfully deployed, you will see the deploy script info for your smart contract recorded in the path recorded in the offckb.config.ts file.
Every time you deploy a new version of your smart contracts, those script infos will be updated by offckb in the place recorded in offckb.config.ts and work out-of-box in your frontend.
You can also deploy smart contracts to the CKB Testnet like this:
cd frontend
offckb deploy --network testnetand start your frontend Dapp targeting Testnet:
edit .env file:
NEXT_PUBLIC_NETWORK=testnet # devnet, testnet or mainnetcd frontend
npm run devNote that the mainnet network is not supported in offckb since offckb is focusing on building a friendly development environment for CKB. To gain better security, it is recommended to use production tools like ckb-cli to deploy smart contracts and do transactions for the CKB mainnet.