Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Tutorial 6 #568

Merged
merged 20 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
efa5f3d
feat(tutorial6): add offchain library to examples
MartinMinkov Aug 24, 2023
0a619fb
chore(package.json): update snarkyjs peer dependency version from 0.8…
MartinMinkov Aug 25, 2023
1fc95e3
refactor(zkapps): update import paths and improve code readability
MartinMinkov Aug 25, 2023
0b90b63
refactor(main.ts): remove useLocal condition to always compile smart …
MartinMinkov Aug 25, 2023
5a617ac
feat(tutorial6): refactor UI to work on localhost and localblockchain
MartinMinkov Aug 25, 2023
cef9d47
feat(.gitignore): update ignore patterns to include nested node_modul…
MartinMinkov Aug 25, 2023
0c50d17
feat(tutorial6): add project
MartinMinkov Aug 25, 2023
5a74238
feat(package.json): add repository, homepage, and bugs fields to prov…
MartinMinkov Aug 25, 2023
9d6c33c
feat(index.page.tsx): add proveUpdateTransaction method call to ensur…
MartinMinkov Aug 25, 2023
58905bc
docs(06-offchain-storage.mdx): update SnarkyJS version and library li…
MartinMinkov Aug 25, 2023
b7e5444
docs(README.md): fix typo in useLocalBlockchain variable formatting f…
MartinMinkov Aug 25, 2023
52bb963
feat(tutorial6): fix ui to work with local env
MartinMinkov Aug 28, 2023
87b57a3
feat(storageServer.ts): switch useLocalBlockchain from false to true …
MartinMinkov Aug 28, 2023
f11f295
feat(tutorial6): update readme
MartinMinkov Aug 28, 2023
1fc7a5d
feat(tutorial6): update readme
MartinMinkov Aug 28, 2023
5ea68c0
feat(package.json): bump version from 0.1.2 to 0.1.3 to reflect new c…
MartinMinkov Aug 28, 2023
88459bb
docs(main.ts, mina-setup.ts): update usage instructions to reflect ne…
MartinMinkov Aug 29, 2023
6853521
feat(.gitignore): add out directory to gitignore to prevent tracking …
MartinMinkov Sep 4, 2023
ab682c6
fix(tutorial4): remove nextjs output from git
MartinMinkov Sep 4, 2023
36dc619
Merge branch 'main' into fix/tutorial-6-offchain-storage
MartinMinkov Sep 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# Dependencies
/node_modules
node_modules
/**/*/node_modules

# Production
/build
/**/*/build
/**/*/dist
/**/*/out
build
dist

# Generated files
.docusaurus
.cache-loader


# Misc
.env
.DS_Store
Expand Down
18 changes: 9 additions & 9 deletions docs/zkapps/tutorials/06-offchain-storage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ zkApp programmability is not yet available on the Mina Mainnet. You can get star

:::note

This tutorial was last tested with [SnarkyJS](https://www.npmjs.com/package/snarkyjs) 0.8.0.
This tutorial was last tested with [SnarkyJS](https://www.npmjs.com/package/snarkyjs) 0.12.1.

:::

Expand Down Expand Up @@ -76,7 +76,7 @@ This implementation requires a trust assumption for zkApps using it, that both d

This makes it useful for both prototyping applications that need off-chain storage, and putting applications into production where these trust assumptions are reasonable, but not for zkApps where a trustless solution is needed.

See the library [here](https://github.com/es92/zkApp-offchain-storage) if you'd like to learn more about this implementation and see how it works.
See the library [here](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/06-offchain-storage/experimental-zkapp-offchain-storage) if you'd like to learn more about this implementation and see how it works.

### Further Development of Single-Server Off-Chain Storage

Expand All @@ -92,9 +92,9 @@ Some suggested improvements:

## Implementing a Project Using Off-Chain Storage

As usual, there is sample code for this project, which you can find [here](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/06-offchain-storage/contracts).
As usual, there is sample code for this project, which you can find [here](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/06-offchain-storage/offchain-storage-zkapp/contracts).

We will be writing and discussing the [src/main.ts](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/06-offchain-storage/contracts/src/main.ts) and [src/NumberTreeContract.ts](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/06-offchain-storage/contracts/src/NumberTreeContract.ts) files in this project.
We will be writing and discussing the [src/main.ts](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/06-offchain-storage/offchain-storage-zkapp/contracts/src/main.ts) and [src/NumberTreeContract.ts](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/06-offchain-storage/offchain-storage-zkapp/contracts/src/NumberTreeContract.ts) files in this project.

This project implements a tree, where each leaf is either empty or stores a number, which will be our data. Updates to the tree can update a leaf, if the new number in the leaf is greater than the old number. The root of the tree is stored on chain, while the tree itself is stored on an off-chain storage server.

Expand Down Expand Up @@ -128,7 +128,7 @@ export { NumberTreeContract };
Now, add the library for the off-chain storage server we'll be using:

```sh
$ npm install experimental-zkapp-offchain-storage --save
$ npm install experimental-offchain-zkapp-storage --save
```

Also install `xmlhttprequest-ts`, which we will use to make network requests when running from nodejs, where the browser's XMLHttpRequest is not available by default:
Expand All @@ -152,7 +152,7 @@ This will fail when first run, but once we start adding code to `main.ts` and `N
Also for this project, we will need to run our storage server. To do this, in a new terminal window, change into the root of your project and run:

```sh
$ node node_modules/experimental-zkapp-offchain-storage/build/src/storageServer.js
$ node node_modules/experimental-offchain-zkapp-storage/build/src/storageServer.js
```

This will start a storage server and create a `database.json` file in the current directory to store our data for this tutorial.
Expand Down Expand Up @@ -182,7 +182,7 @@ Start by adding our imports:
16 OffChainStorage,
17 Update,
18 MerkleWitness8,
19 } from 'experimental-zkapp-offchain-storage';
19 } from 'experimental-offchain-zkapp-storage';
...
```

Expand Down Expand Up @@ -294,7 +294,7 @@ That completes the smart contract!

## Implementing `main.ts`

You can find a full copy of this file [here](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/06-offchain-storage/contracts/src/main.ts) for reference.
You can find a full copy of this file [here](https://github.com/o1-labs/docs2/blob/main/examples/zkapps/06-offchain-storage/offchain-storage-zkapp/contracts/src/main.ts) for reference.

We will not be implementing this full file, instead just discussing a few parts of it, since much is repeated from earlier tutorials. So download it from the above link, place it in your src folder, and then open it in your editor.

Expand Down Expand Up @@ -413,7 +413,7 @@ We call our smart contract as follows:
...
```

That completes our review of the code to interact with the off-chain storage server! As mentioned previously, you can find the full copy of this file [here](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/06-offchain-storage/contracts/src/main.ts) for review.
That completes our review of the code to interact with the off-chain storage server! As mentioned previously, you can find the full copy of this file [here](https://github.com/o1-labs/docs2/tree/main/examples/zkapps/06-offchain-storage/offchain-storage-zkapp/contracts/src/main.ts) for review.

## Conclusion

Expand Down
Empty file.
1 change: 0 additions & 1 deletion examples/zkapps/04-zkapp-browser-ui/ui/out/404.html

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading