6

Previously in Ink! 3, in a function which is accepting AccountId as a parameter, One can validate that the address passed is not AddressZero by using .is_zero() on the parameter variable name but I can't do on my current Ink! 4 project... Honestly would want to step down to Ink3!

1

1 Answer 1

7

An easy method you can use to get the AddressZero is this:

fn zero_address() -> AccountId {
    [0u8; 32].into()
}

And compare it to another address, see an example here:

ensure!(to != zero_address(), Error::ZeroAddressTransfer);

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.