# Client-side API

The Valida client-side API enables creating and verifying Valida proofs of execution within the browser. This enables use cases which require proofs to run on the client side in web apps.

To use the Valida client-side API, you can start by copying the example project which is located in the installed toolchain at `/valida-toolchain/examples/wasm/client-side-example`.

You will need to embed your guest program (the one whose execution you wish to prove) in your client-side code. You can do this by taking the compiled guest program, base64 encoding it, and ingesting it using Webpack. The compiled guest program is located in `target/valida-unknown-baremetal-gnu`. For example, after you run `cargo +valida build --release` on your guest program called `program`, the compiled guest program is located at `target/valida-unknown-baremetal-gnu/release/program`.

Supposing the compiled program is located at `./program`, to base64 encode it, you could run the following command: `base64 program >program.base64`.

The example project illustrates how to ingest the compiled, base64-encoded program into a client-side app. This is accomplished using the following rule in `webpack.config.js`:

```javascript
  module: {
    rules: [
      {
        test: /\.base64/,
        type: 'asset/source',
      }
    ]
  }
```

With this rule in place, the base64-encoded program can be imported as simply as:

```javascript
import programBase64 from "./program.base64";
```

To import the Valida prover, use a line like:

```javascript
import * as valida from "valida-basic-api-wasm";
```

For this to work, `valida-basic-api-wasm` will need to be included in your `package.json`. Once you have done this, `valida` is an object containing methods with the following type signatures:

```typescript
export function run(program_bytes: Uint8Array, stdin: Uint8Array, max_trace_height: number): Uint8Array;
export function prove(program_bytes: Uint8Array, stdin: Uint8Array, max_trace_height: number): Uint8Array;
export function verify(program_bytes: Uint8Array, stdout: Uint8Array, proof: Uint8Array, max_trace_height: number): void;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lita.gitbook.io/lita-documentation/quick-start/valida-compiler-toolchain/client-side-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
