GithubHelp home page GithubHelp logo

nervosnetwork / ckb-cheque-script Goto Github PK

View Code? Open in Web Editor NEW

This project forked from duanyytop/ckb-cheque-script

0.0 2.0 3.0 5.19 MB

The lock script of cheque cell on Nervos CKB

License: MIT License

Rust 86.91% Makefile 6.09% Shell 0.73% C 6.27%

ckb-cheque-script's Introduction

ckb-cheque-script

License Github Actions CI

The lock script of cheque cell on Nervos CKB using Capsule

Pre-requirement

Note: Capsule uses docker to build contracts and run tests. https://docs.docker.com/get-docker/ and docker and ckb-cli must be accessible in the PATH in order for them to be used by Capsule.

Getting Started

  • Init submodules:
git submodule init && git submodule update -r --init
  • Generator static linking for secp256k1:
cd contracts/ckb-cheque-script/ckb-lib-secp256k1/ckb-production-scripts
git submodule init && git submodule update
cd .. && make all-via-docker
  • Build contracts:
# back to repo root directory
cd ../../..
capsule build
  • Run tests
capsule test

Deployment

1. Update the deployment configurations

Open deployment.toml :

  • cells describes which cells to be deployed.

    • name: Define the reference name used in the deployment configuration.
    • enable_type_id : If it is set to true means create a type_id for the cell.
    • location : Define the script binary path.
    • dep_groups describes which dep_groups to be created. Dep Group is a cell which bundles several cells as its members. When a dep group cell is used in cell_deps, it has the same effect as adding all its members into cell_deps. In our case, we don’t need dep_groups.
  • lock describes the lock field of the new deployed cells.It is recommended to set lock to the address(an address that you can unlock) of deployer in the dev chain and in the testnet, which is easier to update the script.

2. Build release version of the script

The release version of script doesn’t include debug symbols which makes the size smaller.

capsule build --release

3. Deploy the script

capsule deploy --address <ckt1....> --fee 0.001

If the ckb-cli has been installed and dev-chain RPC is connectable, you will see the deployment plan:

new_occupied_capacity and total_occupied_capacity refer how much CKB to store cells and data. txs_fee_capacity refers how much CKB to pay the transaction fee.

Deployment plan:
---
migrated_capacity: 0.0 (CKB)
new_occupied_capacity: 129352.0 (CKB)
txs_fee_capacity: 0.003 (CKB)
total_occupied_capacity: 129352.0 (CKB)
recipe:
  cells:
    - name: ckb-cheque-script
      index: 0
      tx_hash: "0x56353f036c04b153eaa6ef31a8637fb673b255fa62becf1c253b00aace643ae1"
      occupied_capacity: 58414.0 (CKB)
      data_hash: "0x617bfa9727d99fbc094a485d14842128f4224260b62278412f44cf2951e512ba"
      type_id: "0x17340bcdef33d40b0ddaeb1a2f5152f579c7e08088977dfb600abf44049ff173"
    - name: secp256k1_blake2b_sighash_all_dual
      index: 0
      tx_hash: "0xf15d81696d1e2fd9e1e128ca95fb8ee3263e04961323ca1e74b8809cb4529828"
      occupied_capacity: 70765.0 (CKB)
      data_hash: "0xa01d57f854cc965cd8850c06691d666f933d8389d693266273bd6c47753cf447"
      type_id: ~
  dep_groups:
    - name: dep_group
      tx_hash: "0x2ebd890517f1a54f5f1a0084bd2111203266d6c321b190232f3ceaa322ef7fd5"
      index: 0
      occupied_capacity: 173.0 (CKB)

4. Type yes or y and input the password to unlock the account.

(1/3) Sending tx 56353f036c04b153eaa6ef31a8637fb673b255fa62becf1c253b00aace643ae1
(2/3) Sending tx f15d81696d1e2fd9e1e128ca95fb8ee3263e04961323ca1e74b8809cb4529828
(3/3) Sending tx 2ebd890517f1a54f5f1a0084bd2111203266d6c321b190232f3ceaa322ef7fd5
Deployment complete

Now the cheque script has been deployed, you can refer to this script by using tx_hash: 2ebd890517f1a54f5f1a0084bd2111203266d6c321b190232f3ceaa322ef7fd5 index: 0 as out_point(your tx_hash should be another value).

ckb-cheque-script's People

Contributors

duanyytop avatar shaojunda avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.