> For the complete documentation index, see [llms.txt](https://garaga.gitbook.io/garaga/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://garaga.gitbook.io/garaga/smart-contract-generators/groth16/generating-calldata-from-a-proof-and-using-your-deployed-contract/using-typescript.md).

# Using Typescript

Using the `garaga` [Npm package](/garaga/installation/npm-package.md)

## Node.js (with file reading)

```typescript
import * as garaga from 'garaga';
import { CurveId } from 'garaga';
import { readFileSync } from 'fs';

await garaga.init();

// Parse from file paths (Node.js only)
const vk = garaga.parseGroth16VerifyingKeyFromJson('verification_key.json');
const proof = garaga.parseGroth16ProofFromJson('proof.json', 'public.json');

const calldata = garaga.getGroth16CallData(proof, vk, CurveId.BN254);
```

## From JSON objects (Node.js and Browser)

```typescript
import * as garaga from 'garaga';
import { CurveId } from 'garaga';

await garaga.init();

// Parse from already-loaded JSON objects
const vkJson = { /* verification key JSON */ };
const proofJson = { /* proof JSON */ };
const publicInputs = [/* public inputs as bigint[] */];

const vk = garaga.parseGroth16VerifyingKeyFromObject(vkJson);
const proof = garaga.parseGroth16ProofFromObject(proofJson, publicInputs);

const calldata = garaga.getGroth16CallData(proof, vk, CurveId.BN254);
```

{% hint style="info" %}
The `CurveId` should match your verifying key's curve: `CurveId.BN254` or `CurveId.BLS12_381`.
{% endhint %}

## Browser Usage

Use `parseGroth16*FromObject` functions in the browser (no filesystem access):

```typescript
import * as garaga from 'garaga';
import { CurveId } from 'garaga';

async function generateCalldata(vkJson: object, proofJson: object, publicInputs?: bigint[]) {
    await garaga.init();

    const vk = garaga.parseGroth16VerifyingKeyFromObject(vkJson);
    const proof = garaga.parseGroth16ProofFromObject(proofJson, publicInputs);

    return garaga.getGroth16CallData(proof, vk, CurveId.BN254);
}
```
