Skip to content

Commit

Permalink
Copy editing docs for readability - first chunk for review (#531)
Browse files Browse the repository at this point in the history
* welcome page

* adding updated docs

* updates after review

* add new line

* small update
  • Loading branch information
kmurphypolygon authored Mar 26, 2024
1 parent 5718528 commit 69ec4dc
Show file tree
Hide file tree
Showing 14 changed files with 416 additions and 246 deletions.
Binary file added docs/img/get-started/account-a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/get-started/account-b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/get-started/commit-height.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/get-started/miden-account-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/get-started/note-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/get-started/two-accounts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/get-started/view-account-vault.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
158 changes: 158 additions & 0 deletions docs/introduction/get-started/create-account-use-faucet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
In this second, we show you how to create a new local Miden account and how to receive funds from the public Miden faucet website.

## Configure the Miden client

The Miden client facilitates interaction with the Miden rollup and provides a way to execute and prove transactions.

!!! tip
Check the [Miden client documentation](https://docs.polygon.technology/miden/miden-client/cli-reference/) for more information.

1. Clone the Miden client.

```shell
git clone https://github.com/0xPolygonMiden/miden-client
```

2. Navigate to the client directory.

```shell
cd miden-client
```

3. Modify the configuration file at `./miden-client.toml` to point to the remote Miden node.

In the `[RPC]` section, replace the `endpoint = { host: }` field with the address provided by the Miden team.
```toml
[rpc]
endpoint = { protocol = "http", host = "<NODE_IP_ADDRESS>", port = 57291 }
[store]
database_filepath = "store.sqlite3"
```
4. Build and install the client using cargo:
```shell
cargo install --features testing,concurrent --path .
```
5. Check you can use the help flag.
```shell
miden-client --help
```
## Create a new Miden account
1. Create a new account called `basic-immutable` using the following command:
```shell
miden-client account new basic-immutable
```
2. List all created accounts by running the following command:
```shell
miden-client account -l
```
3. You should something like this:
![Result of listing miden accounts](../../img/get-started/miden-account-list.png)
Save the account ID for a future step.
## Request tokens from the public faucet
1. To request funds from the faucet navigate to the following website: [Miden faucet website](https://ethdenver.polygonmiden.io/).
2. Copy the **Account ID** printed by the `miden-client account -l` command in the previous step.
3. Paste this id into the **Request test POL tokens** input field on the faucet website and click **Send me 100 tokens!**.
4. After a few seconds your browser should download - or prompt you to download - a file called `note.mno` (mno = Miden note). It contains the funds the faucet sent to your address.
5. Save this file on your computer, you will need it for the next step.
## Import the note into the Miden client
1. Import the note that you have received using the following commands:
```shell
miden-client input-notes -i <path-to-note>
```
2. You should see something like this:
```sh
Succesfully imported note 0x0ff340133840d35e95e0dc2e62c88ed75ab2e383dc6673ce0341bd486fed8cb6
```
3. Now that the note has been successfully imported, you can view the note's information using the following command:
```shell
miden-client input-notes -l
```
4. You should see something like this:
![Result of viewing miden notes](../../img/get-started/note-view.png)
!!! tip "The importance of syncing"
- As you can see, the listed note is lacking a `commit-height`.
- This is because you have received a note off-chain but have not yet synced your view of the rollup to check that the note is valid and exists at the rollup level.
- The nullified check at the operator level prevents double spends after a transaction takes place.
- Hence, before consuming the note we will need to update our view of the rollup by syncing.
### Sync the client
Do this periodically to keep informed about any updates on the node by running the `sync` command:
```shell
miden-client sync
```
You will see something like this as output:
```sh
State synced to block 179672
```
## Consume the note & receive the funds
1. Now that we have synced the client, the input-note imported from the faucet should have a `commit-height` confirming it exists at the rollup level:
```shell
miden-client input-notes -l
```
2. You should see something like this:
![Viewing commit height info](../../img/get-started/commit-height.png)
3. Find your account and note id by listing both `accounts` and `input-notes`:
```shell
miden-client account -l
miden-client input-notes -l
```
4. Consume the note and add the funds from its vault to our account using the following command:
```shell
miden-client tx new consume-notes <Account-Id> <Note-Id>
```
!!! tip
- You only need to use the first 7 characters of the Note-Id.
5. View your updated account's vault containing the tokens sent by the faucet by running the following command:
```shell
miden-client account show <Account-Id> -v
```
6. You should now see your accounts vault containing the funds sent by the faucet.
![Viewing account vault with funds](../../img/get-started/view-account-vault.png)
100 changes: 100 additions & 0 deletions docs/introduction/get-started/p2p-private-offchain-txs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
In this section, we show you how to make off-chain transactions and send funds to another account using the Miden client.

!!! important "Prerequisite steps"
- You should have already followed all previous sections.
- You should have *not* reset the state of your local client.

## Create a second account

!!! tip
Remember to use the [Miden client documentation](https://docs.polygon.technology/miden/miden-client/cli-reference/) for clarifications.

1. Create a second account to send funds with. Previously, we created a `basic-immutable` (account A). Now, create `basic-immutable` (account B) using the following command:

```shell
miden-client account new basic-immutable
```

2. List and view the newly created accounts with the following command:

```shell
miden-client account -l
```

3. You should see two accounts:

![Result of listing miden accounts](../../img/get-started/two-accounts.png)

## Transfer assets between accounts

1. Now we can transfer some of the tokens we received from the faucet to our second account B.

To do this, run:

```shell
miden-client tx new p2id <regular-account-id-A> <regular-account-id-B> <faucet-account-id> 50
```

!!! note
The faucet account id can be found on the [Miden faucet website](https://ethdenver.polygonmiden.io/) under the title **Miden faucet**.

This generates a Pay-to-ID (`P2ID`) note containing `<amount>` assets, transferred from one account to the other.

2. First, sync the accounts.

```shell
miden-client sync # Make sure we have an updated view of the state
```

3. Get the second note id.

```sh
miden-client input-notes list
```

4. Have the second account consume the note.

```sh
miden-client tx new consume-notes <regular-account-ID-B> <input-note-id>
```

!!! tip
It's possible to use a short version of the note id: 7 characters after the `0x` is sufficient.
That's it!

You should now see both accounts containing faucet assets with half the amount transferred from `Account A` to `Account B`.

!!! tip
Remember. The original amount was 100 POL.

Check the second account:

```shell
miden-client account show <regular-account-ID-B> -v # Show account B's vault assets (50 fungible tokens)
```

![Result of listing miden accounts](../../img/get-started/account-b.png)

Check the original account:

```sh
miden-client account show <regular-account-ID-A> -v # Show account A's vault assets (950 fungible tokens)
```

![Result of listing miden accounts](../../img/get-started/account-a.png)

## Clear state

All state is maintained in `store.sqlite3`, located in the directory defined in the `miden-client.toml` file.

To clear all state, delete this file. It recreates on any command execution.

## Congratulations!

You have successfully configured and used the Miden client to interact with a Miden rollup and faucet.

You have performed basic Miden rollup operations like sending transactions, generating and consuming notes.

For more information on the Miden client, refer to the [Miden client documentation](https://docs.polygon.technology/miden/miden-client/).

24 changes: 24 additions & 0 deletions docs/introduction/get-started/prerequisites.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This section shows you how to get started with Miden by generating a new Miden account, requesting funds from a public faucet, and interacting with the Miden rollup using the Miden client.

By the end of this tutorial, you will have:

- Configured the Miden client.
- Connected to a Miden node.
- Created an account and requested funds from the faucet.
- Transferred assets between accounts by generating and consuming notes.

## Prerequisites

### Rust

Download from [the Rust website](https://www.rust-lang.org/learn/get-started).

### Miden node IP address

You will need access to a Miden node. The node processes transactions and creates blocks for the Miden rollup.

Get the IP address of the running Miden node by contacting one of the Miden engineers.

### Miden client

Install the [Miden client](https://docs.polygon.technology/miden/miden-client/install-and-run/).
Loading

0 comments on commit 69ec4dc

Please sign in to comment.