{"id":18674108,"url":"https://github.com/nervosnetwork/dapps-on-ckb-workshop-code","last_synced_at":"2025-04-12T01:55:28.246Z","repository":{"id":38377925,"uuid":"282151637","full_name":"nervosnetwork/dapps-on-ckb-workshop-code","owner":"nervosnetwork","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-13T09:10:41.000Z","size":82,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-12T01:55:23.193Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nervosnetwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-24T07:22:18.000Z","updated_at":"2024-03-27T06:48:46.000Z","dependencies_parsed_at":"2022-08-25T02:12:22.936Z","dependency_job_id":null,"html_url":"https://github.com/nervosnetwork/dapps-on-ckb-workshop-code","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fdapps-on-ckb-workshop-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fdapps-on-ckb-workshop-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fdapps-on-ckb-workshop-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nervosnetwork%2Fdapps-on-ckb-workshop-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nervosnetwork","download_url":"https://codeload.github.com/nervosnetwork/dapps-on-ckb-workshop-code/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505868,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T09:17:31.550Z","updated_at":"2025-04-12T01:55:28.213Z","avatar_url":"https://github.com/nervosnetwork.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dapps-on-ckb-workshop-code\n\nThis repository contains the accompanying code for the `Dapps on CKB` workshop. The workshop consists of 3 Lectures:\n\n* Lecture 1: Introduction [Slides](https://docs.google.com/presentation/d/10m3jPutAc731S5kHgS8axE565CPiUXNmCSU4eCZgv5Y/edit?usp=sharing) [Video](https://www.youtube.com/watch?v=iVjccs3z5q0)\n* Lecture 2: On-chain Scripts with Capsule [Slides](https://docs.google.com/presentation/d/1pl5DtkaoHceC2zZ_OTosXAr98cr80D-8D_5iVEptecY/edit?usp=sharing) [Video](https://www.youtube.com/watch?v=NcN3NiBuJbo)\n* Lecture 3: Dapps with Lumos [Slides](https://docs.google.com/presentation/d/1fQKyOrkN8I61a1ZGXCgRczi6T_zWH0aN-IA2SFpdCU4/edit?usp=sharing) [Video](https://www.youtube.com/watch?v=7ob-WL1eWrQ)\n* Lecture 3 Part 2: Dapps with Lumos Part 2 [Video](https://www.youtube.com/watch?v=TJ2bnSFUpPQ\u0026t=20s)\n\nIn this workshop, we are building an [NFT](https://talk.nervos.org/t/rfc-ckb-nft-draft-spec/4779) script together with a simple set of glue code for interaction. 2 individual components are built for the demo:\n\n* [nft-glue](/nft-glue): [Lumos](https://github.com/nervosnetwork/lumos) powered TypeScript library for interacting with NFT tokens on CKB.\n* [nft-validator](/nft-validator): Rust based on-chain validator script for supporting NFT tokens on CKB. [Capsule](https://github.com/nervosnetwork/capsule) is leveraged to simplify script development.\n\n\n# Build \u0026 Run Workshop\n\n## Start CKB Devnet\n\n```\n# create ckb config file\n$ ckb init --chain devnet\n\n# create account file \n$ echo 0xfd686a48908e8caf97723578bf85f746e1e1d8956cb132f6a2e92e7234a2a245 \u003e alice\n$ echo 0x5368b818f59570b5bc078a6a564f098a191dcb8938d95c413be5065fd6c42d32 \u003e bob\n$ echo 0xd6013cd867d286ef84cc300ac6546013837df2b06c9f53c83b4c33c2417f6a07 \u003e charlie\n```\n\n### Edit `dev.toml`\n\n\u003cdetails\u003e\n   \u003csummary\u003edev.toml\u003c/summary\u003e\n\n``` python\n# alice\n# issue for random generated private key:0xfd686a48908e8caf97723578bf85f746e1e1d8956cb132f6a2e92e7234a2a245\n# address: ckt1qyqw8yx5hx6vwcm7eqren0d0v39wvfwdhy3q2807pp\n[[genesis.issued_cells]]\ncapacity = 20_000_000_000_00000000\nlock.code_hash = \"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8\"\nlock.args = \"0xe390d4b9b4c7637ec80799bdaf644ae625cdb922\"\nlock.hash_type = \"type\"\n\n# bob\n# issue for random generated private key:0x5368b818f59570b5bc078a6a564f098a191dcb8938d95c413be5065fd6c42d32\n# address: ckt1qyqtdhd6s7a44a0s2wc6uk7tcl6duq68nalqvzxw09\n[[genesis.issued_cells]]\ncapacity = 20_000_000_000_00000000\nlock.code_hash = \"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8\"\nlock.args = \"0xb6ddba87bb5af5f053b1ae5bcbc7f4de03479f7e\"\nlock.hash_type = \"type\"\n\n# charlie\n# issue for random generated private key:0xd6013cd867d286ef84cc300ac6546013837df2b06c9f53c83b4c33c2417f6a07\n# address: ckt1qyqxek9w28u3htxhjyqjd7yqzw9nptzaxq2shqlft0\n[[genesis.issued_cells]]\ncapacity = 20_000_000_000_00000000\nlock.code_hash = \"0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8\"\nlock.args = \"0x6cd8ae51f91bacd7910126f880138b30ac5d3015\"\nlock.hash_type = \"type\"\n```\n\n\u003c/details\u003e\n\n### Importing Account to ckb-cli\n``` \n$ ckb-cli account import --privkey-path alice\n$ ckb-cli account import --privkey-path bob\n$ ckb-cli account import --privkey-path charlie\n```\n\n### Start CKB \u0026 CKB-Indexer\n```\n$ ckb run\n```\n\n### Building \u0026 Testing Contracts\n``` \n$ cd nft-validator\n$ capsule build\n$ capsule test\n```\n\n### Deploy Contracts to Devnet\n```\n$ capsule build --release\n\n$ capsule deploy --address ckt1qyqw8yx5hx6vwcm7eqren0d0v39wvfwdhy3q2807pp --fee 0.01\n\n# get and save cell info\n$ ckb-cli rpc get_transaction --hash \u003cget tx_hash from previous step ↑\u003e` \n```\n\n## Interacting with Contract via Lumos \n\n\n```\n# Modify the TX_HASH field of SCRIPTS.SECP256K1_BLAKE160 in config.json file to the current configuration on the dev chain.\n\n# Get the current configuration on the chain\n$ ckb-cli rpc get_block_by_number --number 0\n# Find the transactions[1].hash field from the returned value\n```\n\n\n### Creating the Config\n``` json\n{\n   \"SCRIPTS\": {\n      \"SECP256K1_BLAKE160\": {\n         \"TX_HASH\": \"\u003ctx_hash from ckb-cli rpc get_block_by_number —number 0\u003e\",\n         \"\u003cother fields\u003e\": \"\u003c...\u003e\"\n      },\n      \"SECP256K1_BLAKE160_MULTISIG\": {\n         \"TX_HASH\": \"\u003ctx_hash from ckb-cli rpc get_block_by_number —number 0\u003e\",\n         \"\u003cother fields\u003e\": \"\u003c...\u003e\"\n      },\n      \"NFT\": {\n         \"CODE_HASH\": \"\u003cdata_hash from ./nft-validator/migrations/dev/{timestamp}.json\u003e\",\n         \"HASH_TYPE\": \"data\",\n         \"TX_HASH\": \"\u003ctx_hash from ./nft-validator/migrations/dev/{timestamp}.json\u003e\",\n         \"INDEX\": \"0x0\",\n         \"DEP_TYPE\": \"code\"\n      }\n   }\n}\n```\n\n\nbuild node project\n```\n$ cd ./nft-glue\n$ yarn\n$ npx tsc\n```\n\nuse lib\n```\n$ node --experimental-repl-await\n\n# import lib\nnode\u003e glue = require(\"./lib/index\")\n\n# is []\nnode\u003e await glue.listNftTokens(glue.ADDRESS.ALICE.LOCK)\n\n# generate NFT token \nnode\u003e skeletion = await glue.generateNftToken(glue.ADDRESS.ALICE.ADDRESS, glue.ADDRESS.ALICE.LOCK, glue.ADDRESS.ALICE.ADDRESS)\n\n# mint a NFT for Alice\nnode\u003e await glue.signAndSendTransactionSkeleton(skeletion, glue.ADDRESS.ALICE.PRIVATE_KEY)\n\n# wait a moment, and we can find minted nft\nnode\u003e await glue.listNftTokens(glue.ADDRESS.ALICE.LOCK)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnervosnetwork%2Fdapps-on-ckb-workshop-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnervosnetwork%2Fdapps-on-ckb-workshop-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnervosnetwork%2Fdapps-on-ckb-workshop-code/lists"}