Coder Social home page Coder Social logo

namqdam / cell-script Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cell-labs/cell-script

0.0 0.0 0.0 218 KB

Cell Script is a new designed language for smart-contract programming on UTXO chain, currently supports CKB.

Home Page: https://cellscript.io

Shell 0.11% Go 95.81% ANTLR 2.04% Makefile 1.74% LLVM 0.31%

cell-script's Introduction

Cell Script

Cell Script is a newly designed language for smart-contract programming on the UTXO chain, which currently supports CKB.

Example

Here is an example of a simple cell script.

import "debug"
import "tx"
import "cell"

// main is the entry point of every cell script
function main() {
    tx.scriptVerify()
    var ins = tx.inputs()
    var outs = tx.outputs()

    var in_sum uint64
    var out_sum uint64

    for _, input := range ins {
        in_sum += input
        if in_sum < input {
            debug.Printf("input overflow")
            return 1
        }
    }

    for _, output := range outs {
        out_sum += output
        if out_sum < output {
            debug.Printf("output overflow")
            return 1
        }
    }

    if in_sum < out_sum {
        debug.Printf("Invalid Amount")
        return 1
    }
    
    return 0
}

The ideas and specs can be found here.

The internal discussion can be found here.

How to build (MacOS)

brew install [email protected]
brew install antlr@4
brew install openjdk@21
brew install llvm@16
brew tap riscv-software-src/riscv
brew install riscv-tools
export PATH=/opt/homebrew/bin:$PATH
brew install --cask spike
make build
source install.sh

cell <file>.cell
cargo install --git https://github.com/nervosnetwork/ckb-standalone-debugger ckb-debugger
ckb-debugger --bin <file>

How to Deploy?

git clone [email protected]:cell-labs/cell-cli.git
cd cell-cli
npm install
npm install -g .
# 1、Copy the cell bin file to the Cell-Cli folder: exmple: helloworld
# 2、Enter your CKB private key in cell.config.js
cell-cli deploy ./helloworld

cell-script's People

Contributors

xrdavies avatar douyixuan avatar lazy1523 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.