# ZKWASM Cloud Service

The [Delphinus Lab Service Explorer](https://zkwasm-explorer.delphinuslab.com/) provides a convenient user interface to:

1. Submit Web Assembly images where zkWasm generates zkSNARK circuits for the image.
2. Prove a Web Assembly image execution.
3. Deploy a verification contract on an Ethereum Testnet.

To interact with Delphinus Lab service [install metamask](https://metamask.io/download/) as a browser extension and obtain some testnet coins.

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-a3bd59578d2d17d52d535199d00d0176d892d1a7%2F0_metamask.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://github.com/DelphinusLab/zkwasm-book/blob/main/c4_cloud/assets/images/0_metamask" alt="title image light / dark." width="363"></picture></div>

Paste the below example C source in to [WasmFiddle](https://wasdk.github.io/WasmFiddle/) and hit the Build button in the top center of the page.

```C
unsigned long long wasm_input(int); // external host api for fetch user inputs.

int zkmain() {
  int sum = wasm_input(1);
  int b = sum + 2;
  return b + 1;
}
```

Save the build application as `example.wasm` to a local directory on your machine.

## Submitting a New Application:

Using upper right task bar on [Delphinus Lab Service Explorer](https://zkwasm-explorer.delphinuslab.com/) click `Create New Application` and upload the `example.wasm` in the "Image ID (MD5)" field.

### Setup Phase:

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-785c8704be3545a75574be9d1fde333bac1561df%2F1_taskbar.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-785c8704be3545a75574be9d1fde333bac1561df%2F1_taskbar.png?alt=media" alt="title image light / dark." width="700"></picture></div>

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-c327f0e2710bc94c8f870007e6bad414750aa94e%2F2_new_application.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-c327f0e2710bc94c8f870007e6bad414750aa94e%2F2_new_application.png?alt=media" alt="title image light / dark." width="700"></picture></div>

You can see that the `TASK ID 64d09a94f0e3eee93f7e8e04` has moved from "Processing" to the "Done" state.

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-d071f7899bda36abe6c63fb9baa034d5ee587a14%2Ftest02_3_applicatioprocessing.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-d071f7899bda36abe6c63fb9baa034d5ee587a14%2Ftest02_3_applicatioprocessing.png?alt=media" alt="title image light / dark." width="700"></picture></div>

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-f6537b8fe76ff4dbd74aabcb9cf133c3642543d0%2Ftest02_4_applicationdone.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-f6537b8fe76ff4dbd74aabcb9cf133c3642543d0%2Ftest02_4_applicationdone.png?alt=media" alt="title image light / dark." width="700"></picture></div>

Inspecting the task in the explorer shows the Application Image Hash: `B246F9E85B9D392B0A33374974A2CA23`, and the Setup phase Status as "Done".

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-6859dc4cfcb0db4cd9ebcb888564eaf5dcf017e5%2Ftest02_4_applicationdone2.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-6859dc4cfcb0db4cd9ebcb888564eaf5dcf017e5%2Ftest02_4_applicationdone2.png?alt=media" alt="title image light / dark." width="700"></picture></div>

### Submit a Proof:

At the top of the explorer, hit "Submit Prove Task", a new popup window will appear to create a new prove task. In the Image hash part input the application hash. In this example it is: `C0704FFA2384B360548789AD22911938`. With the image hash input the public input you can enter should be an integer 64-bit type, here for this example we are using the value 112, input: `112:i64`.

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-8c4a200749421d5e2ea881542f99bb92a1298406%2Ftest02_5_provedone.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-8c4a200749421d5e2ea881542f99bb92a1298406%2Ftest02_5_provedone.png?alt=media" alt="title image light / dark." width="700"></picture></div>

You can view the "Proof Info" details which contains the inputs, transcripts, auxiliary data (for batch field dividing in smart contracts) and instances of the proof batching circuits:

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-38abbaaf9f64e956753cb3651833b81bcf0f9971%2Ftest02_15_proofinfo.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-38abbaaf9f64e956753cb3651833b81bcf0f9971%2Ftest02_15_proofinfo.png?alt=media" alt="title image light / dark." width="700"></picture></div>

### Deploying a Verification Contract:

One the application has been Setup and has a Proof generated, a verification contract can be deployed on one of the Ethereum testnets. Hit the "Deploy Verification Contract" at the top of the explorer. Input the Image ID, in this case `C0704FFA2384B360548789AD22911938` and choose a test network to deploy to. Hit "Confirm".

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-b9ebd0ac739150d1261142fbc313d11d6585e0bc%2Ftest02_6_deployverification.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-b9ebd0ac739150d1261142fbc313d11d6585e0bc%2Ftest02_6_deployverification.png?alt=media" alt="title image light / dark." width="700"></picture></div>

Sign the transaction and wait for the verification contract to be deployed.

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-d2e463b0ed693b381be5a062c8b3615e0cd2f35d%2Ftest02_7_sign.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-d2e463b0ed693b381be5a062c8b3615e0cd2f35d%2Ftest02_7_sign.png?alt=media" alt="title image light / dark." width="380"></picture></div>

In the main window of the explorer the deployment task can be seen as "Processing",

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-0d81f37a3d3e283c10be100416334da92867beaf%2Ftest02_8_deployprocessing.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-0d81f37a3d3e283c10be100416334da92867beaf%2Ftest02_8_deployprocessing.png?alt=media" alt="title image light / dark." width="700"></picture></div>

and after a short amount of time the status of this task is "Done".

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-d7701bde2ba5de29fce740313ae39b67d056e4f1%2Ftest02_9_deploydone.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-d7701bde2ba5de29fce740313ae39b67d056e4f1%2Ftest02_9_deploydone.png?alt=media" alt="title image light / dark." width="700"></picture></div>

The Deployment Info shows a "Details section" with the address of the contract,

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-d1c1be1d9c73bf3aa328e10b51a933541653bc5c%2Ftest02_12_deploydone.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-d1c1be1d9c73bf3aa328e10b51a933541653bc5c%2Ftest02_12_deploydone.png?alt=media" alt="title image light / dark." width="700"></picture></div>

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-8a6dbc2332f6b382526c10ca612c3b4e7f73daaa%2Ftest02_13_deploymentinfo.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-8a6dbc2332f6b382526c10ca612c3b4e7f73daaa%2Ftest02_13_deploymentinfo.png?alt=media" alt="title image light / dark." width="700"></picture></div>

This can be seen on etherscan:

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-30ede05c84ebee84ff45b48c2a60bcb88e925619%2Ftest02_14_etherscan.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-30ede05c84ebee84ff45b48c2a60bcb88e925619%2Ftest02_14_etherscan.png?alt=media" alt="title image light / dark." width="1000"></picture></div>

With the verification contract deployed we can verify the proof on chain with the "Verify on Chain" facility. Within the proof section of the image in the explorer, select the Task ID for the proof, to view the proof task, then select "View Proof Info".

<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-3003f7aa9a05891259c932c92e52a55897cf3400%2Ftest02_16_complete.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-3003f7aa9a05891259c932c92e52a55897cf3400%2Ftest02_16_complete.png?alt=media" alt="title image light / dark." width="1000"></picture></div>

Hit the Verify on Chain button, sign the transaction, in some time the transaction receipt should should produce a successful on chain verification.\


<div align="center"><picture><source srcset="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-58f57f92f2e5980d705c12947d01e935d3aaa59d%2Ftest02_17_prooftranscripts.png?alt=media" media="(prefers-color-scheme: dark)"><img src="https://2826657678-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzIfXJlVv3ntN6tleVFjn%2Fuploads%2Fgit-blob-58f57f92f2e5980d705c12947d01e935d3aaa59d%2Ftest02_17_prooftranscripts.png?alt=media" alt="title image light / dark." width="700"></picture></div>

`Verification transaction successful! Transaction hash: 0x64f0c91ff3687541c674d9324a5869c9734f4729799869217e5640cda353f255`
