0

Based on this example

I'm doing something similar:

#[ink(message)]
        pub fn new_multisig(&mut self, threshold: u8, owners_list: Vec<AccountId>, salt: Vec<u8>) {
            let multisig = build_create::<MultiSigRef>()
                .code_hash(self.multisig_codehash)
                .gas_limit(0)
                .endowment(0)
                .exec_input(
                    ExecutionInput::new(Selector::new(ink::selector_bytes!("new")))
                        .push_arg(threshold)
                        .push_arg(owners_list),
                )
                .salt_bytes(salt)
                .returns::<MultiSigRef>()
                .instantiate();

            self.env().emit_event(NewMultisig {
                multisig_address: multisig, //Here i need to get the address of the new contract
                threshold: threshold,
                owners_list: owners_list,
            });
        }

But I need to obtain the address of the instantiated contract. How can I do it?

1 Answer 1

5

You can use to_account_id method to obtain address of instantiated smart contract.

use ink::ToAccountId;

let contract_address = multisig.to_account_id();
1
  • Hey! That worked, but i also needed to import the trait: use ink::ToAccountId;
    – Luca Auet
    Commented Aug 1, 2023 at 12:13

Your Answer

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

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