This implements the ink! side implementation of Substrate PR #5103: https://github.com/paritytech/substrate/pull/5103