RGB wallet can't deploy on Canister

I want to integrate an RGB wallet into an IC canister. After importing and using rgb-std, the code can compile successfully, but I encounter an error during deployment.

Installing canisters…
Upgrading code for canister smartwallet, with canister ID bd3sg-teaaa-aaaaa-qaaba-cai
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
Failed while trying to install all canisters.
Failed to install wasm module to canister ‘smartwallet’.
Failed during wasm installation call: The replica returned a replica error: reject code CanisterError, reject message Wasm module of canister bd3sg-teaaa-aaaaa-qaaba-cai is not valid: Wasm module has an invalid import section. Module imports function ‘__wbindgen_describe’ from ‘wbindgen_placeholder’ that is not exported by the runtime., error code None

the dependencies in project root Cargo.toml:

# for RGB

amplify = "4.6.0"

strict_encoding = "2.7.0-beta.1"

strict_types = "2.7.0-beta.1"

aluvm = "0.11.0-beta.4"

bp-core = "0.11.0-beta.4"

rgb-std = { version = "0.11.0-beta.4", features = ["serde"] }

# rgb-schemata = "0.11.0-beta.4"

serde = "1.0"

serde_json = "1.0"

sha2 = "0.10.8"


rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "master" }

rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "master" }

and the dependencies in workspace package:

crate-type = ["cdylib"]

candid = "0.10"
ic-cdk = "0.12"
ic-cdk-timers = "0.6" # Feel free to remove this dependency if you don't need timers

rgb-std = { workspace = true }
amplify = { workspace = true }
strict_encoding = { workspace = true }
strict_types = { workspace = true }
aluvm = { workspace = true }
bp-core = { workspace = true }
# rgb-std = { version = "0.11.0-beta.4", features = ["serde"] }
# rgb-schemata = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
sha2 = { workspace = true }

and the code in main.rs is:

use amplify::hex::FromHex;
use rgbstd::Txid;

fn greet(name: String) -> String {
    // let beneficiary_txid = 
        // Txid::from_hex("14295d5bb1a191cdb6286dc0944df938421e3dfcbf0811353ccac4100c2068c5").unwrap();
    // let beneficiary = Outpoint::new(beneficiary_txid, 1);

    // let contract = NonInflatableAsset::testnet("TEST", "Test asset", None, Precision::CentiMicro)
    //     .expect("invalid contract data")
    //     .allocate(Method::TapretFirst, beneficiary, 1_000_000_000_000u64.into())
    //     .expect("invalid allocations")
    //     .issue_contract()
    //     .expect("invalid contract data");

    // let contract_id = contract.contract_id();

    format!("Hello, {} !", name)

the source code: https://github.com/lshoo/rgbonic

How to solve this error?

One of your dependencies is trying to use a feature that’s not available under wasm32-unknown-unknown. You probably have to turn off some features to get it to deploy

thanks @Severin
the rgb crates supported wasm by default,not need to turn off some features。

Does anyone have time to try the code?

How did you build it?

I’m getting errors running

cargo build --release --target wasm32-unkown-unkown

I also tried an even simpler project using rgb-std but could not even build it:

error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "depend/secp256k1-zkp/" "-I" "depend/secp256k1-zkp/include" "-I" "depend/secp256k1-zkp/src" "-Wall" "-Wextra" "-g" "-DUSE_NUM_NONE=1" "-DUSE_FIELD_INV_BUILTIN=1" "-DUSE_SCALAR_INV_BUILTIN=1" "-DUSE_FIELD_10X26=1" "-DUSE_SCALAR_8X32=1" "-DUSE_ENDOMORPHISM=1" "-DENABLE_MODULE_ECDH=1" "-DENABLE_MODULE_GENERATOR=1" "-DENABLE_MODULE_RECOVERY=1" "-DENABLE_MODULE_RANGEPROOF=1" "-DENABLE_MODULE_BULLETPROOF=1" "-DENABLE_MODULE_AGGSIG=1" "-DENABLE_MODULE_SCHNORRSIG=1" "-o" "/Users/domwoe/Dev/debug/rgb/target/wasm32-unknown-unknown/release/build/lnpbp_secp256k1zkp-a4bcb9ddeccfc582/out/5c5b8ae0486a27a2-lax_der_parsing.o" "-c" "depend/secp256k1-zkp/contrib/lax_der_parsing.c" with args "clang" did not execute successfully (status code exit status: 1).

Seems to be some local issue with clang on my machine…

In general, the issue is that the wasm support of the project is targeting the browser. It uses wasm bindgen and wasi. One thing you could try is to use GitHub - wasm-forge/wasi2ic: WASI dependency replacer for the *.wasm files

Good luck!


I build the code with dfx build successfully, but I got the error when I run dfx deploy or dfx canister install rgb.

I’ll try the wasm-forge/wasi2ic and extism with RGB, thanks

Thanks a lot @domwoe
After I use wasm-forge/wasi2ic and translate the wasm, it works temporarily now.

I updated the readme that how to run it.

1 Like

Awesome! I’m looking forward to what you’ll build with this. One note though, if you want to do signatures you shouldn’t rely on the implementation in the library, but use the threshold ECDSA signing API if possible.

Thanks @domwoe

What is this mean? and how to do