
# Basic example

Before running the example make sure you have built the `cardano-wasm` library by following the process described in the readme file of the [`cardano-wasm` folder](../..).

## Running the simple example

To run the example this folder:

1.  Copy the generated `cardano-wasm.wasm` file to this subfolder. You can find the locatino for the built `cardano-wasm.wasm` file by using:
    ```console
    echo "$(env -u CABAL_CONFIG wasm32-wasi-cabal list-bin exe:cardano-wasm | tail -n1)"
    ```
2.  Copy the generated `cardano-wasm.js` file (generated by the `post-link.mjs` command in the section above) to this subfolder.
3.  Copy the wrapper files from the `lib-wrapper` folder into this subfolder.
4.  Navigate to this subfolder in your terminal.
5.  Due to browser security restrictions (CORS policy), you may need to serve the `index.html` file through a local HTTP server. A simple way to do this is using Python's built-in HTTP server:
    ```console
    python3 -m http.server 8001
    ```
6.  Open your web browser and navigate to `http://localhost:8001/`. You should see a page titled `Test Output` with the results of the test, and if you open the developer console you should be able to see an output like the following:
    ```console
    [Log] wasi: – 0 – 0 (wasi.js, line 1)
    [Log] wasi: – 0 – 0 (wasi.js, line 1)
    [Log] Tx input: (test, line 9)
    [Log] be6efd42a3d7b9a00d09d77a5d41e55ceaf0bd093a8aa8a893ce70d9caafd978#0 (test, line 10)
    [Log] Tx body: (test, line 16)
    [Log] {cborHex: "84a300d9010281825820be6efd42a3d7b9a00d09d77a5d41e5…86b4e8a52c6555f659b871a00989680021a001e8480a0f5f6",
           description: "Ledger Cddl Format", type: "TxBodyConway"} (test, line 17)
    [Log] Signed tx: (test, line 19)
    [Log] {cborHex: "84a300d9010281825820be6efd42a3d7b9a00d09d77a5d41e5…5ca8d8561a45358a27b7f5d1f4f7ceb3fec2a8725f20df5f6",
           description: "Ledger Cddl Format", type: "Tx ConwayEra"} (test, line 20)
    ```
