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

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

This is my contract code snippet. I am trying to test cross-contract call with simplest computation. But I am getting Contracts.ContractTrapped error. I also updated the dummy_fuction selector to "_" to check if i was passing wrong selector. But then also I am getting the same error. DO we have some examples on how to call cross contract calls to self or other contract? And Can someone explain what wrong i am doing in my code?

  • Did you go through [this offical documentation of Cross-Contract Calling] (use.ink/4.0.0-alpha.1/basics/cross-contract-calling) ? However you can also view this code
    – go11li
    Jan 25, 2023 at 5:47
  • What if I am calling the self Contract (re-entrancy), Do i need to import self contract or what? What if i only have the selector information and the arguments that function is taking? Jan 25, 2023 at 10:04
  • No you don't have to import, you can simply call by its name, along with necessary arguments.
    – go11li
    Jan 25, 2023 at 12:20
  • But My requirement is I need to update my contract states even if my sub-contract call failed or reverted. That is why i was using cross-contract invocation for own contract function itself. The way we perform .call() low level contract execution in solidity. Jan 25, 2023 at 15:05
  • the contract state isn't changed if calling failed.
    – go11li
    Jan 29, 2023 at 3:05

1 Answer 1


Instead of cross contract calling, what you are doing here is Reentrancy guard which is the process to prevent specific type of attack (i.e reentrancy attack where attacker can repeatedly call function without expected condition met) whereas cross contract calling is the process of interacting with other smart contract.

In order to do cross contract call you can view this offical doc tutorial and this repo. There is delegator example code which is advance concept for corss contract calling.

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.