Skip to content

Instantly share code, notes, and snippets.

@an-ivannikov
Created January 7, 2022 18:07
Show Gist options
  • Save an-ivannikov/22cf9482310db0d4bce7d8ec0a0806db to your computer and use it in GitHub Desktop.
Save an-ivannikov/22cf9482310db0d4bce7d8ec0a0806db to your computer and use it in GitHub Desktop.
Uniswap V2 INIT_CODE_HASH
The problem is that you first need to compile the `uniswap-v2-core` contracts
Next, you need to get `INIT_CODE_HASH` from the bytecode of the `UniswapV2Pair.sol`
```js
// file ./get-init-code-hash.js
const UniswapV2Pair = artifacts.require('UniswapV2Pair.sol');
module.exports = async (callback) => {
console.log(
'UniswapV2Pair bytecode hash (Look for INIT_CODE_HASH):\n%s',
(web3.utils.keccak256(UniswapV2Pair.bytecode)).substring(2)
);
callback();
}
```
Run it code
```bash
truffle exec ./get-init-code-hash.js
```
Next you need
1) Replace it in Line # 24 for `uniswap-v2-periphery/contracts/libraries/UniswapV2Library.sol`.
2) Replace it in `INIT_CODE_HASH` for` uniswap-sdk/src/constants.ts`.
_When replacing the code, you need to pay attention to the places where the prefix `0x` is found, you need to save it and replace what follows it._
Next you need
1) compile the `uniswap-v2-periphery` code
Next you need
1) deploy `UniswapV2Factory.sol` and `UniswapV2Router02.sol`
2) replace the corresponding addresses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment