{"id":31769306,"url":"https://github.com/second-state/how_to_deploy_uniswap","last_synced_at":"2026-02-25T21:03:36.272Z","repository":{"id":49611104,"uuid":"290920503","full_name":"second-state/how_to_deploy_uniswap","owner":"second-state","description":"Detailed instructions on how to deploy Uniswap on an Ethereum compatible blockchain","archived":false,"fork":false,"pushed_at":"2021-06-12T04:06:29.000Z","size":668,"stargazers_count":144,"open_issues_count":11,"forks_count":92,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-10T02:44:02.128Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/second-state.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-28T01:24:33.000Z","updated_at":"2025-06-23T02:25:07.000Z","dependencies_parsed_at":"2022-09-13T21:40:14.864Z","dependency_job_id":null,"html_url":"https://github.com/second-state/how_to_deploy_uniswap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/second-state/how_to_deploy_uniswap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fhow_to_deploy_uniswap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fhow_to_deploy_uniswap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fhow_to_deploy_uniswap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fhow_to_deploy_uniswap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/second-state","download_url":"https://codeload.github.com/second-state/how_to_deploy_uniswap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/second-state%2Fhow_to_deploy_uniswap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29839952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T20:42:33.054Z","status":"ssl_error","status_checked_at":"2026-02-25T20:42:21.322Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-10T02:43:23.299Z","updated_at":"2026-02-25T21:03:36.266Z","avatar_url":"https://github.com/second-state.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"//** Please note this is a draft and this code is under heavy development. Not to be used in production **\n\n# How to deploy Uniswap\n\n--- \n\n## Housekeeping\nThe code in this section is packaged up into a single `./utils/housekeeping.sh` file for your convenience. Below are the details of all of the `./utils/housekeeping.sh` commands for your understanding.\n\n```\nsudo apt-get update\nsudo apt-get -y upgrade\nsudo apt-get install npm\nnpm install fs\nnpm install web3\nnpm install truffle-hdwallet-provider\nsudo apt-get install apache2\n# install Yarn\ncurl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -\necho \"deb https://dl.yarnpkg.com/debian/ stable main\" | sudo tee /etc/apt/sources.list.d/yarn.list\nsudo apt update \u0026\u0026 sudo apt install yarn\n```\n\nUpdate version of node\n```\ncurl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -\nsudo apt-get install -y nodejs\n```\n\nClone the Uniswap Interface code using Git.\n```\ncd ~\ngit clone https://github.com/Uniswap/uniswap-interface.git\n```\nChange into the Uniswap Interface directory.\n```\ncd ~\ncd uniswap-interface\n```\nNow, whilst in the `~/uniswap-interface directory`, clone the \"How To Install Uniswap\" code using Git.\n```\ngit clone https://github.com/second-state/how_to_deploy_uniswap.git\n```\nChange into the `how_to_deploy_uniswap/` directory.\n```\ncd how_to_deploy_uniswap/\n```\n\n--- \n\n## Accounts\n\nCreate 3 Ethereum compatible addresses using any method that you are comfortable with i.e. [web3js](https://web3js.readthedocs.io/en/v1.2.11/web3-eth-accounts.html) etc.\n\nNow paste the **private** and **public** keys of those addresses into the installation_data.json file as shown below.\n```\nvi ~/uniswap-interface/how_to_deploy_uniswap/installation_data.json\n```\nHere is an example of the `private_key` and `public_key` sections of that file.\n```\n  \"private_key\": {\n    \"alice\": \"your_new_key_here\",\n    \"bob\": \"your_new_key_here\",\n    \"charlie\": \"your_new_key_here\"\n  },\n  \"public_key\": {\n    \"alice\": \"your_new_key_here\",\n    \"bob\": \"your_new_key_here\",\n    \"charlie\": \"your_new_key_here\"\n  }\n```\nYou will need to fund these accounts with network tokens. So depending on your network, please go ahead and send at least 20 network tokens (from a Faucet etc.) to all three of these accounts.\n\nNow place the RPC URL to your Ethereum compatible network in that same `installation_data.json` file.\n```\nvi ~/uniswap-interface/how_to_deploy_uniswap/installation_data.json\n```\nHere is an example of the `rpc_endpoint` section of that file.\n```\n\"provider\": {\n\t\"rpc_endpoint\": \"http://rpc_url:port\"\n}\n```\n\n--- \n\n## V1\nNow run the Uniswap V1 smart contract installer.\n```\ncd ~/uniswap-interface/how_to_deploy_uniswap/uniswap_v1\n```\n```\nnode deploy_uniswap_v1.js\n```\nIf you open the `../installation_data.json` file, you will see that the Uniswap V1 contract addresses and the Alice and Bob (ERC20 and ERC20 Exchange) addresses have been automatically filled in.\n```\n\"contract_address\": {\n    \"uniswap_factory\": \"0x2DF5e651be537bB564005340EA5D8f6fA763b530\",\n    \"weth\": \"\",\n    \"uniswap_exchange_template\": \"0x68Fc886B0ca3D65AE8Ad21Fde01d8C4E2AD9d86c\",\n    \"alice_exchange\": \"0x4A8f21726434951f5C1baA0F067d50fdA2a297e2\",\n    \"bob_exchange\": \"0x61d82A90455EC7cDEdF7cF7F5267c0aF6657c626\",\n    \"alice_erc20_token\": \"0x240Fc9370709bad1F4402186701C76e36a20848b\",\n    \"bob_erc20_token\": \"0x09cB0AE6dddF68Aaad81b8f6B83c30dfdaA65b48\",\n    \"uniswap_v2\": \"\",\n    \"multicall\": \"\",\n    \"migrator\": \"\",\n    \"router\": \"\",\n    \"ens_registry\": \"\",\n    \"unisocks\": \"\"\n}\n```\n\n---\n\n## V2 \n\nNow run the Uniswap V2 smart contract installation script.\n```\ncd ~/uniswap-interface/how_to_deploy_uniswap/uniswap_v2\n```\n\n### Important Warning\nThe `feeToSetter` has been hard-coded to the `Charlie` account inside the `deploy_uniswap_v2.js` script (that you are about to run). The `feeToSetter` is the account that is responsible for future profit that result from trades. This account is set to `Charlie` for demonstration purposes only. **If you are running this script, you are responsible for correctly setting the `feeToSetter` account up and managing its private keys.**\n\n```\nnode deploy_uniswap_v2.js\n```\nCongratulations, the smart contracts are all deployed. You will see that all of the contract addresses in the `installation_data.json` file have been filled out.\n```\n\"contract_address\": {\n\t\"uniswap_factory\": \"0x2DF5e651be537bB564005340EA5D8f6fA763b530\",\n\t\"weth\": \"0x043c7D26e381CB1bb025b4CE0A6E0C63D7767866\",\n\t\"uniswap_exchange_template\": \"0x68Fc886B0ca3D65AE8Ad21Fde01d8C4E2AD9d86c\",\n\t\"alice_exchange\": \"0x4A8f21726434951f5C1baA0F067d50fdA2a297e2\",\n\t\"bob_exchange\": \"0x61d82A90455EC7cDEdF7cF7F5267c0aF6657c626\",\n\t\"alice_erc20_token\": \"0x240Fc9370709bad1F4402186701C76e36a20848b\",\n\t\"bob_erc20_token\": \"0x09cB0AE6dddF68Aaad81b8f6B83c30dfdaA65b48\",\n\t\"uniswap_v2\": \"0x0fA47ae2b7Dee29571678580BBe9A8A88436E393\",\n\t\"multicall\": \"0x50F0463B01119Aa954ce40a7f21ecf4573E7605a\",\n\t\"migrator\": \"0x3cBe562Fd434aF61601937895000A91D014a49e7\",\n\t\"router\": \"0x5c192a0155D504772F3bc2689aF69116E098ECAa\",\n\t\"ens_registry\": \"0xA07e2676495eEDEdb5A50b9ba020Ba3A98f87D4E\"\n}\n```\n\n---\n\n## Interface\n\nNow change into the `uniswap_interface` directory.\n```\ncd ~/uniswap-interface/how_to_deploy_uniswap/uniswap_interface\n```\nNow run the `modify_addresses.py` script \n```\npython3 modify_addresses.py\n```\nChange back to the Uniswap directory so we can build the application.\n```\ncd ~/uniswap-interface/\n```\nAn `ls` should look like this (no build folder yet)\n```\nLICENSE  README.md  cypress  cypress.json  how_to_deploy_uniswap  node_modules  package.json  public  src  tsconfig.json  yarn.lock\n```\nBuild the application's dependencies using the following command.\n```\nyarn\n```\n\n---\n\n### Chain id changes (optional)\n\n**ChainID**\nPlease note: the chainId for each network is actuall set [inside the Uniswap SDK's code](https://github.com/Uniswap/uniswap-sdk/blob/v2/src/constants.ts#L7)\nYou may not need/want to change this but if you do i.e. you are using chainId `2` instead of `1` please perform the following tasks\n\nOpen the `how_to_deploy_uniswap/uniswap_interface/change_chain_id.py` file and edit the `one_to_two` and `one_to_two_II` and `new_value` and `new_value_II` variables to suite your situation i.e. changing from chainId `1` to `2` would look like this.\n```\none_to_two = \"MAINNET = 1\"\none_to_two_II = \"chainId\\:\\\"1\\\"\"\none_to_two_III = \"chainId:1\"\none_to_two_IV =\"1: 'mainnet'\"\n\nnew_value = \"MAINNET = 2\"\nnew_value_II = \"chainId\\:\\\"2\\\"\"\nnew_value_III = \"chainId:2\"\nnew_value_IV = \"2: 'mainnet'\"\n```\n\nBe sure to escape `/` and `.` and `:` (as shown above) because these will break the command when executed.\n\nNow run this file\n```\npython3.6 change_chain_id.py\n```\n\nIn addition to the above change, if your chainId is not standard i.e. your mainnet is not `1`, then you must also modify the `export declare const WETH` section of the `node_modules/@uniswap/sdk/dist/entities/token.d.ts` file. The first position in this enum `1: Token;` represents the MAINNET so go ahead and change it to suit your needs. In our case `1: Token;`\n\n```\nexport declare const WETH: {\n    1: Token;\n    3: Token;\n    4: Token;\n    5: Token;\n    42: Token;\n};\n\n```\nIn addition to the above change, again if your chainId is not standard then go ahead and also update the `src/utils/index.ts` file in the following two places i.e. `1: '',` and `ETHERSCAN_PREFIXES[1]`\n\n```\nconst ETHERSCAN_PREFIXES: { [chainId in ChainId]: string } = {\n  1: '',\n  3: 'ropsten.',\n  4: 'rinkeby.',\n  5: 'goerli.',\n  42: 'kovan.'\n}\n```\n\n```\nconst prefix = `https://${ETHERSCAN_PREFIXES[chainId] || ETHERSCAN_PREFIXES[1]}etherscan.io`\n```\n\nIn addition to the above change, another file in the Uniswap Interface source code specifies `supportedChainIds`. If your chainId is not in the list then add it like this `vi src/connectors/index.ts`\n\n```\nexport const injected = new InjectedConnector({\n  supportedChainIds: [1, 2, 3, 4, 5, 42]\n})\n```\nIn that same file, also change the `1` to your chainId in line 14 i.e.\n```\nexport const NETWORK_CHAIN_ID: number = parseInt(process.env.REACT_APP_CHAIN_ID ?? '1')\n```\n\nHopefully you did not have to change the `chainId`. If you are all set then go ahead and build the Uniswap Interface application\n\n---\n\n### Disable Unisocks (Optional)\nThis [Unisocks contract](https://etherscan.io/address/0x65770b5283117639760beA3F867b69b3697a91dd#code), this [other Uniswap contract](https://etherscan.io/address/0x23B608675a2B2fB1890d3ABBd85c5775c51691d5) and the [hard-coded Unisocks metadata](https://cloudflare-ipfs.com/ipfs/QmNZEeAN1zk6hLoHHREVkZ7PoPYaoH7n6LR6w9QAcEc29h) are deployed against real-world assets (socks) and therefore it makes no sense to include this in the build.\nIn order to disable the Unisocks component of this build we need to do the following updates to the code.\n\n#### useContract.ts\n* Comment out the `import UNISOCKS_ABI from '../constants/abis/unisocks.json'` line in the src/hooks/useContract.ts file\n\n* Comment out the `useSocksController` section of the `./src/hooks/useContract.ts` file\n```\nexport function useSocksController(): Contract | null {\n  const { chainId } = useActiveWeb3React()\n  return useContract(\n    chainId === ChainId.MAINNET ? '0x65770b5283117639760beA3F867b69b3697a91dd' : undefined,\n    UNISOCKS_ABI,\n    false\n  )\n}\n\n```\n#### useSocksBalance.ts\n* `mv src/hooks/useSocksBalance.ts src/hooks/useSocksBalance.ts.orig`\n\n#### src/components/Web3Status/index.tsx\n* Comment out `import { useHasSocks } from '../../hooks/useSocksBalance'` and `const hasSocks = useHasSocks()`  which are in the `src/components/Web3Status/index.tsx` file\n* Also comment out this block of code \n```\nconst SOCK = (\n  \u003cspan role=\"img\" aria-label=\"has socks emoji\" style={{ marginTop: -4, marginBottom: -4 }}\u003e\n    🧦\n  \u003c/span\u003e\n)\n```\nfrom the `src/components/Web3Status/index.tsx` file\n* Also delete the `{hasSocks ? SOCK : null}` line of code which is also in the `src/components/Web3Status/index.tsx` file\n\n\n### Environment variables\n\nOpen the `.env` and `.env.production` files and update the `REACT_APP_CHAIN_ID` and the `REACT_APP_NETWORK_URL` to suite your needs.\n\n### Change the hard-coded RPC\n\nOpen the `how_to_deploy_uniswap/uniswap_interface/change_rpc.py` file and edit the following variables to suite your needs.\n\n```\ninfura = \"https\\:\\/\\/mainnet\\.infura\\.io\\/v3\\/faa4639b090f46499f29d894da0551a0\"\nnew_rpc = \"http\\:\\/\\/oasis-ssvm-demo\\.secondstate\\.io\\:8545\"\n```\n\n**Be sure to escape** `/` and `.` and `:` (as shown above) **because these will break the command when executed**.\n\nNow run this script\n```\npython3.6 change_rpc.py\n```\n\n### Build\n\nModify any addresses which are lurking in dependencies etc.\n```\ncd how_to_deploy_uniswap/uniswap_interface/ \u0026\u0026 python3 modify_addresses.py\ncd ../../\n```\n```\nyarn run build\n```\nThis will generate a new `build` directory as well as some new files, as shown below.\n```\n  450.29 KB  build/static/js/4.047da443.chunk.js\n  276.48 KB  build/static/js/5.5c7ecd7f.chunk.js\n  155.14 KB  build/static/js/9.1f17fe1e.chunk.js\n  95.38 KB   build/static/js/main.38d70569.chunk.js\n  67.14 KB   build/static/js/0.1e3e94eb.chunk.js\n  66.33 KB   build/static/js/6.e890ef53.chunk.js\n  6.56 KB    build/static/js/1.5f3a35e8.chunk.js\n  1.24 KB    build/static/js/runtime-main.c8bb7174.js\n  907 B      build/static/css/4.996ad921.chunk.css\n  165 B      build/static/js/8.81f9e545.chunk.js\n  164 B      build/static/js/7.494e051e.chunk.js\n```\nYou will remember that we just ran the `modify_addresses.py` script. We are now going to run that **again** (but this time, over the build folder, which the above build command just created). This is just to make sure that there are no addresses which relate to the original Uniswap source code (but rather our newly created contract addresses).\n```\ncd how_to_deploy_uniswap/uniswap_interface/ \u0026\u0026 python3 modify_addresses.py\n```\n\nNow run the `change_rpc.py` again also.\n```\npython3.6 change_rpc.py\n```\n\n---\n\nIf you are modifying the chainId (if you did the work above), please run this again.\n\n**WARNING** only run this if you are using a different chainId **!**\n```\npython3.6 change_chain_id.py\n```\n\n---\n\nNow, we return to the Uniswap directory to copy the modified `build` files over to our Apache2 server, where they will be deployed for the end users.\n```\ncd ../../ \u0026\u0026 sudo cp -rp build/* /var/www/html/ \u0026\u0026 sudo /etc/init.d/apache2 restart\n```\n![Uniswap](./images/toggle.png)\n\n\n# More\n\nIf code changes are made in the source files (i.e. a console.log statement etc.), the following command is a one-stop-shop for a restart\n```\nyarn run build \u0026\u0026 cd how_to_deploy_uniswap/uniswap_interface/ \u0026\u0026 python3 modify_addresses.py \u0026\u0026 cd ../../ \u0026\u0026 sudo cp -rp build/* /var/www/html/ \u0026\u0026 sudo /etc/init.d/apache2 restart\n```\n\n**v1**\nFor official information, please see the [official documentation of Uniswap V1](https://uniswap.org/docs/v1/)\n\n**V2**\nFor official information, please see the [official documentation of Uniswap V2](https://uniswap.org/docs/v2/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecond-state%2Fhow_to_deploy_uniswap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsecond-state%2Fhow_to_deploy_uniswap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecond-state%2Fhow_to_deploy_uniswap/lists"}