- Install Chrome, Firefox, Opera
- Install MetaMask
- Install NodeJS
For local testing comment out initializer function and uncomment constructor. Also, remove ProxyOwnable inheritance. Revert to the initializer method when migrating with truffle to a testnet or mainnet.
- Single line view
git pull --all; npm install; truffle compile; npx truffle migrate --compile-all --network ropsten --reset
- Execute the command below to pull in all the most recent changes
git pull --all
- Execute the command below to install all pinned dependencies for project
npm ci
- Execute the command below to compile smart contracts
truffle compile
- Execute the command below to deploy to testnet
- Ropsten:
npx truffle migrate --compile-all --network ropsten --reset - Rinkeby:
npx truffle migrate --compile-all --network rinkeby --reset
- Ropsten:
truffle console --network rinkebyconst {ethers} = require('ethers')const instance = await EMaxCoin5.deployed()orlet instance = await EMaxCoin7.at("<contractAddress>")instance.name()instance.symbol()instance.balanceOf('address')instance.transfer(ethers.utils.getAddress("<toAddress>"), ethers.utils.parseEther("amount"))instance.<VariableName>.call().then(function (res) {console.log(res)})
address factory = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;
address token0 = 0x15874d65e649880c2614e7a480cb7c9A55787FF6; // mainnet: eMax, rinkeby: address(this)
address token1 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; // mainnet: wETH (0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2), rinkeby: wETH (0xc778417E063141139Fce010982780140Aa0cD5Ab)
address pair = address(uint160(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f'
)))));
Do the following to confirm upgrade works as expected:
- compile the code.
- deploy to ropsten
- change the code
- do some transactions
- compile the code
- deploy update to ropsten
- validate balances
- do some transactions
This is straightforward because you are probably doing a --reset so it's a clean deployment, and all deployments are using the same compiler runs and addresses are properly cached.
- compile the code
- Make a mental note of the latest migration script number (for example:
4as defined as the latest migration script of4_deploy_burn) - Be prepared to press ctrl+C to abort the deployment
- Get ready to press ctrl+C to cancel so you do not deploy a duplicate token
- Run the deployment, and look for
X_latest_migration.jsbeing the first migration executed
ABORT when you see `1_initial_migration.js` ideally before it even says `Deploying`, as below
Starting migrations...
======================
> Network name: 'ropsten'
> Network id: 3
> Block gas limit: 8000000 (0x7a1200)
1_initial_migration.js
======================
Error: Contract at <0xADDRESS> doesn't look like an EIP 1967 proxy
Fix: Look at the migration script this failed on, and either use the await EMaxCoin.deployed(); approach -OR- update the hardcoded address.
- build script calls
const deployed = await EMaxCoin2.deployed();and it is unable to resolve.
Fix: hardcode the address instead of deployed.address, there is a commented out example in 4_deploy_burn.js
- IF THE MIGRATION STARTS BACK AT STEP 1_initial_migration.js...
Openzeppelin uses data within the build/contracts/Migrations.json file.
This file has a section called networks. As defined in truffle.config, mainnet is network: 1. Ropsten is network:3 and the below still holds (just update )
Update the networks json object to ensure it has the following definitions for network:1
The source of this information is etherscan - the first transaction made by the origin wallet was to create the migration script when the contract was originally deployed, so we need to use that address and transaction hash.
"networks": {
"1": {
"events": {},
"links": {},
"address": "0x8E64f15F1D8cF6743558F916befa06E41E68224B",
"transactionHash": "0x6b2285ae58213b1938fe139485d5d65a938fcd85eed1dddbc24a563763ef89d4"
},
...
}
- Execute the command below to compile scripts
npx truffle compile
- Execute the command below to do a deployment, but get ganache running locally.
npx truffle migrate
- Execute the command below to deploy to ropsten
npx truffle migrate --compile-all --network ropsten --reset
- Execute the command below to deploy to mainnet
npx truffle migrate --compile-all --network mainnet --reset
- Execute the command below to run verification
truffle run verify :COIN_NAME --network :NETWORK_NAME
- Execute the command below to run tests
- launch ganache
npx truffle test
- Until improved, visit remix.ethereum.org and install the
Flatteneraddon. Import the relevant files into the editor, run the flattener, and clean up compilation errors related to licenses and order of include statements.
Click here to explain the 4 contracts, 'TransparentUpgradeableProxy'