Skip to content

Allow multiple user-inputs in minting transaction #4

@mr-zwets

Description

@mr-zwets

The cashscript code for the minting smart contract allows for the user to add multiple inputs.

  // Get userInput for mint
  const userAddress = await getUserAddress();
  const userUtxos = await electrumServer.getUtxos(userAddress);
  const networkFeeMint = 520;
  const filteredUserUtxos = userUtxos.filter(
    val => !val.token && val.satoshis >= mintPriceSats + networkFeeMint,
  );
  const bchBalanceUser = userUtxos.reduce((total, utxo) => utxo.token ? total : total + utxo.satoshis, 0n);
  const userInput = filteredUserUtxos[0];

this code could just as well select an array of userInputs to get to the required minting amount.

Next the fromP2PKH(userInput, userSig) in the transaction construction should be using this array of userInputs and then set the all signatures to be empty before adding each input to the listSourceOutputs .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions