简体   繁体   中英

error[E0412]: cannot find type `String` in this scope

#![cfg_attr(not(feature = "std"), no_std)]

use ink_lang as ink;

#[ink::contract]

mod XYZ {

    #[ink(storage)]
    pub struct Xyz {
        token_id: u32,
        serial_code: String
    }
    ...
}

Error:

             serial_code: String
   |                      ^^^^^^ not found in this scope

Based on this - you should use the String type included in ink!

use ink_prelude::string::String;

And include in the correct Cargo.toml file:

[Dependencies]
ink_prelude = { version = "2", git = "github.com/paritytech/ink", tag = "latest-v2", package = "ink_prelude", default-features = false }"

(or whatever version is correct for you)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM