How to provide UTXO to script call

I have a call of script that creates order
Link to script is here

When I provide required object as argument it fails with “NotEnoughBalance” error, I assume it can be fixed by providing UTXO, but I couldn’t find any example how to attach it to script call function.

My code

 const orderObject = {
      id,
      predicate_address: { value: predicateAddress },
      asset0: { value: token0 },
      amount0: "450000",
      asset1: { value: token1 },
      amount1: "100000",
      owner: this.rootStore.accountStore.addressInput,
    } as CreateOrderParamsInput;
 const { value, logs } = await createOrderScript.functions
      .main(orderObject)
      .call();

When executing a Script that requires funds, you have some options;

  1. Create a Script Instance with a Account Instance, this account instance can be of types Predicate or WalletUnlocked/Locked. Calling a script | Fuels-ts

  2. Create a Script Instance, and add specifics Inputs and Outputs by changing the transactionRequest. script.

    const wallet = new WalletUnlocked();
    const script = new Script('<hex>', {...}, account);
    const call = script.functions.main();
    call.transactionRequest.addCoinOutput({...});
    call.transactionRequest.inputs.push({...});
    call.transactionRequest.outputs.push({...});
    
  3. Create a Transaction Request instance directly and update the data on it;

    const wallet = Wallet.generate();
    const tx = new TransactionRequest({
        script: '<hex>',
        scriptData: '<hex of data>'
    });
    tx.addCoinOutput({...});
    tx.inputs.push({...});
    tx.outputs.push({...});
    wallet.sendTransaction(tx);
    
2 Likes

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.