0

Contract A has a Payable Method and contract B has ContractRef of A saved in storage. I can call other methods on Contract A but not sure how to call the payable method from Contract B. Tried with call builder as well like this :

build_call::<DefaultEnvironment>()
   .call_type(
      Call::new()
      .callee(contractBRef.get_account())
      .gas_limit(0)
      .transferred_value(amount))
      .exec_input(
         ExecutionInput::new(Selector::new([0xDE, 0xAD, 0xBE, 0xEF]))
         .push_arg::<AccountId>(candidate)
         .push_arg::<u128>(0)
         .push_arg::<u128>(amount)
         .push_arg::<u128>(0)
         .push_arg::<u128>(100)
      ).call_flags(CallFlags::default()).returns::<Result<()>>().unwrap()

But the call is returning CalleeTrapped Error.

6
  • are you using the correct selector?
    – kriko.eth
    Commented Nov 14, 2022 at 12:42
  • yes i did check the selector as well @Coreggon . Commented Nov 15, 2022 at 9:02
  • further note ... the issue appears only when ContractB's method is payable and i try to transfer value greater than 0 . This is getting weird not sure what i am missing. Commented Nov 15, 2022 at 14:47
  • and what about the function you are making the call from, is it payable too?
    – kriko.eth
    Commented Nov 16, 2022 at 15:14
  • also, are you sure that the contract has enough balance?
    – kriko.eth
    Commented Nov 16, 2022 at 22:52

1 Answer 1

1

Thank you all for help. The issue was being caused by contract trying to make a balance transfer less than existential deposit.

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.