Skip to content

Commit e5d4f7b

Browse files
authored
Update metadata_tx.ts
1 parent ead3510 commit e5d4f7b

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

doc/getting-started/metadata_tx.ts

+8-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const MNEMONIC = "key in your 24 words of your mnemonic here, words separated by
66
const INPUT_HASH ="9fc9bb3ea1f2540ae870076e6543b5d804566a548db9da9e16c5271596e8dc9d"
77
const INPUT_INDEX =1;
88
const INPUT_AMOUNT = "113185492" ; //Lovelace on your UTXO
9-
const TO_ADDRESS="addr_test1qqew6jaz63u389gwnp8w92qntetzxs6j9222pn4cnej672vazs7a6wnrseqggj4d4ur43yq9e23r4q0m879t7efyhzjq8mvzua";
9+
const TO_ADDRESS="addr_test1your_address_in_bech32";
1010
const AMOUNT="2000000";
1111

1212
function harden(num: number): number {
@@ -87,23 +87,16 @@ txBuilder.set_auxiliary_data(auxData);
8787
txBuilder.add_change_if_needed(addr.to_address());
8888

8989

90-
const txBody = txBuilder.build()
91-
const txBodyBytes = CSL.FixedTransaction.new_from_body_bytes(txBody.to_bytes());
92-
let tx_hash = txBodyBytes.transaction_hash();
90+
const tx = txBuilder.build_tx()
91+
const fixedTx = CSL.FixedTransaction.from_bytes(tx.to_bytes());
92+
let txHash = fixedTx.transaction_hash();
9393

94-
const witnesses = CSL.TransactionWitnessSet.new();
95-
const vkeyWitnesses = CSL.Vkeywitnesses.new();
96-
const vkeyWitness = CSL.make_vkey_witness(tx_hash,paymentKey);
97-
vkeyWitnesses.add(vkeyWitness);
98-
witnesses.set_vkeys(vkeyWitnesses);
99-
100-
101-
102-
// Step 6.=========Create Transaction with 03 components========
103-
const transaction = CSL.Transaction.new(txBody, witnesses, auxData);
94+
// Step 6.=========Make and add vkey witness if it necessary========
95+
const vkeyWitness = CSL.make_vkey_witness(txHash,paymentKey);
96+
fixedTx.add_vkey_witness(vkeyWitness)
10497

10598
// Step 7.=========Serialize Transaction to hex========
106-
const txSerialized = Buffer.from(transaction.to_bytes()).toString("hex");
99+
const txSerialized = fixedTx.to_hex();
107100
console.log("Transaction serialized:", txSerialized);
108101

109102

0 commit comments

Comments
 (0)