I was attempting to comprehend the workings of cross-contract calling in substrate ink contracts using this particular sample code.

If I provide u64::MAX as the calls_count value, it will result in a failure, what should the end user expect to receive when invoking the test_cross_contract_call function?

pub fn test_cross_contract_call(&mut self, callee: AccountId, calls_count: u64) {
            let selector: Selector = Selector::new([0x6b, 0x25, 0xcb, 0x19]);
            let response: u64 = build_call::<DefaultEnvironment>()
            self.value = response;

#[ink(message, selector = 0x6b25cb19)]
pub fn dummy_function(&mut self, value: u64) -> u64 {
            return 45 * value;

1 Answer 1


The call to dummy_function is going to overflow because n * u64::MAX > u64, meaning your contract will trap.

Since you're using CallBuilder::invoke(), which panics upon any encountering any error, your caller contract will also trap.

If you want to attempt to handle errors you'll need to use CallBuilder::try_invoke() instead.

I assume you'll get a CalleeTrapped error due to the overflow, but I haven't tried it out myself.

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.