-
Notifications
You must be signed in to change notification settings - Fork 64
feat: add zkSync with RedStone tutorial #8
feat: add zkSync with RedStone tutorial #8
Conversation
8313ff5
to
a2ba5a8
Compare
a2ba5a8
to
af65f2f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor suggestions and comments
|
||
#### 1. Clone this repo | ||
```sh | ||
git clone https://github.com/redstone-finance/stable-price-marketplace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git clone https://github.com/redstone-finance/stable-price-marketplace | |
git clone https://github.com/zkSync-Community-Hub/tutorials |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
#### 1. Clone this repo | ||
```sh | ||
git clone https://github.com/redstone-finance/stable-price-marketplace | ||
cd stable-price-marketplace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cd stable-price-marketplace | |
cd tutorials/tutorials/zkSync-RedStone-stable-price-marketplace-tutorial |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
### Tests | ||
|
||
We've used hardhat test framework to contract tests. All the tests are located in the [test](test/) folder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the tests all pass on your end? When I run the tests I get:
yarn test
yarn run v1.22.19
$ NODE_ENV=test hardhat test --network zkSyncTestnet
ExampleNFT
✔ Should deploy ExampleNFT (2136ms)
✔ Should mint 2 NFTs (1778ms)
✔ User1 should approve spending and User2 should spend (2838ms)
Marketplace core functions test
✔ Should deploy contracts (3038ms)
✔ Should mint NFT (889ms)
✔ Seller should post sell order for token 1 with ETH price (2859ms)
✔ Should get all orders
Expected ETH amount: 1.0
✔ Buying should fail with smaller amount then seller requested (316ms)
Expected ETH amount: 1.0
✔ Buyer should buy token 1 for ETH price (917ms)
✔ Should post and cancel order (4811ms)
Marketplace core functions test
✔ Should deploy contracts (2953ms)
✔ Should mint NFT (1901ms)
✔ Seller should post sell order for token 2 with stable USD price (2778ms)
✔ Should wrap marketplace contract with redstone wrapper
Expected ETH amount: 0.0
1) Buying should fail with smaller amount then seller requested
Expected ETH amount: 0.0
2) Buyer should buy token for USD price expressed in ETH
14 passing (31s)
2 failing
1) Marketplace core functions test
Buying should fail with smaller amount then seller requested:
AssertionError: Expected transaction to be reverted
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Context.<anonymous> (test/stable-marketplace.test.ts:88:5)
2) Marketplace core functions test
Buyer should buy token for USD price expressed in ETH:
Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (error={"reason":"execution reverted","code":"UNPREDICTABLE_GAS_LIMIT","method":"estimateGas","transaction":{"from":"0xa61464658AfeAf65CccaaFD3a512b69A83B77618","gasPrice":{"type":"BigNumber","hex":"0x0ee6b280"},"to":"0x0a67078A35745947A37A552174aFe724D8180c25","value":{"type":"BigNumber","hex":"0x00"},"data":"0xd96a094a0000000000000000000000000000000000000000000000000000000000000000455448000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025171e97dd018a845a3920000000200000010184df94c1cdf3dacc79d3081d78a5798364ee89ab96a76a9145e796ad9db325299c10dba57d6b4cb294ea811069d44477a21c718d6785174d52fa86bd6ef94a1b00013136393434333736373338343623302e322e352372656473746f6e652d6d61696e2d64656d6f000026000002ed57011e0000","type":0,"accessList":null},"error":{"reason":"processing response error","code":"SERVER_ERROR","body":"{\"jsonrpc\":\"2.0\",\"error\":{\"code\":3,\"message\":\"execution reverted\",\"data\":\"0x\"},\"id\":68}","error":{"code":3,"data":"0x"},"requestBody":"{\"method\":\"eth_estimateGas\",\"params\":[{\"gasPrice\":\"0xee6b280\",\"type\":\"0x0\",\"value\":\"0x0\",\"from\":\"0xa61464658afeaf65cccaafd3a512b69a83b77618\",\"to\":\"0x0a67078a35745947a37a552174afe724d8180c25\",\"data\":\"0xd96a094a0000000000000000000000000000000000000000000000000000000000000000455448000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025171e97dd018a845a3920000000200000010184df94c1cdf3dacc79d3081d78a5798364ee89ab96a76a9145e796ad9db325299c10dba57d6b4cb294ea811069d44477a21c718d6785174d52fa86bd6ef94a1b00013136393434333736373338343623302e322e352372656473746f6e652d6d61696e2d64656d6f000026000002ed57011e0000\"}],\"id\":68,\"jsonrpc\":\"2.0\"}","requestMethod":"POST","url":"http://localhost:3050"}}, tx={"data":"0xd96a094a0000000000000000000000000000000000000000000000000000000000000000455448000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025171e97dd018a845a3920000000200000010184df94c1cdf3dacc79d3081d78a5798364ee89ab96a76a9145e796ad9db325299c10dba57d6b4cb294ea811069d44477a21c718d6785174d52fa86bd6ef94a1b00013136393434333736373338343623302e322e352372656473746f6e652d6d61696e2d64656d6f000026000002ed57011e0000","to":{},"from":"0xa61464658AfeAf65CccaaFD3a512b69A83B77618","value":{"type":"BigNumber","hex":"0x00"},"type":0,"gasPrice":{},"nonce":{},"gasLimit":{},"chainId":{}}, code=UNPREDICTABLE_GAS_LIMIT, version=abstract-signer/5.7.0)
at Logger.makeError (node_modules/@ethersproject/logger/src.ts/index.ts:269:28)
at Logger.throwError (node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
at /Users/dennis/Documents/Code/tutorials/tutorials/zkSync-RedStone-stable-price-marketplace-tutorial/node_modules/@ethersproject/abstract-signer/src.ts/index.ts:301:31
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Promise.all (index 7)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but they will pass when you populate functions indicated in the tutorial like buy
in dApp or _getPriceFromOrder
in StableMarketplace
contract
return new ethers.Contract(address, abi, signer); | ||
} | ||
|
||
async function buy(orderId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async function buy(orderId) { | |
async function buy(orderId: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
#### 2. Compile contracts | ||
```sh | ||
yarn compile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command does not exist in package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
<img alt="orders" src="docs/img/orders.png" width="300" /> | ||
|
||
##### Buy NFTs | ||
You can also switch metamask account and buy the NFT. I would recommend to open the developer tools in browser at the network tab and explore network requests that are being sent before the buy transaction sending. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, the problem was with an invalid function name in the tutorial text
3afc39e
to
7505929
Compare
Tutorial submission
Title of the tutorial
zkSync and RedStone stable price NFT marketplace tutorial
Brief tutorial description
This tutorial will show how to use RedStone oracles on the zkSync Era blockchain. It is designed as an example dApp of a stable price NFT marketplace. It means that sellers can create sell orders (offers), specifying the price amount in USD. But buyers are able to pay with native coins, the required amount of which is calculated dynamically at the moment of the order execution. Users will be requested to add a few crucial parts which will make it possible to use RedStone data on-chain and run application on zkSync local testnet.
Checklist
Please ensure you've completed the following tasks: