Expression of type ... cannot produce expected type (Motoko)

If I want to call this function from the bitcoin example code

  /// Sends the given amount of bitcoin from this canister to the given address.
  /// Returns the transaction ID.
  public func send(request : SendRequest) : async Text {
    Utils.bytesToText(await BitcoinWallet.send(NETWORK, DERIVATION_PATH, KEY_NAME, request.destination_address, request.amount_in_satoshi));
  };`

from inside the same main.mo, I’m trying to do it like this:

 public func withdrawBtc(btc_withdrawal_amount : Nat64, btc_withdrawal_address : Text) : async Text {

    let btcWithdrawRequest : SendRequest = {
      destination_address = btc_withdrawal_address;
      amount_in_satoshi = btc_withdrawal_amount;
    };

    send(btcWithdrawRequest);
  };

but the send(btcWithdrawRequest); part says

expression of type** ** async<$withdrawBtc> Text** **cannot produce expected type** ** Text Motoko

How do I fix this or what’s wrong with it?

1 Like

Put await before the call to send.

2 Likes