CRYPTO NEWS

Price analysis 9/21: BTC, ETH, BNB, XRP, ADA, SOL, DOGE, DOT, MATIC, SHIB

Bitcoin and altcoins rallied ahead of the Fed’s rate hike decision, indicating that traders viewed the 0.75% rate hike as a “priced-in” event.

Detection of ERC20 tokens sent to Contract -?

I’m developing a game. Energy will be purchased with my own token. For example, to buy energy, you will use the "X" token you purchased earlier. It’s like buying 1 energy for 1000 "X" tokens. I searched a lot but couldn’t find an answer. I’m looking for a function just like receive() does. I want::Listen

I’m developing a game. Energy will be purchased with my own token.

For example, to buy energy, you will use the "X" token you purchased earlier. It’s like buying 1 energy for 1000 "X" tokens.

I searched a lot but couldn’t find an answer.

I’m looking for a function just like receive() does.

I want to add the amount of XXXX tokens sent to the contract and the wallet address that sent these tokens to a mapping and update the energy count.

For example, the user has sent 1000 X tokens (X is representative only). The amount of X tokens sent will be recorded with the sending wallet: Example: mapping(address => uint) xTokenInfo;

And for every 1000 X tokens, energy will be given to the wallet that sent the token.

For example: Let’s say 10,000 (10K) X tokens are sent. That means 10 energy.

SAMPLE:

address currentTokenAddress = 0xTOKEN;  mapping(address => uint) energyBalance;  function sendToken_and_ConvertEnergys(uint _tokenAmount){   if(sentToken == currentTokenAddress){     energyBalance[msg.sender] = (_tokenAmount/1000);   } else {     revert("Only X TOKENs are accepted");  } } 

Price analysis 9/21: BTC, ETH, BNB, XRP, ADA, SOL, DOGE, DOT, MATIC, SHIB

Shopping cart
There are no products in the cart!
Continue shopping
0