The Inkpad CLI can be installed with:
cargo install inkpad-cli
We can use the inkpad
binary to explore the usages of inkpad library.
inkpad 0.2.0
Inkpad command tool
USAGE:
inkpad [*.contract | name | code-hash] <SUBCOMMAND>
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
ARGS:
<*.contract | name | code-hash> If empty, inkpad will load the last contract which has been executed
SUBCOMMANDS:
call Calls a call method
deploy Calls a deploy method
help Prints this message or the help of the given subcommand(s)
info Prints info of *.contract
list Lists all contracts
- lightweight. Inkpad is a standalone ink! contract environment that scales with your needs, Inkpad can be embedded into almost any application.
- debugging. Inkpad built with the traps handlers of both
wasmi
andwasmtime
, it supports catching the traps of the wasm binary of ink! contracts - tests. With Inkpad, you can write tests of ink! contract with full-features of the chain api
- customized. The runtime of inkpad works with various of rust
trait
that we can configure it blazing flexible.
You can use Inkpad from a variety of different platforms:
- Rust - the inkpad-runtime crate
- Browser - the inkpad-browser crate
- Command Line - the inkpad-cli crate
// test flipper.contract
use inkpad_ri::Instance;
use inkpad_runtime::Runtime;
use parity_scale_codec::Encode;
#[test]
fn test_flipper() {
let mut rt = Runtime::contract(
include_bytes!("./flipper.contract"),
Some(Instance),
)
.expect("Create runtime failed");
rt.deploy("default", vec![], None).expect("Deploy failed");
assert_eq!(rt.call("get", vec![], None), Ok(Some(vec![0])));
rt.deploy("new", vec![true.encode()], None)
.expect("Deploy failed");
assert_eq!(rt.call("get", vec![], None), Ok(Some(vec![1])));
rt.call("flip", vec![], None).expect("Call contract failed");
assert_eq!(rt.call("get", vec![], None), Ok(Some(vec![0])));
}
Inkpad extracted from sp-sandbox
and pallet-contracts
of substrate
with both wasmi
and wasmtime
features, plus trap handlers for the
two executors.
It abstracts the chain environment which ink! contracts requires so that we can embed inkpad almost any applications to run ink! contracts.
Run ink! contract anywhere!