-
Notifications
You must be signed in to change notification settings - Fork 447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need an example to show how to use trait-contract as a storage in contract. #590
Comments
for example the trait-contract may could be used like(I guess): #[ink(storage)]
pub struct ExampleContract {
holder: Lazy<dyn BaseErc20>,
} to receive different erc20 implementation. (But I can't compile it now). Thus the final thing what I expect is like the interface in solidity. The caller contract could load an Address to an interface and call the real contract. But now I don't know how to use |
I think I figure out how to use contract A crate is depended by contract B crate, like use ink_env::call::FromAccountId;
let instance: A = A::from_account_id(address); to load contract A from an address/account_id. But now I still don't know how to use trait-contract as a storage. |
This has not yet been implemented for ink! but we are aware that this is needed and are already working out some possible designs for this feature. |
Closed since superseeded by #631. |
Is there a way to load a contract from an AccountId directly?
Describe the details
Example
delegator
andmultisig_plain
show how to do a contract call another contract. However I'm interesting in that whether ink! allow to load a contract from an AccountId?In example
delegator
, the contract call should pass the contract type, and in examplemultisig_plain
, the contract allow to pass an AccountId, but call some function need to pass the selector and encoded params.So is there a way to load a contract from an AccountId? I look though the code and find the trait:
But there is no example to show how to use this trait. And in expanded code for a contract, this trait is not implemented for the contract.
Thus, I don't know whether this thing "load a contract from an AccountId" is allowed?
If this thing is allowed, then, how can I use it?
(
Sorry for I don't understand the doc comments in create_builder.rs file:
https://github.com/paritytech/ink/blob/3803a2662e89dfa97b6f8b17e87c0cce2d873f48/crates/env/src/call/create_builder.rs#L146-L164
)
In my mind, what I expect is like:
And it seems that the
trait-*
design like the example "trait-erc20", "trait-flipper" is a way to solve this situation? May be we need more example to show how to usetrait-*
contract to design a contract specification.The text was updated successfully, but these errors were encountered: