DX-React is a React/Redux/Truffle + Web3 frontend application interfacing with the DX-Contracts
The rest of this guide assumes you are using up-to-date versions of Node, NPM, Chrome and MetaMask, respectively.
-
Install
ganache-cli
&truffle
globally - we recommend[email protected]
right now for stabilitynpm i -g ganache-cli [email protected]
-
Grab the
dx-react
projectgit clone [email protected]:gnosis/dx-react.git
-
Install deps - please be patient as this may take a little while.
npm install
-
Running the app - please have 3 terminals/tabs ready
Step 1:
npm run rpc
Step 2:
npm run migrate
Step 3:
npm start
-
Head to
localhost:5000
in Chrome
- Grab the
dx-react
projectgit clone [email protected]:gnosis/dx-react.git
- Install deps - please be patient as this may take a little while.
npm install
- Launch the server:
npm run start:localProd
- Head to
localhost:5000
in Chrome
Please refer to the Truffle Docs for much more in-depth info on migrations/deployment
-
Take a look inside
./test/contracts
to see 2 local only contracts used in testingWhen using test tokens, they first need to be created as in the above folder, and then deployed
-
Take a look inside
./migrations
Notice that the files are named clearly and superseded by numbers. Migration scripts are fired sequentially! Use conditionals here to facilitate deploying contracts only on certain networks - e.g:
module.exports = (deployer, network) => { if (network === 'development') return deployer.deploy(TokenOMG, 50000e18).then(() => deployer.deploy(TokenRDN, 50000e18)) return console.log('Not running on development, skipping.') }
The migration script export accepts 3 params: a.
module.exports = (deployer, network, accounts) => { ... }
1. deployer: Function 2. network: string 3. accounts: string[]
from the TruffleContract repo:
Your migration files will use the deployer to stage deployment tasks. As such, you can write deployment tasks synchronously and they'll be executed in the correct order:
// Stage deploying A before B deployer.deploy(A); deployer.deploy(B);
Alternatively, each function on the deployer can be used as a Promise, to queue up deployment tasks that depend on the execution of the previous task:
// Deploy A, then deploy B, passing in A's newly deployed address deployer.deploy(A).then(function() { return deployer.deploy(B, A.address); });
returns string ('development' | 'rinkeby' | 'main', 'kovan' | 'ropsten')
As mentioned above, can be used to grab network info in migrations flow. Conditional migrating, for example
returns string[]
Use to migrate/deploy contracts with certain addresses. On local these are the accounts first listed in
ganache-cli
Please refer to the Ganache-CLI repo for more information
-
Deploying contracts
Now it's time to deploy! Finally! Your
./migrations
folder will contain files something like:1_initial_migrations.js
2_DEV_ONLY_Migrate_Deps.js
3_DEV_ONLY_Migrate_Test_Tokens.js
Where numbers 2 and 3 use conditional network checking logic to only deploy when ganache is set on the
development
(local) network.
-
-
Under
./test/resources/token-lists/<NETWORK>/
you'' find the available tokens in their respective formats. a. Adding: You MUST add new tokens in the exact same format. b. Removing: Delete the tokens object. -
Open up
./src/globals/index.ts
a. Head to:// Network token list hashes (latest versions) export const TESTING_TOKEN_LIST_HASH = 'QmXgUiWTumXghNuLk3vAypVeL4ycVkNKhrtWfvFHoQTJAM' export const RINKEBY_TOKEN_LIST_HASH = process.env.FE_CONDITIONAL_ENV === 'production' ? 'QmW4NCDDZRexP5FVpMQXxNWwFHTQjCGeb5d8ywLs2XRJxR' : 'QmfB3fRGacBseNiBMhKFaYoEGDyiWnUCBPsE7Xo3sKqSyi' export const KOVAN_TOKEN_LIST_HASH = 'QmVk68VH1D2uGx2LUGXsrfvKHQiA1R4sjw8cw4so33DPsw' export const MAINNET_TOKEN_LIST_HASH = 'Qmbe4nTY26Gv2qiTqqd1Ax3s94NuCdvwf9UogAH3nTKfPd' export const TokenListHashMap = { RINKEBY: RINKEBY_TOKEN_LIST_HASH, KOVAN: KOVAN_TOKEN_LIST_HASH, MAIN: MAINNET_TOKEN_LIST_HASH, }
b. You will need to update the network token list hash. Right now the lists are local but also updated on IPFS where we get back unique hashes.
i. Copy the path to the updated token list from step 1 ii. In your terminal, run: `node test/scripts/add2ipfs.js <PATH/TO/TOKEN-LIST/HERE>` and copy the returned hash - Test that it worked using the hash and the URL returned iii. Replace the respective network token list hash from step 2 with the newly returned hash
If you want a Token to be added to Rinkeby token list, please follow instructions in ADD_TOKEN_REQUEST_TEMPLATE.md.
This project is licensed under the MIT License - see the LICENSE.md file for details