# @hyperoracle/zkgraph-cli

> ## CLI

Latest version **1.0.0** (published 2023-12-07) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @hyperoracle/zkgraph-cli
pnpm add @hyperoracle/zkgraph-cli
yarn add @hyperoracle/zkgraph-cli
bun add @hyperoracle/zkgraph-cli
```

Provides the command `zkgraph`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-12-07 |
| First published | 2023-10-13 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 17 |
| Unpacked size | 79.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 28 |
| Maintainers | murongxdb, nom4dv3, fewwwww, hyper-oracle |

## Links

- npm: https://www.npmjs.com/package/@hyperoracle/zkgraph-cli
- Repository: https://github.com/hyperoracle/zkgraph-cli
- Homepage: https://github.com/hyperoracle/zkgraph-cli#readme
- Issues: https://github.com/hyperoracle/zkgraph-cli/issues
- npm.io page: https://npm.io/package/@hyperoracle/zkgraph-cli

## Dependencies (17)

- [api](https://npm.io/package/api.md) ^6.1.1
- [cac](https://npm.io/package/cac.md) ^6.7.14
- [axios](https://npm.io/package/axios.md) ^1.5.1
- [ethers](https://npm.io/package/ethers.md) ^5.7.2
- [nanoid](https://npm.io/package/nanoid.md) ^5.0.1
- [semver](https://npm.io/package/semver.md) ^7.5.4
- [ts-md5](https://npm.io/package/ts-md5.md) ^1.3.1
- [prompts](https://npm.io/package/prompts.md) ^2.4.2
- [unconfig](https://npm.io/package/unconfig.md) ^0.3.11
- [form-data](https://npm.io/package/form-data.md) ^4.0.0
- [picocolors](https://npm.io/package/picocolors.md) ^1.0.0
- [await-to-js](https://npm.io/package/await-to-js.md) ^3.0.0
- [axios-retry](https://npm.io/package/axios-retry.md) ^3.8.0
- [@antfu/utils](https://npm.io/package/@antfu/utils.md) ^0.7.6
- [assemblyscript](https://npm.io/package/assemblyscript.md) ^0.27.12
- [create-zkgraph](https://npm.io/package/create-zkgraph.md) 1.0.0
- [@hyperoracle/zkgraph-api](https://npm.io/package/@hyperoracle/zkgraph-api.md) ^1.0.0

## Recent versions

- 1.0.0 (latest) — 2023-12-07
- 1.0.0-alpha.0 (alpha) — 2023-12-18
- 0.0.2-alpha.6 — 2023-12-06
- 0.0.2-alpha.5 — 2023-12-06
- 0.0.2-alpha.4 — 2023-12-06
- 0.0.2-alpha.3 — 2023-11-22
- 0.0.2-alpha.2 — 2023-11-16
- 0.0.2-alpha.1 — 2023-11-16
- 0.0.1 — 2023-11-06
- 0.0.1-alpha.25 — 2023-11-06
- 0.0.1-alpha.24 — 2023-11-06
- 0.0.1-alpha.23 — 2023-11-05
- 0.0.1-alpha.22 — 2023-11-05
- 0.0.1-alpha.21 — 2023-11-03
- 0.0.1-alpha.20 — 2023-11-02
- … 20 more at https://npm.io/package/@hyperoracle/zkgraph-cli/versions

## README

# zkGraph CLI

## CLI

> Note: Only `full` image will be processed by zkOracle node. `local` (generated by commands ending with `--local` option) means the zkGraph is compiled locally and only contains partial computation (so that proving and executing will be faster).

The workflow of local zkGraph development must follow: `Develop` (code in /src) -> `Compile` (get compiled wasm image) -> `Execute` (get expected output) -> `Prove` (generate input and pre-test for actual proving in zkOracle) -> `Verify` (verify proof on-chain).

To upload and publish your zkGraph, you should `Upload` (upload code to IPFS), and then `Publish` (register zkGraph on onchain zkGraph Registry).

### Compile

Compile for Full Image (Link Compiled with Compiler Server).

#### Usage

```bash
zkgraph compile [root]
```

#### Options

| Options                 | Description             |
| ----------------------- | ----------------------- |
| `--local`               | Compile for Local Image |
| `--yaml-path <path>`    | Path to yaml file       |
| `--mapping-path <path>` | Path to mapping file    |

### Execute

Execute Full Image.

Please save the `ZKGRAPH_STATE_OUTPUT` string for following prove steps.

#### Usage
```bash
zkgraph exec [...params] [root]
```

#### Usage cases
```bash
zkgraph exec <blockId> [root]
zkgraph exec <blockId> <offchainData> [root]
```


#### Arguments

| Arguments        | Description                                     |
| ---------------- | ----------------------------------------------- |
| `<block id>`     | Block number (or block hash) as runtime context |
| `<offchainData>` | offchain data                                   |


#### Options

| Options   | Description         |
| --------- | ------------------- |
| `--local` | Execute Local Image |

### Set Up

Set Up Full Image

- `circuit-size`: Specify the circuit size of image instead of the default recommended. eg. `zkgraph setup -- --circuit-size <size> (eg. 22)`.

#### Usage
```bash
zkgraph setup [root]
```

#### Options

| Options                     | Description                      |
| --------------------------- | -------------------------------- |
| `--local`                   | Set Up Local Image               |
| `-k, --circuit-size <size>` | Circuit size (k in 2^k) of image |

### Prove

Prove Full Image

#### Usage
```bash
zkgraph prove [...params] [root]
```

#### Usage cases
```bash
zkgraph prove <blockId> <expectedStateStr> [root]
zkgraph prove <blockId> <offchainData> <expectedStateStr> [root]
```

#### Arguments

| Arguments          | Description                                     |
| ------------------ | ----------------------------------------------- |
| `<block id>`       | Block number (or block hash) as runtime context |
| `<expected state>` | State output of the zkGraph execution           |
| `<offchainData>`   | offchain data                                   |


#### Options

| Options          | Description                  |
| ---------------- | ---------------------------- |
| `--local`        | Prove Local Image            |
| `-i, --inputgen` | Run in input generation Mode |
| `-t, --test`     | Run in test Mode             |
| `-p, --prove`    | Run in prove Mode            |

### Upload

Upload zkGraph (Code and Full Image).

Please save the `ipfs_hash` from the output dialog for following publish steps.

#### Usage
```bash
zkgraph upload [root]
```

#### Options

| Options   | Description                                 |
| --------- | ------------------------------------------- |
| `--local` | Upload Local zkGraph (Code and Local Image) |


### Verify

Verify Proof Onchain.

#### Usage
```bash
zkgraph verify <prove task id>
```

#### Arguments

| Arguments         | Description           |
| ----------------- | --------------------- |
| `<prove task id>` | Task id of prove task |


### Publish

Publish and Register zkGraph Onchain.

See also: [Verifier Contract Interface](https://github.com/DelphinusLab/halo2aggregator-s/blob/main/sol/contracts/AggregatorVerifier.sol#L40).

#### Usage
```bash
zkgraph publish <deployed contract address> <ipfs_hash> <bounty_reward_per_trigger>
```

#### Arguments

| Arguments                     | Description                                                |
| ----------------------------- | ---------------------------------------------------------- |
| `<deployed contract address>` | Contract address of deployed verification contract address |
| `<ipfs hash>`                 | IPFS hash of uploaded zkGraph                              |
| `<bounty reward per trigger>` | Bounty reward per trigger in ETH                           |

### Deposit

Publish and register zkGraph Onchain.

#### Usage
```bash
zkgraph deposit <deployed contract address> <deposit amount>
```

#### Arguments

| Arguments                     | Description                                                |
| ----------------------------- | ---------------------------------------------------------- |
| `<deployed contract address>` | Contract address of deployed verification contract address |
| `<deposit amount>`            | Deposit amount in ETH                                      |

## Config

### Configuring zkGraph

When running zkGraph from the command line, the tool will automatically attempt to locate a configuration file named zkgraph.config.js in the project’s root directory. It also supports other file extensions such as JS and TS.

The most basic config file looks like this:

```js
// zkgraph.config.js
export default {
  // config options
}
```

You can also explicitly specify a config file to use with the --config CLI option (resolved relative to cwd):

```bash
zkgraph --config my-config.js
```

### Config Intellisense

Since zkGraph ships with TypeScript typings, you can leverage your IDE's intellisense with jsdoc type hints:

```js
/** @type {import('@hyperoracle/zkgraph-cli').UserConfig} */
export default {
  // ...
}
```
Alternatively, you can use the defineConfig helper which should provide intellisense without the need for jsdoc annotations:

```js
import { defineConfig } from '@hyperoracle/zkgraph-cli'

