在 Solidity(以太坊)中,需要合约地址来调用该合约。
contract KittyInterface {
function getKitty(uint256 _id) external view returns (
bool isGestating,
bool isReady,
uint256 cooldownIndex,
uint256 nextActionAt,
uint256 siringWithId,
uint256 birthTime,
uint256 matronId,
uint256 sireId,
uint256 generation,
uint256 genes
);
}
contract ZombieFeeding is ZombieFactory {
address ckAddress = 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d;
KittyInterface kittyContract = KittyInterface(ckAddress);
我可以在近协议(protocol)中做到这一点吗? 附近的示例有所不同,需要提供 wasm 文件。 https://github.com/near-examples/rust-high-level-cross-contract
pub fn deploy_status_message(&self, account_id: String, amount: u64) {
Promise::new(account_id)
.create_account()
.transfer(amount as u128)
.add_full_access_key(env::signer_account_pk())
.deploy_contract(
include_bytes!("../status-message-contract/status_message.wasm").to_vec(),
);
}
此外,我在使用高级交叉合约代码时遇到错误。 https://gateway.ipfs.io/ipfs/QmPvcjeEE5PJvaJNN2axgKVWGbWVEQCe9q4e95t9NCeGFt/
最佳答案
请看一下锁定合约示例。它使用以下内容:
ext_whitelist::is_whitelisted(
staking_pool_account_id.clone(),
&self.staking_pool_whitelist_account_id,
NO_DEPOSIT,
gas::whitelist::IS_WHITELISTED,
)
.then(ext_self_owner::on_whitelist_is_whitelisted(
staking_pool_account_id,
&env::current_account_id(),
NO_DEPOSIT,
gas::owner_callbacks::ON_WHITELIST_IS_WHITELISTED,
))
第一个调用接口(interface)是(<arg_0>, <arg_1>, ..., <arg_n>, <ACCOUNT_ID>, <ATTACHED_DEPOSIT>, <ATTACHED_GAS>)
-
<arg_0>, <arg_1>, ..., <arg_n>
- 来自下面定义的接口(interface)的参数 -
<ACCOUNT_ID>
- 部署要调用的合约的账户 -
<ATTACHED_DEPOSIT>
- 附加到通话的 yocto-NEAR 金额 -
<ATTACHED_GAS>
- 传递给调用的 Gas 量
后来它使用 .then
将回调附加到第一个 Promise。 。回调只是另一个异步函数调用。
高级接口(interface)ext_whitelist
定义如下:
#[ext_contract(ext_whitelist)]
pub trait ExtStakingPoolWhitelist {
fn is_whitelisted(&self, staking_pool_account_id: AccountId) -> bool;
}
关于nearprotocol - 如何从地址调用不同的合约?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63879405/