2
let selector: [u8; 4] = [0xbd, 0x77, 0x15, 0xef];
let amount_out = build_call::<DefaultEnvironment>()
    .call_type(Call::new().callee(self.liquidity_pool_address))
    .exec_input(
        ExecutionInput::new(Selector::new(selector))
            .push_arg(amount)
    )
    .returns::<u128>()
    .fire();

match amount_out {
    Ok(output) => return output,
    Err(_) => {
        panic!("Failed to execute call")
    }
} 

The method with the selector: 0xbd7715ef returns a u128 (Balance) type. It doesn't ever have an Err variant, but instead returns 0. The liquidity_pool_address is also its deployed contract address And it takes one u128 argument

There are no error messages to help me debug the problem with the call.

Any clues?

2
  • You can and should edit your original post :)
    – Nuke
    Jan 26, 2023 at 19:50
  • 1
    Please include the error code thrown specifically as well above
    – Nuke
    Jan 26, 2023 at 19:50

1 Answer 1

2

A minimal reproducer would be helpful for answering the question in more depth. So ideally code for a message in contract A and a message in contract B.

That being said, the issue in this case is often that either the selector doesn't exist or the contract doesn't exist.

Try the following:

Instead of

let selector: [u8; 4] = [0xbd, 0x77, 0x15, 0xef];
...
ExecutionInput::new(Selector::new(selector))

you can write:

ExecutionInput::new(Selector::new(ink::selector_bytes!("my_message")))

This will automatically compute the selector bytes, ensuring that there was no mistake when transforming it manually to a byte array.

For self.liquidity_pool_address: Check if you do any castings to AccountId here. Sometimes I see contracts that do some weird stuff to get a String into AccountId.

You could try having a message fn test(&self, acc_id: AccountId) that contains the code you posted above, but instead of self.liquidity_pool_address it would use the message argument acc_id. This way you can test it with a properly typed AccountId; polkadot-js, Contracts UI and cargo-contract will automatically transform the supplied account id to the correct type.

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.