wasmx/wasm-chisel

error[E0463]: can't find crate for `chisel`

AchalaSB opened this issue · 3 comments

When I run my rust contract I got error forchisel
Here is my code. TIA

#![feature(proc_macro, wasm_custom_section, wasm_import_module)]
extern crate chisel;
extern crate ewasm_api;

#[no_mangle]
pub extern "C" fn add_one(name :&str) {
    println!("hello")
}

Here's log

cargo build
   Compiling rust_contract v0.1.0 (/home/achala/Codes/kip-gitlab/kide/templates/empty_rust)
error[E0463]: can't find crate for `chisel`
 --> src/lib.rs:2:1
  |
2 | extern crate chisel;
  | ^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: Could not compile `rust_contract`.

To learn more, run the command again with --verbose.

Hi @AchalaSB
A couple things to note:
1.) You need to add chisel to your Cargo.toml to use it.
2.) chisel is the binary, you need to use libchisel to interact with it programmatically.
3.) wasm-chisel is not intended for use as part of a contract. It is an external tool to verify or amend wasm binaries and contracts.

Thanks @jakelang
Reinstalling cargo install chisel worked for me, now I'm not using concept of Cargo.toml
Can you give me simple hello world contract.
I have gone through https://github.com/ewasm/testnet/blob/ed854ab7b8dfddc511e13ffb281d46845c001608/rust.md
But I'm not aware of how to use finish or revert function in my code(for simple hello world contract)

extern crate ewasm_api;
#[no_mangle]
pub extern "C" fn main() {
    println!("hello")
}

@AchalaSB println is not supported in ewasm contracts, as that is designed to write to the terminal's stdout.
That contract should instead use finish_data("Hello, World") and calling the deployed contract will return the corresponding bytes.