- Create
.env
file to deploy
cp .env.example .env
yarn
yarn
yarn deploy:boltchain
Each time you update UniswapV2Pair.sol
contract, you need to update the hex
value in this line:
Use this command to get a new value:
$ cat artifacts/contracts/UniswapV2Pair.sol/UniswapV2Pair.json| jq -r .bytecode| xargs cast keccak| cut -c 3-
(Ensure you have jq and cast installed)
Why? Uniswap V2 uses CREATE2 opcode to deploy pair contracts. This opcode allows to generate contract addresses deterministically without depending on external state (deployer's nonce). Instead, it uses the hash of the deployed contract code and salt:
https://github.com/Switcheo/bolt-evm-dex-core/blob/master/contracts/UniswapV2Factory.sol#L42
Each time you update the Pair contract (even when you change compiler version), its bytecode changes, which means the hash of the bytecode also changes.