<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>

CC BY-SA 4.0
2022-04-25T20:17:26.097Z
Unfortunately this does not answer the question at all.
rx2347
CC BY-SA 4.0
2022-03-14T04:44:41.507Z
2022-03-14T04:44:41.507Z
Mehul Prajapati
<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>

CC BY-SA 4.0
2021-12-15T13:30:57.793Z
I understand the concept, but would like more coding details of the implementation, because both Nami Wallet and cardano-serialization-lib documentation do not provide practical guidance to make this happen
Daniel Cukier
CC BY-SA 4.0
2022-04-25T20:19:31.953Z
@DanielCukier did you solve this? I'd encourage you to share your solution as the lack of documentation is indeed a problem. Cardano wont succeed unless all of us do a better job of getting people educated on these day-to-day-tasks.
rx2347
CC BY-SA 4.0
2021-12-14T11:17:20.937Z
2021-12-14T11:17:20.937Z
Jey
<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>

CC BY-SA 4.0
2022-04-29T00:06:13.730Z
I believe this won't work for my case, because I am using the browser wallet. I don't have access to the sender private key. What I want is to create a transaction and submit it to the user wallet, so the user can sign it before I submit the transaction to the blockchain
Daniel Cukier
CC BY-SA 4.0
2022-03-19T02:38:30.553Z
2022-05-02T06:29:01.767Z
2022-05-02T06:29:01.767Z
Alicia Basilio
<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>

CC BY-SA 4.0
2022-04-28T05:12:41.823Z
Should you mark one of the answers as accepted?
gRebel
<transaction><nami-wallet><nami>
How do I create and submit a transaction using only Nami Wallet?
# How do I create and submit a transaction using only Nami Wallet?

(Asked by: username_0 on 2021-12-10)

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?

**Tags:** transaction, nami-wallet, nami
> **Comments:**
> **username_1**: Should you mark one of the answers as accepted?  

---

## 3 answers

### Answer by username_2 on 2022-03-14. Score: 2

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

> **Comments:**
> **username_3**: Unfortunately this does not answer the question at all.  

---

### Answer by username_4 on 2021-12-14. Score: 2

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.

> **Comments:**
> **username_0**: I understand the concept, but would like more coding details of the implementation, because both Nami Wallet and cardano-serialization-lib documentation do not provide practical guidance to make this happen  
> **username_3**: @DanielCukier did you solve this? I'd encourage you to share your solution as the lack of documentation is indeed a problem. Cardano wont succeed unless all of us do a better job of getting people educated on these day-to-day-tasks.  

---

### Answer by username_5 on 2022-03-19. Score: 1

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;
    }

> **Comments:**
> **username_0**: I believe this won't work for my case, because I am using the browser wallet. I don't have access to the sender private key. What I want is to create a transaction and submit it to the user wallet, so the user can sign it before I submit the transaction to the blockchain  

---

