diff --git a/README.md b/README.md
index df987b34..a133631d 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# zkRollup
+# zkRollup 2.0
## Table of Contents
@@ -15,7 +15,8 @@
2.8. [Initiliaze withdrawal off-chain](#2_8)
2.9. [Find exit transaction](#2_9)
2.10. [Complete withdrawal on-chain](#2_10)
- 2.11. [Resources](#2_11)
+ 2.11. [Bonus: create rollup account with an off-chain transaction](#2_11)
+ 2.12. [Resources](#2_12)
## 1. Description
In a nutshell, zkRollup is a layer 2 construction -- similar to Plasma -- which uses the ethereum blockchain for data storage instead of computation.
@@ -35,8 +36,8 @@ For more on zkRollup checkout our docs [here](https://docs.iden3.io/#/rollup/rol
### Testnet details
We've currently deployed an operator and the relevant contracts to the Goerli Testnet:
-1. **[Rollup.sol](https://github.com/iden3/rollup/blob/testnet/contracts/Rollup.sol)** manages the rollup itself: https://goerli.etherscan.io/address/0xE0C17C3a4f06b859124Df351Ca83864e6de46AB2.
-2. **[RollupPoS.sol](https://github.com/iden3/rollup/blob/testnet/contracts/RollupPoS.sol)** manages the consensus mechanism; in this case PoS: https://goerli.etherscan.io/address/0x60B6b593c381E5D31EC9a7b74a4cc1F2C5235EeB
+1. **[Rollup.sol](https://github.com/iden3/rollup/blob/testnet/contracts/Rollup.sol)** manages the rollup itself: https://goerli.etherscan.io/address/0xXXXXXX
+2. **[RollupPoS.sol](https://github.com/iden3/rollup/blob/testnet/contracts/RollupPoS.sol)** manages the consensus mechanism; in this case PoS: https://goerli.etherscan.io/address/0xXXXXXX
This testnet is purely for transfers (not arbitrary smart contracts), and fully supports ERC20 tokens.
@@ -110,21 +111,20 @@ node cli.js printkeys --configpath config-example.json
You should see a message with the following stucture:
```bash=
-The following keys have been found:
- Ethereum key:
- Address:
- Babyjub Key:
- Public Key:
+Ethereum public key:
+ Address:
+Rollup public key:
+ Compressed:
+ Points:
Ax:
Ay:
- Public Key Compressed:
```
Before we interact with the rollup contract, you’ll need to make sure you have some ether stored in this `Address` (this is to pay for the network transaction fees in the next step). The best way to do this is by using the goerli faucet.
Copy your ethereum address and visit the [faucet](https://goerli-faucet.slock.it/) to request test ether.
-One you've done this, visit https://goerli.etherscan.io/address/ and input your address. You should see that your balance has been updated.
+One you've done this, visit [https://goerli.etherscan.io](https://goerli.etherscan.io/) and input your address. You should see that your balance has been updated.
### 2.4. Get tokens
@@ -158,9 +158,9 @@ Note that deposits may take 2 minutes to be forged.
As before, you should see a transaction hash. You can use the this hash to [track its progress](https://goerli.etherscan.io/).
-### 2.6. Get your rollup ID
+### 2.6. Get your rollup account status
-Rollup addresses are simply Merkle tree leaf IDs. To find out what your rollup id is, use either one of the following commands:
+To find out what your rollup account status is, use either one of the following commands:
```bash=
node cli.js info --type accounts --filter ethereum -c config-example.json
@@ -189,27 +189,25 @@ Accounts found:
]
```
-You'll find your rollup id under the field `idx`.
-
-With this id, you can do things like check your balance. Either by executing the following command:
+Note that information retrieved prints all possible tokens attached to rollup account. If it is wanted to get information account for specific token, you can filter by token too:
```
-node cli.js info --type accounts --filter id --id -c config-example.json
+node cli.js info --type accounts --filter tokenid --tokenid -c config-example.json
```
-Or by visiting the following link:
+Also you could visit the following link to check your account state:
-[https://zkrollup.iden3.net/accounts/](https://zkrollup.iden3.net/accounts/1){your rollup id}
+https://zkrollup.iden3.net/accounts/:ax/:ay/:tokenid
### 2.7. Send a rollup transaction to an operator
-Now that you've created your rollup account and found your account id, it's time to send your first rollup transaction!
+Now that you've created your rollup account, it's time to send your first rollup transaction!
To do this, execute the following command:
-> You'll need to replace the first `` with your id and the second with the id of the intended recipient (for example `1`). You'll also need to replace `` with the amount you wish to send, and `` with an appropriate fee (at least 1 wei).
+> You'll need to replace the first `` with the rollup public key compressed of the intended recipient. You'll also need to replace `` with the amount you wish to send, and `` with an appropriate fee (`50%` as an example).
```bash=
-node cli.js offchaintx --type send --sender --recipient --amount --fee --tokenid 0 -c config-example.json
+node cli.js offchaintx --type send --recipient --amount --fee --tokenid 0 -c config-example.json
```
Congratulations on executing your first off-chain transaction! 🚀
@@ -224,12 +222,11 @@ To avoid paying an on-chain withdrawal fee, you need to initialise your withdraw
To do this, execute the following command:
-> As before, you’ll need to replace `` with your id, `` with the amount you wish to send, and `` with an appropriate fee (at least 1 wei).
-
+> As before, you’ll need to replace `` with the amount you wish to send, and `` with an appropriate fee (`50%` as an example).
```bash=
-node cli.js offchaintx --type withdrawoffchain --sender --amount --fee --tokenid 0 -c config-example.json
+node cli.js offchaintx --type withdrawoffchain --amount --fee --tokenid 0 -c config-example.json
```
This effectively transfers tokens to the **exit tree** -- a Merkle tree dedicated to keeping track of withdrawals. From there, they can be withdrawn using the on-chain contract.
@@ -238,10 +235,8 @@ This effectively transfers tokens to the **exit tree** -- a Merkle tree dedicate
Once the previous transaction has been forged, a new entry in the exit tree is created. You can check for this entry by executing the following command:
-> Remember to replace `` with your id.
-
```bash=
-node cli.js info --type exits --id -c config-example.json
+node cli.js info --type exits --tokenid 0 -c config-example.json
```
You'll receive a response that looks like this:
@@ -259,22 +254,38 @@ We're now ready to withdraw the tokens from the rollup chain to our wallet.
To do this, execute the following command:
-> Remember to replace `` with your id, and `` with the batch number you obtained in the previous step.
+> Remember to replace `` with the batch number you obtained in the previous step.
```bash=
-node cli.js onchaintx --type withdraw --id --numexitbatch -c config-example.json
+node cli.js onchaintx --type withdraw --tokenid 0 --numexitbatch -c config-example.json
```
Wait a couple of minutes and then visit [etherscan](https://goerli.etherscan.io/) to check that your transaction has gone through.
And voila! That's all there is to it :)
-### 2.11. Resources
+### 2.11. Bonus: create rollup account with an off-chain transaction
-- Checkout our github repository [here](https://github.com/iden3/rollup).
+We are going to creare a rollup account which does not exist on rollup ledger and send some funds to it. This means that a rollup account could be created without going on-chain and does not then does not require any ether.
+
+Get a valid rollup account from client or ask for rollup public key to some friend :)
+```bash=
+node cli.js createkeys
+```
+
+Take `Rollup public key compressed` and perform the off-chain deposit:
+```bash=
+node cli.js offchaintx --type depositoffchain --amount --tokenid 0 --fee --ethereumaddress -r
+```
+
+> In order to perform this deposit off-chain transaction, the operator must pay for an on-chain transaction and the creation of the rollup account. Transaction needs to cover this costs, otherwise operator will automatically reject the transaction. Current testnet implementation defines a `deposit fee = 0.0001 ether`. Taking into account that we consider `WEENUS token = 1$`, that would mean that, assuming ether value is 230$, deposit fee would cost 0.023 $. Therefore, to perform a deposit off-user, rollup user must pay fees that covers this deposit fees.
-- For more on how the rollup client works, see [here](https://github.com/iden3/rollup/blob/testnet/rollup-cli/README.md).
-- If you’d like to offer feedback, come across any problems, or have any questions at all, please feel free to reach out to us in our [telegram group](https://t.me/joinchat/G89XThj_TdahM0HASZEHwg).
+### 2.12. Resources
+
+- Checkout our github repository [here](https://github.com/iden3/rollup).
+
+- For more on how the rollup client works, see [here](https://github.com/iden3/rollup/blob/testnet/rollup-cli/README.md).
+- If you’d like to offer feedback, come across any problems, or have any questions at all, please feel free to reach out to us in our [telegram group](https://t.me/joinchat/G89XThj_TdahM0HASZEHwg).
\ No newline at end of file
diff --git a/package.json b/package.json
index 74dc9146..188d693c 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,6 @@
"test:coverage": "npx truffle run coverage --file='./test/contracts/*.test.js'",
"build:webapp": "browserify rollup-cli/index.js -s rollup > simple-webapp/src/utils/bundle-cli.js && browserify rollup-operator/index.js -s operator > simple-webapp/src/utils/bundle-op.js && simple-webapp/src/utils/disable-eslint.sh",
"test:all": "npm run test:rollup && cd rollup-cli && npm run test:all && cd ../rollup-operator && npm run test:all && cd ../cli-pob && npm run test:all"
-
},
"repository": {
"type": "git",
diff --git a/rollup-cli/.gitignore b/rollup-cli/.gitignore
index 38947a25..d538755a 100644
--- a/rollup-cli/.gitignore
+++ b/rollup-cli/.gitignore
@@ -2,4 +2,5 @@ getIden3.sh
node_modules
/test/resources/
/wallet.json
-/config.json
\ No newline at end of file
+/config.json
+/*.test.json
\ No newline at end of file
diff --git a/rollup-cli/cli.js b/rollup-cli/cli.js
index be4ccb03..352d38df 100644
--- a/rollup-cli/cli.js
+++ b/rollup-cli/cli.js
@@ -3,6 +3,8 @@
/* eslint-disable no-shadow */
const fs = require('fs');
const readline = require('readline');
+const chalk = require('chalk');
+
const { Writable } = require('stream');
const feeTable = require('../js/constants').fee;
@@ -26,15 +28,13 @@ rollup-cli
createkeys command
=============
- rollup-cli createkeys