Giter Club home page Giter Club logo

elton01 / liquid Goto Github PK

View Code? Open in Web Editor NEW

This project forked from webankblockchain/liquid

0.0 0.0 0.0 818 KB

Liquid 由微众银行区块链团队开发并完全开源,是一种嵌入式领域特定语言( embedded Domain Specific Language,eDSL),能够用来编写运行于区块链底层平台FISCO BCOS的智能合约。

Home Page: https://liquid-doc.readthedocs.io/zh_CN/latest/

License: Apache License 2.0

Shell 0.62% Rust 98.68% Batchfile 0.71%

liquid's Introduction

Liquid - Makes Smart Contract Smarter

GitHub license Code Lines Latest release Language

Liquid 由微众银行区块链团队开发并完全开源,是一种嵌入式领域特定语言( embedded Domain Specific Language,eDSL),能够用来编写运行于区块链底层平台FISCO BCOS的智能合约。

关键特性

安全(Security)

  • 支持在智能合约内部便捷地编写单元测试用例,可通过内嵌的区块链模拟环境直接在本地执行;

  • 算数溢出及内存越界安全检查;

  • 能够结合模糊测试等工具进行深度测试;

  • 未来将进一步集成形式化验证及数据隐私保护技术。

性能(Performance)

  • 配合 LLVM 优化器,支持将智能合约代码编译为可移植、体积小、加载快 Wasm 格式字节码;

  • 对 Wasm 执行引擎进行了深度优化,并支持交易并行化等技术;

  • 结合 Tree-Shaking 等技术,进一步压缩智能合约体积。

体验(Experience)

  • 支持使用大部分现代语言特性(如移动语义及自动类型推导等);

  • 提供专有开发工具及编辑器插件辅助开发;

  • 丰富的标准库及第三方组件。

可定制(Customization)

  • 能够根据业务需求对编程模型、语言文法的进行深度定制。

  • 未来还将进一步探索如何与隐私保护、跨链协同等功能相结合。

合约示例

使用 Liquid 编写的 HelloWorld 合约如下所示:

#![cfg_attr(not(feature = "std"), no_std)]

use liquid::storage;
use liquid_lang as liquid;

#[liquid::contract]
mod hello_world {
    use super::*;

    #[liquid(storage)]
    struct HelloWorld {
        name: storage::Value<String>,
    }

    #[liquid(methods)]
    impl HelloWorld {
        pub fn new(&mut self) {
            self.name.initialize(String::from("Alice"));
        }

        pub fn get(&self) -> String {
            self.name.clone()
        }

        pub fn set(&mut self, name: String) {
            self.name.set(name)
        }
    }

    #[cfg(test)]
    mod tests {
        use super::*;

        #[test]
        fn get_works() {
            let contract = HelloWorld::new();
            assert_eq!(contract.get(), "Alice");
        }

        #[test]
        fn set_works() {
            let mut contract = HelloWorld::new();

            let new_name = String::from("Bob");
            contract.set(new_name.clone());
            assert_eq!(contract.get(), "Bob");
        }
    }
}

技术文档

阅读Liquid 在线技术文档,详细了解如何使用 Liquid。

架构设计

架构设计

社区

最小支持 Rust 版本(Minimum Supported Rust Version,MSRV)

Rust Nightly 1.52 或更高。

License

Liquid 的开源协议为 Apache License 2.0,详情请参考LICENSE

liquid's People

Contributors

vita-dounai avatar bxq2011hust avatar kyonray avatar cyjseagull 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.