Added ganache setup guide

This commit is contained in:
Chris Kalani
2019-08-13 16:09:50 -07:00
committed by fabioberger
parent b58d4005d3
commit d5a22829ac
2 changed files with 82 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
In order to run 0x.js methods that interact with the Ethereum blockchain (i.e filling an order, checking a balance or setting an allowance) you need to point your Web3 Provider to an Ethereum node. Because of the ~12 second block times, during development it is best to use [Ganache-cli](https://github.com/trufflesuite/ganache-cli) a fast Ethereum RPC client made for testing and development.
# Install Ganache-cli locally
```
npm install -g ganache-cli@6.1.6
```
In order to run Ganache-cli with all the latest V2 0x protocol smart contracts available, you must first download [this Ganache-cli snapshot](http://ganache-snapshots.0x.org.s3.amazonaws.com/0x_ganache_snapshot-2.4.0.zip) and save it. Next unzip it's contents with:
```bash
unzip ./0x_ganache_snapshot-2.4.0.zip -d ./0x_ganache_snapshot
```
You can now start Ganache-cli as follows:
```bash
ganache-cli \
--networkId 50 \
-p 8545 \
--db ./0x_ganache_snapshot \
-m "concert load couple harbor equip island argue ramp clarify fence smart topic"
```
**Note:** The `--db` flag expects the filepath to where the DB snapshot folder is located on your machine.
Since we started Ganache-cli on port 8545, we can pass ZeroEx the following provider during instantiation:
```
const provider = new Web3.providers.HttpProvider('http://localhost:8545');
```
0x.js will now communicate with Ganache-cli over HTTP.
To test that your setup is working, use this cURL request to fetch the byte-code for the Exchange contract:
```
curl -X POST \
http://localhost:8545/ \
-d '{"jsonrpc":"2.0","method":"eth_getCode","params":["0x0b1ba0af832d7c05fd64161e0db78e85978e8082", "latest"],"id":1}'
```
If the result key does not return `0x0`, then the contract code was successfully returned.
---
# Contract addresses
- Exchange.sol: `0x48bacb9266a570d521063ef5dd96e61686dbe788`
- ERC20Proxy.sol: `0x1dc4c1cefef38a777b15aa20260a54e584b16c48`
- ERC721Proxy.sol: `0x1d7022f5b17d2f8b695918fb48fa1089c9f85401`
- MultiAssetProxy.sol: `0x6a4a62e5a7ed13c361b176a5f62c2ee620ac0df8`
- ZRXToken.sol: `0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c`
- AssetProxyOwner.sol: `0x04b5dadd2c0d6a261bfafbc964e0cac48585def3`
- WETH9.sol: `0x0b1ba0af832d7c05fd64161e0db78e85978e8082`
- Forwarder.sol: `0x6000eca38b8b5bba64986182fe2a69c57f6b5414`
- OrderValidator.sol: `0x32eecaf51dfea9618e9bc94e9fbfddb1bbdcba15`
- DutchAuction.sol: `0x7e3f4e1deb8d3a05d9d2da87d9521268d0ec3239`
- Coordinator.sol: `0x4d3d5c850dd5bd9d6f4adda3dd039a3c8054ca29`
- CoordinatorRegistry.sol: `0xaa86dda78e9434aca114b6676fc742a18d15a1cc`
# Dummy tokens for testing
- DummyERC20Token.sol: `0x34d402f14d58e001d8efbe6585051bf9706aa064`
- DummyERC20Token.sol: `0x25b8fe1de9daf8ba351890744ff28cf7dfa8f5e3`
- DummyERC20Token.sol: `0xcdb594a32b1cc3479d8746279712c39d18a07fc0`
- DummyERC20Token.sol: `0x1e2f9e10d02a6b8f8f69fcbf515e75039d2ea30d`
- DummyERC20Token.sol: `0xbe0037eaf2d64fe5529bca93c18c9702d3930376`
- DummyERC721Token.sol: `0x07f96aa816c1f244cbc6ef114bb2b023ba54a2eb`
The first EOA generated by the supplied mnemonic (`0x5409ed021d9299bf6814279a6a1411a7e866a631`) has a starting balance of 1,000,000,000 ZRX and all 9 unlocked accounts have a balance of ~100 ETH. The dummy tokens can be minted by any address by calling the respective contract methods ([ERC20](https://github.com/0xProject/0x-monorepo/blob/69c7c03fb34b3f21f65c40b73baa21184a296fb2/contracts/erc20/contracts/test/DummyERC20Token.sol#L67) & [ERC721](https://github.com/0xProject/0x-monorepo/blob/69c7c03fb34b3f21f65c40b73baa21184a296fb2/contracts/erc721/contracts/test/DummyERC721Token.sol#L47) method).

View File

@@ -63,5 +63,16 @@
"type": "Command-line tools",
"path": "tools/ethereum-types/v2.1.4/reference.mdx",
"versions": ["v2.1.4"]
},
"ganache-setup": {
"title": "How to Set Up Ganache",
"description": "",
"topics": ["Ganache"],
"difficulty": "Intermediate",
"isCommunity": false,
"isFeatured": false,
"tags": ["Protocol developer"],
"type": "Command-line tools",
"path": "guides/ganache-setup.mdx"
}
}