export default defineConfig({
  // ...
})
```

ZkGraph also directly supports TS config files. You can use zkgraph.config.ts with the defineConfig helper as well.

### Config Options

#### JsonRpcProviderUrl

- **Type:** `object`
- **Default**: `{ mainet: "", sepolia: "", goerli: ""}`

Update your Etherum JSON RPC provider URL here.
It is recommended to use providers that support debug_getRawReceipts RPC method.  

#### UserPrivateKey

- **Type:** `string`

Update your private key here to sign zkwasm messages.
Please note that (during testnet phrase) your address balance (in zkwasm server) should > 0.


#### ZkwasmProviderUrl

- **Type:** `string`
- **Default**: `https://zkwasm-explorer.delphinuslab.com:8090`

#### CompilerServerEndpoint

- **Type:** `string`
- **Default**: `http://compiler.hyperoracle.io/compile`

#### PinataEndpoint

- **Type:** `string`
- **Default**: `https://api.pinata.cloud/pinning/pinFileToIPFS`

#### PinataJWT

- **Type:** `string`

#### WasmBinPath

- **Type:** `string`
- **Default**: `[root]/build/zkgraph_full.wasm`

zkGraph CLI Build-In a tag name is `root`.  
The `root` is user project root path.  
Of course, you can also place this tag at any position within the string.  
`LocalWasmBinPath` is the same.

#### LocalWasmBinPath

- **Type:** `string`
- **Default**: `[root]/build/zkgraph_local.wasm`

---
_Source: https://npm.io/package/@hyperoracle/zkgraph-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
