2

I’m new to blockchain development and have been interested in the Uniswap/sushiswap/pancakeswap/etc. projects for some time.

I’m trying to build my own project as a learning exercise. I’ve deployed the contracts to ropsten and can see that my token has zero supply in my frontend.

My question is, how do I interact with the contracts to mint tokens, create liquidity pools, etc? Do I write a js file that utilizes web3 to call those functions such as mint() and createPair()?

3

A DEX essentially allows you to swap tokens and create liquidity pools, which means that you don't create (mint) new tokens in general. Only if the DEX has the possibility of staking, then you may create LP tokens (Liquidity Pool tokens) and send them to the stakers in exchange of their standard tokens.

If the contract is verified in etherscan.io, you can call their functions directly without the need of any development. You just need to know the contract address, which functions to call and what values are expected.

On the other hand, you can use libraries such as web3.js or ethers.js to interact with the contract through a frontend or backend.

In Uniswap, most of the functions are available through the Router02 contract. For instance, if you had to create a liquidity pool, then you should call this function (it will create a new pair if it doesn't exist):

function addLiquidity(
  address tokenA,
  address tokenB,
  uint amountADesired,
  uint amountBDesired,
  uint amountAMin,
  uint amountBMin,
  address to,
  uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);

Nevertheless, if you are new in blockchain, it's a bit challenging to start with a DEX. Perhaps you can practise a little bit with simple ERC20 contracts, transfer tokens, iterate through arrays, access mappings, develop code in web3.js to read & write values from contracts, etc and then it will be easier to follow the core functions of DEXes.

1
  • Sergi thank you for your response! Really super helpful and helped get me on the right track. Thanks again 🙏 – architect Mar 19 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.