When communicating between two NEAR protocol smart contracts. How is contract A accessed by contract B?
This question How to call different contract from its address? covers this but doesn't specify how the naming structure is determined.
Using this example from 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;
}
Is the contract above ext_whitelist deployed as ext_whitelist.near? Searching the near explorer There does not appear to be an account ext_whitelist.near
How would another contract with a different namespace be identified?
eg would contract1.contracts.near
be identified like #[ext_contract(contract1.contracts)]
from any .near address and #[ext_contract(contract1)]
from the contracts.near
address?
I am not sure if I understand the question correctly.
But Rust macro input on created the Rust object (pardon if I use incorrect terminology here) to communicate with the contract. You can re-use the same
ext_whitelist
object across multiple contracts.The actual address of the contract is passed when you make a contract call:
The last three arguments are
Contract address is account_id
0 - I have no idea
Allocated gas
This is not very elegant design choice, as it is very confusing to read and use. I would suggest creating
Contract
instances like in other blockchains, instead of explicitly passing the contract address to every contract call.