@@ -11,7 +11,7 @@ The Kuber Hydra Client can be integrated with a CIP-30 compatible wallet to sign
1111
1212- Node.js environment
1313- ` libcardano ` and ` libcardano-wallet ` installed.
14- - Access to a running Hydra node and its credentials (e.g., ` node.addr ` , ` funds.sk ` ).
14+ - Access to a running Hydra node and its credentials (e.g., ` node.addr ` , ` alice- funds.sk` ).
1515
1616This example demonstrates how to set up a ` SimpleCip30Wallet ` and use it to sign and submit a transaction to a Hydra Head.
1717
@@ -22,20 +22,32 @@ import { ShelleyWallet, SimpleCip30Wallet } from "libcardano-wallet";
2222import { KuberHydraApiProvider } from " kuber-client" ; // Adjust path as needed
2323import { UTxO } from " libcardano/serialization" ;
2424
25+ function formatUtxo(utxo : UTxO ) {
26+ return {
27+ txIn: ` ${utxo .txIn .txHash .toString (" hex" )}#${utxo .txIn .index } ` ,
28+ address: utxo .txOut .address .toBech32 (),
29+ lovelace: utxo .txOut .value .lovelace .toString (),
30+ assetPolicies: Object .keys (utxo .txOut .value .multiassets ?? {}).length ,
31+ };
32+ }
33+
2534async function runCip30CommitExample() {
2635 // Initialize Hydra API Provider
27- const hydra = new KuberHydraApiProvider (" http://172.31.6.1 :8082" ); // Replace with your Hydra node URL
36+ const hydra = new KuberHydraApiProvider (" http://localhost :8082" );
2837
2938 // Load node address and test wallet signing key
3039 const node_addr_path = process .env .HOME + " /.cardano/preview/hydra-0/credentials/node.addr" ;
3140 const nodeAddr = readFileSync (node_addr_path ).toString (" utf-8" ).trim ();
3241
3342 // Setup Shelley wallet
3443 const testWalletSigningKey = await CardanoKeyAsync .fromCardanoCliJson (
35- JSON .parse (readFileSync (process . env . HOME + " /.cardano/preview/hydra-0/ credentials/funds.sk" , " utf-8" )),
44+ JSON .parse (readFileSync (" ../../kuber-hydra/devnet/ credentials/alice- funds.sk" , " utf-8" )),
3645 );
3746 const shelleyWallet = new ShelleyWallet (testWalletSigningKey );
38- console .log (" Wallet" , shelleyWallet .toJSON ());
47+ console .table ({
48+ paymentKeyHash: shelleyWallet .paymentKey .publicKeyHash ().toString (" hex" ),
49+ networkId: 0 ,
50+ });
3951
4052 // Create SimpleCip30Wallet instance
4153 // The first two arguments are for the L1 API provider and the Hydra API provider, respectively.
@@ -66,10 +78,11 @@ async function runCip30CommitExample() {
6678
6779 const txIn = selectedUtxos [0 ].txIn ;
6880 const utxoToCommit = [` ${txIn .txHash .toString (" hex" )}#${txIn .index } ` ];
81+ console .table (selectedUtxos .map (formatUtxo ));
6982
7083 // Build the commit transaction using Hydra API
7184 const commitResult = await hydra .commit ({ utxos: utxoToCommit });
72- console .log (" Transaction to be signed :" , commitResult .hash );
85+ console .log (" Commit transaction hash :" , commitResult .hash );
7386
7487 // Sign the transaction using the CIP-30 wallet
7588 const signResult = await cip30Wallet .signTx (commitResult .cborHex );
0 commit comments