0

Let's assume I create a token XYZ with a total supply of 1 million unit.

I send 500 000 tokens to the token address - e.g: 0xD5A7448b2289d24432F4F2F714458efA8a996359. I add 100 000 tokens to the liquidity pool on Pancake swap to give the token a value?

Someone buys 10000 units of my token - where is that deducted from? Is there a way to check token balance on the contract address?

0

If someone buys the token, it will be deducted from Pancake: 100,000-1000

Check the balanceOf a specified token held at any address: balanceOf()

0

You shouldnt send tokens to the token contract address. Unless you have a specific function implemented to recover them, they'll be lost forever. @zmy is right, but a better way to check for the balance of a pair is to call getReserves for this pair contract. that'll give you the amount of tokenA and tokenB stored in that contract (the liquidity available) from there you can calculate the price of the token or do whatever you want.

1
  • BTW you shouldnt send tokens directly to the pair address using the transfer function from the token contract either, UniswapV2Router has an addLiquidity function that does that.
    – Foxxxey
    Jul 30 '21 at 12:20

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.