nearprotocol - 使用未声明的类型或模块 near_blockchain

标签 nearprotocol

尝试编译 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]两个structimpl契约(Contract),impl只有是不够的。

#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize)]
pub struct Token {
   ...
}


#[near_bindgen]
impl Token {

   ...
}

关于nearprotocol - 使用未声明的类型或模块 near_blockchain,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64109605/

相关文章:

nearprotocol - 托管和多重签名合约

nearprotocol - 如何获取 NEAR 中某个区 block 的所有交易?

nearprotocol - 如何从地址调用不同的合约?

nearprotocol - 为什么在 NEAR 上开户需要代币?

rust - 两个 NEAR 协议(protocol)智能合约之间的交叉通信命名结构是如何确定的?

rust - 如何捕获NEAR samart契约(Contract)日志(env::log)?

nearprotocol - 当我尝试对任何合约进行开发部署时,我得到 `BadRequestError`

rust - 在近协议(protocol)合约的函数中返回多个值

nearprotocol - 如何使用 AssemblyScript 在 NEAR 合约上使用 PersistentUnorderedMap?初始化后 PersistentUnorderedMap 不会出现在合约存储中

nearprotocol - 获取交易的区 block 高度 使用帐户 ID 创建帐户 NEAR 协议(protocol)