0

Here are the steps i have done:

  1. cargo contract new flipper

  2. in contract code i added these lines of code:

  3. use blst::min_pk::SecretKey; after #![cfg_attr(not(feature = "std"), no_std)] & changed this function:

    #[ink(message)]
    pub fn flip(&mut self) {
        let ikm = [0u8; 32];
        let sk = SecretKey::key_gen(&ikm,&[]).unwrap();
        ink_env::debug_print!("{:?}",sk);
        self.value = !self.value;
    }
    
  4. Run command cargo add blst

  5. After the completion, my Cargo.toml file changed dependencies by adding

    blst = "0.3.10"

  6. When i run: cargo+nightly contract build, i got error and warning: enter image description here

  7. SecretKey is a struct that can be found in blst::min_pk directory. Its a dependence that can be found on github. I can link it if need.

Any help how do i fix this error? If you need more information, just tell me and i will provide!

Here is full Cargo.toml: here is full Cargo.toml :

[package]
name = "testX"
version = "0.1.0"
authors = ["[your_name] <[your_email]>"]
edition = "2021"

[dependencies]
ink_primitives = { version = "3.3", default-features = false }
ink_metadata = { version = "3.3", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "3.3", default-features = false }
ink_storage = { version = "3.3", default-features = false }
ink_lang = { version = "3.3", default-features = false }

scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }
blst = "0.3.10"

[lib]
name = "testX"
path = "lib.rs"
crate-type = [
    # Used for normal contract Wasm blobs.
    "cdylib",
]

[features]
default = ["std"]
std = [
    "ink_metadata/std",
    "ink_env/std",
    "ink_storage/std",
    "ink_primitives/std",
    "scale/std",
    "scale-info/std",
]
ink-as-dependency = []
2
  • can you add Cargo.toml as well?
    – go11li
    Commented Dec 14, 2022 at 12:09
  • added in question! Commented Dec 14, 2022 at 12:12

1 Answer 1

1

this specific error display if you are adding use blst::min_pk::SecretKey; outside mod instead put inside mod flipper { use blst::min_pk::*; } but still this also throws duplicate lang item in crate 'std' error, have a look here for further error

4
  • yes, you are right. I got : error[E0463]: can't find crate for panic_abort` ` and ` error[E0152]: duplicate lang item in crate std (which blst depends on): panic_impl. ` Is there a solution trough link you sent me? Commented Dec 14, 2022 at 13:33
  • for solution they have suggested to write or update crate which support no_std
    – go11li
    Commented Dec 14, 2022 at 13:41
  • hmm.. i dont like that.. i hope there might be some other solution... Commented Dec 14, 2022 at 13:44
  • sadly there is no other solution @NikolaBozin
    – kriko.eth
    Commented Dec 16, 2022 at 0:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.