4

I'm trying to make cross contracts calls on already deployed contract, I'm running the local subtrate node in debug mode, and I'm getting the following message when trying to preform cross contracts.

Here is the error:

ThreadId(34) runtime::contracts: Execution finished with debug buffer: panicked at 'called `Result::unwrap()` on an `Err` value: CalleeTrapped', erc20/lib.rs:102:14

Here is the DeployedContract1 cross call function code:

        #[ink(message)]
        #[ink(selector = 40)]
        pub fn test(&self) -> u32 {
            self.platform_fee
        }

Here is the DeployedContract2 (erc20/lib.rs) function source code:

        #[ink(message)]
        pub fn test1(&self,token_contract: AccountId) -> u32 {
            
            let my_return_value: u32 =  ink_env::call::build_call::<<Self as ::ink_lang::reflect::ContractEnv>::Env>()
            .callee(token_contract) <--- ERROR points here
            .gas_limit(50000)
            .transferred_value(0)
            .exec_input(
                ink_env::call::ExecutionInput::new(ink_env::call::Selector::new([0, 0, 0, 40])),
                

            )
            .returns::<ink_env::call::utils::ReturnType<u32>>()
            .fire()
            .unwrap();
            my_return_value
            
        }

4
  • Have you tried increasing the gas limit?
    – forgetso
    Mar 2, 2022 at 15:00
  • @forgetso No sir, I'll do it and report back Mar 3, 2022 at 16:06
  • @forgetso Didn't work sir, thank you anyways. Mar 3, 2022 at 18:18
  • Are your contract constructors marked as payable?
    – forgetso
    Mar 3, 2022 at 20:14

1 Answer 1

4

Your call to fire() returns a CalleeTrapped error which you subsequently turn into a panic by calling unwrap. This unwrap is where the panic should point to.

CalleeTrapped is a rather unspecific error and just means that the callee trapped (caused by a panic in Rust). The function you are calling is infallible if described correctly here. This only leaves some error in the selector.

I suspect that the selector you specified (40) encodes to [40, 0, 0, 0] because the 40 is interpreted as integer which is then SCALE encoded. SCALE uses little endian representation.

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.