尝试编译 NEAR 智能合约时出现以下错误,但仅在编译为 wasm 目标时
Compiling nep9000 v0.1.0 (/Users/mikkoohtamaa/code/advanced-fungible-token/contract)
error[E0433]: failed to resolve: use of undeclared type or module `near_blockchain`
--> src/token.rs:144:1
|
144 | #[near_bindgen]
| ^^^^^^^^^^^^^^^ use of undeclared type or module `near_blockchain```
正常 cargo build
没关系。
最佳答案
看来您需要声明 #[near_bindgen]
两个struct
和 impl
契约(Contract),impl
只有是不够的。
#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize)]
pub struct Token {
...
}
#[near_bindgen]
impl Token {
...
}
关于nearprotocol - 使用未声明的类型或模块 near_blockchain,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64109605/