@@ -6,7 +6,7 @@ const MNEMONIC = "key in your 24 words of your mnemonic here, words separated by
6
6
const INPUT_HASH = "9fc9bb3ea1f2540ae870076e6543b5d804566a548db9da9e16c5271596e8dc9d"
7
7
const INPUT_INDEX = 1 ;
8
8
const INPUT_AMOUNT = "113185492" ; //Lovelace on your UTXO
9
- const TO_ADDRESS = "addr_test1qqew6jaz63u389gwnp8w92qntetzxs6j9222pn4cnej672vazs7a6wnrseqggj4d4ur43yq9e23r4q0m879t7efyhzjq8mvzua " ;
9
+ const TO_ADDRESS = "addr_test1your_address_in_bech32 " ;
10
10
const AMOUNT = "2000000" ;
11
11
12
12
function harden ( num : number ) : number {
@@ -87,23 +87,16 @@ txBuilder.set_auxiliary_data(auxData);
87
87
txBuilder . add_change_if_needed ( addr . to_address ( ) ) ;
88
88
89
89
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 ( ) ;
93
93
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 )
104
97
105
98
// Step 7.=========Serialize Transaction to hex========
106
- const txSerialized = Buffer . from ( transaction . to_bytes ( ) ) . toString ( "hex" ) ;
99
+ const txSerialized = fixedTx . to_hex ( ) ;
107
100
console . log ( "Transaction serialized:" , txSerialized ) ;
108
101
109
102
0 commit comments