user4400: I'd like to create a transaction using pure JavaScript on browser using Nami Wallet.
The docs shows only cardano.signTx(tx, partialSign) and cardano.submitTx(tx), but don't explain very well how to build the Transaction object.
How can I create a full Transaction object, let's say, transfering a specific amount of ADA from one wallet to another?

user2068: Is a long and awful process, Check this example using version 10.4  for all function definitions check my repo https://github.com/alice1989123/vending_machine/blob/main/Cardano/Wallet/Wallet.js

Build the TransactionBody Inputs Outputs Fees, and more minting burning etc
Hash the body and Sign it attach the witnesses  to the  the transaction,
Send it

    async function sendAda(senderAddress, senderprvKeys, lovelaces, address) {
      const reciverAddress = wasm.Address.from_bech32(address);
      const wasmSender = wasm.Address.from_bech32(senderAddress);
    
      const outPutValue = wasm.Value.new(wasm.BigNum.from_str(`${lovelaces}`));
    
      const protocolParameters = await getProtocolParams();
    
      const output = wasm.TransactionOutput.new(reciverAddress, outPutValue);
    
      const txBuilder = InitTx(protocolParameters);
      txBuilder.add_output(output);
      const utoxs_ = await getUtxos(senderAddress);
      const utxos = wasm.TransactionUnspentOutputs.new();
      utoxs_.forEach((utxo) => utxos.add(utxo));
      txBuilder.add_inputs_from(utxos, 1);
      txBuilder.add_change_if_needed(wasmSender);
      const txBody = txBuilder.build();
      const tx = wasm.Transaction.new(txBody, wasm.TransactionWitnessSet.new());
      const hash = await SignAndSend(tx, senderprvKeys);
      return hash;
    }


user2537: On Cardano, a transaction consists of UTxOs spent and UTxOs produced. The Nami wallet has a function to extract its UTxOs:
cardano.getUtxos(amount?: Value, paginate?: {page: number, limit: number}) : [TransactionUnspentOutput]
These UTxOs and the recipient address (as well as some static variables of the mainnet like fees...) are theoretically all you need to construct the transaction that transfers funds from one wallet to the other. The construction is not trivial, however, and you would probably want to use a library like https://github.com/Emurgo/cardano-serialization-lib that does this for you.

user117: If you are open to integrating with a wallet other than Nami, then Typhon Wallet integration is seamless which does not require you to fetch UTXOs and manually build a transaction.
The below snippet is all you need to build a transaction.
const paymentTransactionResponse = await typhon.paymentTransaction({
  outputs: [
    {
      address:
        "addr_test1qz7jw975stagnvs00wsjny6y6gpazn86yvwcm2vy02j3up7mt68vuzvz4nzgs00x0shrgywvy674v6r2zcs8fxvvq27qfjq8np",
      amount: "6000000", // In Lovelace
    },
  ],
});

More examples, https://docs.typhonwallet.io/examples/paymentTransaction.html

4400: <p>I'd like to create a transaction using pure <code>JavaScript</code> on browser using Nami Wallet.
The docs shows only <code>cardano.signTx(tx, partialSign)</code> and <code>cardano.submitTx(tx)</code>, but don't explain very well how to build the <code>Transaction</code> object.</p>
<p>How can I create a full <code>Transaction</code> object, let's say, transfering a specific amount of ADA from one wallet to another?</p>
 2068: <p>Is a long and awful process, Check this example using version 10.4  for all function definitions check my repo <a href="https://github.com/alice1989123/vending_machine/blob/main/Cardano/Wallet/Wallet.js" rel="nofollow noreferrer">https://github.com/alice1989123/vending_machine/blob/main/Cardano/Wallet/Wallet.js</a></p>
<ol>
<li>Build the TransactionBody Inputs Outputs Fees, and more minting burning etc</li>
<li>Hash the body and Sign it attach the witnesses  to the  the transaction,</li>
<li>Send it</li>
</ol>
<pre><code>    async function sendAda(senderAddress, senderprvKeys, lovelaces, address) {
      const reciverAddress = wasm.Address.from_bech32(address);
      const wasmSender = wasm.Address.from_bech32(senderAddress);
    
      const outPutValue = wasm.Value.new(wasm.BigNum.from_str(`${lovelaces}`));
    
      const protocolParameters = await getProtocolParams();
    
      const output = wasm.TransactionOutput.new(reciverAddress, outPutValue);
    
      const txBuilder = InitTx(protocolParameters);
      txBuilder.add_output(output);
      const utoxs_ = await getUtxos(senderAddress);
      const utxos = wasm.TransactionUnspentOutputs.new();
      utoxs_.forEach((utxo) =&gt; utxos.add(utxo));
      txBuilder.add_inputs_from(utxos, 1);
      txBuilder.add_change_if_needed(wasmSender);
      const txBody = txBuilder.build();
      const tx = wasm.Transaction.new(txBody, wasm.TransactionWitnessSet.new());
      const hash = await SignAndSend(tx, senderprvKeys);
      return hash;
    }
</code></pre>
 2537: <p>On Cardano, a transaction consists of UTxOs spent and UTxOs produced. The Nami wallet has a function to extract its UTxOs:</p>
<p><code>cardano.getUtxos(amount?: Value, paginate?: {page: number, limit: number}) : [TransactionUnspentOutput]</code></p>
<p>These UTxOs and the recipient address (as well as some static variables of the mainnet like fees...) are theoretically all you need to construct the transaction that transfers funds from one wallet to the other. The construction is not trivial, however, and you would probably want to use a library like <a href="https://github.com/Emurgo/cardano-serialization-lib" rel="nofollow noreferrer">https://github.com/Emurgo/cardano-serialization-lib</a> that does this for you.</p>
 117: <p>If you are open to integrating with a wallet other than Nami, then Typhon Wallet integration is seamless which does not require you to fetch UTXOs and manually build a transaction.</p>
<p>The below snippet is all you need to build a transaction.</p>
<pre><code>const paymentTransactionResponse = await typhon.paymentTransaction({
  outputs: [
    {
      address:
        &quot;addr_test1qz7jw975stagnvs00wsjny6y6gpazn86yvwcm2vy02j3up7mt68vuzvz4nzgs00x0shrgywvy674v6r2zcs8fxvvq27qfjq8np&quot;,
      amount: &quot;6000000&quot;, // In Lovelace
    },
  ],
});
</code></pre>
<p>More examples, <a href="https://docs.typhonwallet.io/examples/paymentTransaction.html" rel="nofollow noreferrer">https://docs.typhonwallet.io/examples/paymentTransaction.html</a></p>
