【问题标题】:How is the cross communication naming structure between two NEAR protocol smart contracts determined?两个 NEAR 协议智能合约之间的交叉通信命名结构是如何确定的?
【发布时间】:2021-01-19 19:30:22
【问题描述】:

在两个 NEAR 协议智能合约之间进行通信时。合约B如何访问合约A?

这个问题How to call different contract from its address? 涵盖了这一点,但没有说明如何确定命名结构。

使用来自https://github.com/near/core-contracts/blob/cd221798a77d646d5f1200910d45326d11951732/lockup/src/lib.rs#L64-L67的这个例子

#[ext_contract(ext_whitelist)]
pub trait ExtStakingPoolWhitelist {
    fn is_whitelisted(&self, staking_pool_account_id: AccountId) -> bool;
}

ext_whitelist 上面的合约是否部署为 ext_whitelist.near?搜索near explorer好像没有账号ext_whitelist.near

如何识别具有不同命名空间的另一个合约?

例如,contract1.contracts.near 是否会被识别为来自任何 .near 地址的#[ext_contract(contract1.contracts)] 和来自contracts.near 地址的#[ext_contract(contract1)]

【问题讨论】:

    标签: rust blockchain nearprotocol


    【解决方案1】:

    我不确定我是否正确理解了这个问题。

    但是 Rust 宏输入创建了 Rust 对象(如果我在这里使用了不正确的术语,请原谅)与合约进行通信。您可以在多个合约中重复使用相同的 ext_whitelist 对象。

    合约调用时会传递合约的实际地址:

    
                ext_status_message::get_status(
                    env::signer_account_id(),
                    &account_id,
                    0,
                    SINGLE_CALL_GAS,
                ),
    

    最后三个参数是

    • 合约地址是account_id

    • 0 - 我不知道

    • 分配气体

    这不是很优雅的设计选择,因为阅读和使用非常混乱。我建议像在其他区块链中一样创建 Contract 实例,而不是显式地将合约地址传递给每个合约调用。

    【讨论】:

    • - 0 附加存款。
    猜你喜欢
    • 2022-06-22
    • 2021-08-18
    • 2021-01-14
    • 2020-03-13
    • 2021-06-14
    • 2021-01-12
    • 1970-01-01
    • 1970-01-01
    • 2021-01-19
    相关资源
    最近更新 更多