So I'm learning Solidity in creating a new token. I successfully created a token and implemented custom tax and burn functionalities. Now I'm trying to understand the Uniswap liquidity features. The thing I don't understand is the address(this) function. In many example code's I see liquidity being added FROM this address and the pair tokens are stored there aswell.

However, how do I access this address through metamask? How are the tokens stored there? Does a simple contract where totalSupply is transferd to owner() or (msg.sender) also have tokens in address(this)? Address(this) totally confuses my mind.

So this piece of code:

uniswapV2Router.addLiquidityETH{value: ethAmount}(
        address(this), //What is this address, shouldn't this be the owner address?
        tokenAmount, //Custom token amount
        0, // slippage is unavoidable
        0, // slippage is unavoidable
        address(this), //Liquidity tokens are stored here and are inaccesible?

So in this code example above. The first parameter and the second last parameter is address(token). The first parameter should be according to the docs "The contract address of the desired token." Which is my own token of course. Now the second param is the amount of this token. How does address(this) contain tokens to add to the liq pool? The second last param is according the docs "Recipient of the liquidity tokens.", are they inaccessible?




is the address of the deployed smart contract itself.

In Uniswap context, guessing without you quoting any source code, it is the address of the pair contract.


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.