# Cardano-rest how to create and submit transaction with javascript

**URL:** <https://forum.cardano.org/t/cardano-rest-how-to-create-and-submit-transaction-with-javascript/34701>\
**Category:** Cardano Integration\
**Tags:** testnet\
**Created:** [22 June 2020 08:18 UTC](https://forum.cardano.org/t/cardano-rest-how-to-create-and-submit-transaction-with-javascript/34701 "2020-06-22T08:18:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Duc\_Hai\_Nguyen](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/duc_hai_nguyen/32/19179_2.png) [@Duc\_Hai\_Nguyen](https://forum.cardano.org/u/Duc_Hai_Nguyen)\
**Post date:** [22 June 2020 08:18 UTC](https://forum.cardano.org/t/cardano-rest-how-to-create-and-submit-transaction-with-javascript/34701/1 "2020-06-22T08:18:22Z")

</div>

Im using cardano-wallet package to build transaction manually and get stuck in encode transaction as cbor format. Any one can help?

const Cardano = require(‘cardano-wallet’)

```
const txFinalizer = new Cardano.TransactionFinalized(unsignedTx)
const setting = Cardano.BlockchainSettings.from_json({
  protocol_magic: PROTOCOL_MAGICS.testnet
})

// sign Transaction
utxos.forEach(() => {
  const witness = Cardano.Witness.new_extended_key(
    setting,
    Cardano.PrivateKey.from_hex(privateKey),
    txFinalizer.id()
  )
  txFinalizer.add_witness(witness)
})
const txid = txFinalizer.id().to_hex()
const signedTx = txFinalizer.finalize()
const txEncoded = CBOR.encode(Buffer.from(signedTx.to_hex(), 'hex')

const response = await axios({
  headers: {
    'Content-Type': 'application/cbor'
  },
  method: 'post',
  url: `${submitUrl}/api/submit/tx`,
  'data-binary': txEncoded
})
```

---

<div class="post-metadata">

**Author:** ![Steve](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/steve/32/7229_2.png) [@Steve](https://forum.cardano.org/u/Steve)\
**Post date:** [22 June 2020 08:41 UTC](https://forum.cardano.org/t/cardano-rest-how-to-create-and-submit-transaction-with-javascript/34701/2 "2020-06-22T08:41:42Z")

</div>

I’m not familiar with the cardano-wallet package, but I can see you’re missing a parentheses at the end of

```
const txEncoded = CBOR.encode(Buffer.from(signedTx.to_hex(), 'hex')

```

That might be it 🙂

---

<div class="post-metadata">

**Author:** ![Duc\_Hai\_Nguyen](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/duc_hai_nguyen/32/19179_2.png) [@Duc\_Hai\_Nguyen](https://forum.cardano.org/u/Duc_Hai_Nguyen)\
**Post date:** [22 June 2020 08:49 UTC](https://forum.cardano.org/t/cardano-rest-how-to-create-and-submit-transaction-with-javascript/34701/3 "2020-06-22T08:49:59Z")

</div>

thank you, but it’s not the problem 😬

---

<div class="post-metadata">

**Author:** ![Duc\_Hai\_Nguyen](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/duc_hai_nguyen/32/19179_2.png) [@Duc\_Hai\_Nguyen](https://forum.cardano.org/u/Duc_Hai_Nguyen)\
**Post date:** [22 June 2020 09:04 UTC](https://forum.cardano.org/t/cardano-rest-how-to-create-and-submit-transaction-with-javascript/34701/4 "2020-06-22T09:04:56Z")

</div>

I addressed the problem myself  
const txEncoded = Buffer.from(signedTx.to\_hex(), ‘hex’)

```
const response = await axios({
  headers: {
    'Content-Type': 'application/cbor'
  },
  method: 'post',
  url: `${submitUrl}/api/submit/tx`,
  data: txEncoded
})
```

---

<div class="post-metadata">

**Author:** ![\_lete](https://avatars.discourse-cdn.com/v4/letter/_/ea5d25/32.png) [@\_lete](https://forum.cardano.org/u/_lete)\
**Post date:** [13 August 2020 03:19 UTC](https://forum.cardano.org/t/cardano-rest-how-to-create-and-submit-transaction-with-javascript/34701/5 "2020-08-13T03:19:51Z")

</div>

May I have a look at your complete code? I have some problems that are similar to you. Thank you very much

---

<div class="post-metadata">

**Author:** ![Duc\_Hai\_Nguyen](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/duc_hai_nguyen/32/19179_2.png) [@Duc\_Hai\_Nguyen](https://forum.cardano.org/u/Duc_Hai_Nguyen)\
**Post date:** [13 August 2020 06:04 UTC](https://forum.cardano.org/t/cardano-rest-how-to-create-and-submit-transaction-with-javascript/34701/6 "2020-08-13T06:04:05Z")

</div>

Since Sheley was released. I no longer use cardano-wallet to build transaction. I move to [cardano-serialization-lib]

---

<div class="post-metadata">

**Author:** ![\_lete](https://avatars.discourse-cdn.com/v4/letter/_/ea5d25/32.png) [@\_lete](https://forum.cardano.org/u/_lete)\
**Post date:** [13 August 2020 10:31 UTC](https://forum.cardano.org/t/cardano-rest-how-to-create-and-submit-transaction-with-javascript/34701/7 "2020-08-13T10:31:33Z")

</div>

can you use it make unsignedTx, and sumbitTx to complete byron transfer
