Skip to main content
This guide will introduce how to set up development tools on MacOS and develop Dapps on AxiomLedger. Here, we’ll use the well-known decentralized exchange Uniswap@V2 as an example. Please familiarize yourself with the basic concepts of Uniswap before using the following tutorial for project deployment and experience! The following steps will take the Aries testnet as an example. If you want to try it on the mainnet or other testnets, you can view related resources on the Resources page.

Development Environment Configuration

First, you need to install some necessary development tools, including Git, NodeJs, etc.

Install Homebrew

Homebrew is a package manager for MacOS that can help us easily install and manage software. Install Homebrew:

Install Git

Install Git by Homebrew:

Install NVM

Install NVM by curl or wget. Here we provide the curl command:
After installing NVM, close and reopen the Terminal, or run the following command to enable NVM:

Install Node.js

Install Node.js v20 and Node.js v16 using NVM. Later, you may need to use different Node versions to deploy different Uniswap components.

Retrieve Uniswap@V2 Source Code

Since Uniswap v2 requires multiple components, you need to retrieve them in sequence from the official repository to form the following package structure:
We’ve already organized the complete project code for you, which can be obtained from the test repository. The command is:

Deploy Uniswap@V2 Contract

Init Hardhat

Initialize the Hardhat project under the uniswap-contract package and clone the relevant contract files from the official repository according to the package format mentioned above. If you are using our test repo, please route to the right package and run below code:
At this point, you need to modify the networks field in the Hardhat configuration file to fit your network. The account private key is used for deploying contracts on the chain. It can be safely used by setting it as an environment variable. Use the command export YOUR_PRIVATE_KEY = 'YOUR_PRIVATE_KEY' to write it to the environment variable. Use the Aries testnet as an example, the Hardhat config is as follows:

Write Contract Deployment Scripts

Write the contract deployment script in the scripts package. Here is the deployment script for the core contract of Uniswap@V2 that we have prepared for you. You can find the corresponding file named deployUniswapV2.js in the test repository.
Write the token deployment script in the scripts package. Here is the token contract deployment script that we have prepared for you. You can find the corresponding file named deployUniswapTokens.js in the test repository.

Deploy Contracts & Record Contract Address

Run the following command to deploy the contracts to the corresponding network. Here, we’ll deploy the contracts to the Aries testnet as an example.
Please note: The first account configured in the hardhat network will be used as the deployment account. You need to ensure that this account has sufficient tokens. For information on how to obtain tokens from the faucet for testing, please refer to the Resources.
After running the relevant deployment scripts, we can obtain the relevant Uniswap@V2 contract addresses。After running the relevant ERC20 token deployment script, we can obtain the associated Token contract addresses: After running the contract deployment script and the ERC20 token deployment script, you will obtain the Uniswap@V2 contract address as well as the Token contract address. These addresses will be used in the next steps.

Usage

After deploying the aforementioned contracts, you can obtain the contract deployment addresses. These addresses are used to modify hardcoded values in subsequent frontend project, ensuring the smooth deployment of the frontend project.
The INIT_CODE_PAIR_HASH in the aforementioned contract is actually the hash value of the creationCode of the UniswapV2Pair contract. You need to manually modify the following code block. But if you are using our test repository, this part of the modification has already been completed.

Deploy Interface

Now, let’s modify the relevant configurations of the frontend project to locally deploy the Uniswap@V2 frontend poroject Interface-2.6.5.

Modify Uniswap-SDK

Retrieve the source code basing on the SDK version that the frontend depends on. You need to make some modifications. If you are using our test repository, the related source code has already been integrated in the test repository.
Enter the uniswap-sdk directory, use nvm to switch the Node.js version to 16.13.2. Then execute the following command:

Modify Network

Since currently Uniswap only supports the Ethereum mainnet and its testnets you need to modify the ChainId[TESTNET] in src/constants.ts to your desired chain ID. Here, we’ll take the AxiomLedger testnet Aries as an example, and you can change the chain ID to 23411.

Modify Contract Address

Make necessary changes to src/constant.ts based on the factory contract deployed earlier:

Modify WETH Address

Now, modify the contract address corresponding to src/entities/token.ts. Deploy the WETH contract on the testnet. Earlier, you’ve already deployed the WETH Token contract on the chain, enter the address into the WETH_ADDR in the following code:

Build SDK

Invoke the command under the SDK package in package.json to build SDK, or enter the following command in the corresponding package’s command line:
At this point, a new artifact has produced. You can used it wherever the SDK is needed.

Default-token-list Modification

Retrieve the source code based on the default-token-list version that the frontend depends on, which requires some modifications. If you are using our test repository, the related source code has already been integrated in the test repository. This library will help you generate the relevant token-lists. Find the corresponding package and manually modify it according to the following format. Since WETH is the required contract for Uniswap@V2, you need to modify the address and chainId to your configuration after deployment. Using src/tokens/testnet.json as an example, please fill in the corresponding fields with the WETH_ADDR, AXMTOKEN1_ADDR, etc., produced after deploying the token contract as mentioned above. The logoURI of the test token can be customized. Take Aries testnet as an example, you can modify the chainId to 23411. For other tokens, please read the token list description and fill in accordingly.
Execute the following command in the current package to construct uniswap-default.tokenlist.json, which can be configured and used in the frontend. For instance, see the file in the test repository: uniswap-v2/interface-2.6.5/src/constants/lists.ts.
This token list can be used in the Uniswap@V2 frontend project, allowing the frontend to quickly link to the relevant tokens already deployed on the chain. This is convenient for users to view the balances of various tokens, facilitating the swift establishment of liquidity pools.

Modify Interface

Next is the deployment and construction of the Uniswap@V2 frontend repository. Retrieve source code from Uniswap’s official repository and switch to tag 2.6.5. Of course, our test project has already deployed the related source code for you.

Modify Contract Address

First, modify the ROUTER_ADDRESS contract address in src/constants/index.ts:
Then modify the multi-signature contract address MULTICALL_ADDR in src/constants/multicall/index.ts:

Modify Dependencies and Configurations

Modify the dependency package:
Adjust the environment configuration. Taking AxiomLedger Aries testnet as an example, modify the corresponding entries in the .env and .env.productionfiles to the following values:

Build and Launch

After making the necessary modifications, execute the following commands to start the Interface frontend locally: (using Node@16)
Now you can experience Uniswap@V2 built on AxiomLedger Aries testnet.

Miscellaneous - Build by Remix

Using Remix to build Dapps on AxiomLedger is a more convenient choice, for instance, deploying the Uniswap@v2. Import the factory contract and the routing contract into Remix, and select the appropriate Solidity version in the compiler. During the deployment phase, selecting ENVIRONMENT as Injected Provider - MetaMask allows for easy connection and deployment to AxiomLedger via MetaMask. Finally, we can select the desired method from the contract method list in Remix to invoke.