Skip to content

Latest commit

 

History

History
114 lines (86 loc) · 4.56 KB

README.md

File metadata and controls

114 lines (86 loc) · 4.56 KB

ink! - Parity's ink to write smart contracts

Linux Codecov Coveralls LoC Docs (Core) Docs (Model)
linux codecov coveralls loc docs docs

IMPORTANT NOTE: WORK IN PROGRESS! Do not expect this to be working.

ink is an eDSL to write WebAssembly based smart contracts using the Rust programming language.

Example

Below is an example using the eDSL demonstrating a simple Flipper smart contract that has a boolean state that can be flipped or returned.

contract! {
    /// Flips its state between `true` and `false`.
    struct Flipper {
        /// The current state of our flag.
        value: storage::Value<bool>,
    }

    impl Deploy for Flipper {
        /// Initializes our state to `false` upon deploying our smart contract.
        fn deploy(&mut self) {
            self.value.set(false)
        }
    }

    impl Flipper {
        /// Flips the current state of our smart contract.
        pub(external) fn flip(&mut self) {
            *self.value = !*self.value;
        }

        /// Returns the current state.
        pub(external) fn get(&self) -> bool {
            *self.value
        }
    }
}

Documentation

  • User
  • Developer
    • core: Developer documentation for the core abstractions
      • Storage allocators, SRML environment definitions
      • Offchain test environment
      • Utilities for smart contracts like collections
    • model: Developer documentation for the model abstractions
      • Virtual model of a smart contract
      • Contains smart contract ABI dispatch
      • Used to build an actual smart contract eDSL on

Goals

Core Goals

Ecosystem Easy integration with the Rust ecosystem.
Tooling Rust tooling works out-of-the-box for smart contract code. This includes auto-completion, syntax highlighting, code coverage for tests, go-to definitions and other IDE goodies.
Testing Easy to build, test, deploy and run.
Development Development can be done entirely off-chain to speed up the process.

Key Attributes

Efficient Compile smart contract code to machine code that is at least as efficient as if you used the low-level function calls directly.
Robust Make it as simple as possible to write code that just does what is expected and as difficult as possible to write incorrect or exploitable code.
Simple Smart contract code should be as easy-to-read as possible.
Accessible Make it accessible to users by providing excellent documentation and teaching materials.

Structure

Module Description
cli A minimalist tool to setup a smart contract project easily.
core The core utilities used to write smart contracts.
model Medium-level abstractions to write smart contracts heavily inspired by Fleetwood.
lang The actual eDSL based on ink_core and ink_model to provide a user friendly interface to writing smart contract code.
examples Features some smart contracts written for clarity with focus on teaching users how to use pDSL to write their own contracts.

Contribution

Visit our contribution guidelines for more information.

License

The entire code within this repository is licensed under the GLP-v3. Please contact us if you have questions about the licensing of our products. of our products.