How do I get the sender's address on contract initialization call

I need to save the address of the account that initialised a contract in a creator state, like so:

let acc = match ctx.sender() {
          Address::Account(acc) => acc,
          Address::Contract(_) => return Err(ContractError::ContractVoter),
 };

But I’m getting this error: the following trait defines an item sender, perhaps you need to restrict type parameter impl HasInitContext with it:: ` + concordium_std::HasReceiveContext

Please help. Thanks.

Use init_origin.

1 Like