#run-time #substrate #smart-contracts #wasm

no-std ceres-runtime

Runtime ink! contract anywhere!

Show the crate…

2 unstable releases

0.2.0 Aug 2, 2021
0.1.0 Jun 14, 2021

#517 in #substrate


Used in 2 crates

MIT license

135KB
2.5K SLoC

Ceres Runtime

crate doc downloads LICENSE

The wasm executor of ink! contract

This repo provides:

  • Parsing *.contract to ABI and wasm source
  • A wasm runtime for executing ink! contract
    • Few interfaces

Design


- - - - - - - - -      - - - - -      - - - - - - -
| ink! contract | ---> | ceres | ---> |  anywhere |
- - - - - - - - -      - - - - -      - - - - - - -

Example

use ceres_runtime::Runtime;

#[test]
fn test_flipper() {
    let mut rt = Runtime::from_contract(include_bytes!("../flipper.contract"))
        .expect("Create runtime failed");

    rt.deploy("default", &[]).expect("Deploy failed");
    assert_eq!(&rt.call("get", &[]).expect("Call contract failed"), &[0]);

    rt.deploy("new", &["true"]).expect("Deploy failed");
    assert_eq!(&rt.call("get", &[]).expect("Call contract failed"), &[1]);

    rt.call("flip", &[]).expect("Call contract failed");
    assert_eq!(&rt.call("get", &[]).expect("Call contract failed"), &[0]);
}

LICENSE

MIT

Dependencies

~4–13MB
~177K SLoC