0

Based on the ink! Cross-Contract Calling documentation, I want to reference other smart contract and instantiate it more than once. That would be possible?

I tried to do it but when I execute the logic twice I get a Duplicate Contract error. I don't know if I have to send different parameters to salt_bytes() or if this is not possible right now with ink.

I let you an example of what I have been trying:

let new_contract = ContractRef::new(owner)
            .endowment(0)
            .code_hash(self.contract_hash)
            .salt_bytes(self.version.to_le_bytes())
            .instantiate()
            .expect("failed at instantiating the contract");

Thanks!

1
  • Does anybody know where I can find documentation on ContractRef? I am unsure where the methods such as .endowment() come from.
    – Jolow
    Sep 29, 2022 at 17:09

1 Answer 1

2

Did you use the same salt when instantiating for the second time? Looks to me like it might be the problem, since the salt is used to determine contract's account ID.

1
  • I tried modifying the salt and was successful. I was about to share it. Thank you! Aug 25, 2022 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.