CRYPTO NEWS

What’s wrong with my buyToken function?

Here is my solidity

interface IERC20 {     function decimals() external view returns (uint8);     function totalSupply() external view returns (uint);     function balanceOf(address owner) external view returns (uint);     function allowance(address owner, address spender) external view returns (uint);      function approve(address spender, uint value) external returns (bool);     function transfer(address to, uint value) external returns (bool);     function transferFrom(address from, address to, uint value) external returns (bool); }  interface V2 {     function decimals() external view returns (uint8);     function totalSupply() external view returns (uint);     function balanceOf(address owner) external view returns (uint);     function allowance(address owner, address spender) external view returns (uint);      function approve(address spender, uint value) external returns (bool);     function transfer(address to, uint value) external returns (bool);     function transferFrom(address from, address to, uint value) external returns (bool); }  pragma solidity ^0.5.17; contract tokenSales {     //string public name = "EthSwap Instant Exchange";          // IERC20 public token;     // V2 public rgp;     address token = 0x87e9D87f85e80D79A77067A090F0748241892F74;     address rgp = 0x153Eef8365e8F4ae62aC99b6C84520f81F572827;     address owner;     uint public price;          uint256 public tokensSold;     uint256 public decimals;          event sold(address account, uint price, address token);          modifier onlyOwner() {         require(             msg.sender == owner,             "RGP Token: Caller is not the Owner"         );         _;     }      constructor(uint _price) public payable{         owner ==  msg.sender;         price = _price;           // SMC: 0xDA0bab807633f07f013f94DD0E6A4F96F8742B53     }          function() external payable{         buyTokens();         msg.value;     }      // Guards against integer overflows     function mul(uint x, uint y) public pure returns (uint z) {         require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');     }                  //uint tokens = contribution.mul(multiplier).div(TOKEN_PRICE);         //tokenAllocations[investor] = tokenAllocations[investor].add(tokens);         //tokensSold = tokensSold.add(tokens);          function setBUSDCPrice(uint _price) public onlyOwner {         price = _price;     }          function sendCollectedBUSDC (address payable _recipient)         external         onlyOwner     {         if (address(this).balance > 0) {             _recipient.transfer(address(this).balance);         }     }      function buyTokens() public payable {         //CHECK FOR INPUT BALLANCE         require(msg.value > 0, "RGP: INSUFFICIENT INPUT BALLANCE, YOU NEED TO SEND SOME BUSDT");                  //CALCULATE THE AMOUNT OF TOKEN TO PURCHASE         uint256 tokensToBuy = mul(msg.value, uint256(10) ** IERC20(token).decimals()) / mul(price, uint256(10) ** V2(rgp).decimals());                  //ALLOWANCE FOR BOTH ADDRESS(THIS) AND MSG.SENDER         V2(rgp).allowance(msg.sender, address(this));         IERC20(token).allowance(address(this), msg.sender);                  //REQUIREMENT FOR ALLOWANCE         tokensToBuy <= V2(rgp).allowance(address(this), msg.sender); // "RGP: CHECK THE TOKEN ALLOWANCE OF ADMIN";         msg.value <= IERC20(token).allowance(msg.sender, address(this)); // "RGP: CHECK THE TOKEN BALANCE OF BUYER";                  //APPROVE FOR BOTH MSG.SENDER AND ADDRESS(THIS)         V2(rgp).approve(msg.sender, tokensToBuy);         IERC20(token).approve(address(this), msg.value);                  //TRANSFER FROM MSG.SENDER TO ADDRESS(THIS)         IERC20(token).transferFrom(msg.sender, address(this), msg.value);                  //CHECK FOR BALANCE OF ADMIN         uint256 rgpBalance = V2(rgp).balanceOf(address(this));                  //REQUIRE THAT THE BALANCE APPROVED IS GREATER THAN THE TOKENS TO BUY.         require(rgpBalance >= tokensToBuy, "RGP: NOT ENOUGH TOKEN IN THE RESERVE");                  //TRANSFER FROM RGP TO MSG.SENDER         V2(rgp).transferFrom(address(this), msg.sender, tokensToBuy);                  //REDUCE THE ALLOWANCE OF BOTH PARTIES         IERC20(token).allowance(msg.sender, address(this)) + msg.value;         V2(rgp).allowance(address(this), msg.sender) + tokensToBuy;                  //INCREASE THE ALLOWANCE OF BOTH PARTIES.         IERC20(token).allowance(msg.sender, address(this)) + msg.value;         V2(rgp).allowance(address(this), msg.sender) + tokensToBuy;                 //          tokensSold += msg.value;          emit sold(msg.sender, msg.value * price, address(token));              }      function endSale() public onlyOwner{             // Send unsold tokens to the owner.         require(V2(rgp).transfer(owner, address(this).balance), "RGP: Sales ended.");         require(IERC20(token).transfer(owner, address(this).balance), "RGP: Sales ended.");              msg.sender.transfer(address(this).balance);     } } 

Deployed to ropsten "HERE"

The token address "TOKEN ADDRESS".

Please I have been on this for some days trying to figure out what wrong but I couldn’t I have checked related issues on this platform and others still the same, I actually taught it was stress so I decided to take some time out and came back still can’t figure it out.

I test on remix it deducts ether from msg.sender and did not credit to smart contract address and as well msg.sender did not receive token.

Why Rich Dad, Poor Dad Author Will Wait For Bitcoin To Drop To $1,100 Before Buying More

Best-selling author Robert Kiyosaki offered his followers a “Rich dad lesson” on Bitcoin. Via his official Twitter account, the writer made a distinction between “winners” and “losers” in the crypto market. Related Reading | Reports: FTX Targeting BlockFi Purchase At $25M At the time of writing, Bitcoin has lost major support as it broke below $20,000::Listen

Best-selling author Robert Kiyosaki offered his followers a “Rich dad lesson” on Bitcoin. Via his official Twitter account, the writer made a distinction between “winners” and “losers” in the crypto market.

Related Reading | Reports: FTX Targeting BlockFi Purchase At $25M

At the time of writing, Bitcoin has lost major support as it broke below $20,000 and it’s currently trading at $18,900 with a 6% loss in the last 24 hours. The cryptocurrency has lost over 75% of its value since reaching an all-time high at $69,000.

BTC’s price trends to the downside on the 4-hour chart. Source: BTCUSD Tradingview

At those levels, the Rich Dad Poor Dad author was a buyer and seemed more enthusiastic about BTC’s price future appreciation. Now, he has made a 180 degrees shift in his speech publicly bashing those investors which he classified as “losers”.

Kiyosaki’s full message is rather grim, and might be aiming for an impossible level, for Bitcoin to crash all the way down to $1,100:

RICH Dad lesson. “LOSERS quit when they lose.”  Bitcoin losers are quitting some committing suicide.’WINNERs learn from their losses. I am waiting for Bitcoin to “test” $1100. If it recovers I will buy more. If it does not I will wait for losers to “capitulate” quit then buy more.

In the past, Kiyosaki highlighted $20,000 as the “buy the dip” level. The author called the cryptocurrency a hedge against inflation and called the BTC’s price crashing “good news” and predicted a “time to get richer” by increasing his holdings.

The author was bullish on BTC and precious metals, but it’s unclear what has caused him to shift his views. On a different occasion, Kiyosaki foresaw the start of a depression, preceded by a “giant crash” across global markets.

The main trigger for this scenario is the U.S. Federal Reserve (Fed) and its attempts to slow down inflation, which is currently at a 40-year high. At that time, Kiyosaki said:

BIDEEN & FED need inflation to prevent New Depression. Inflation rips off the poor. Inflation makes rich richer. Biden and Fed corrupt. Prepare: Giant crash then new depression. Be smart Buy, gold, silver Bitcoin.

Should You Listen To Robert Kiyosaki?

Kiyosaki was almost right when he predicted Bitcoin would reach an all-time high near $75,000. However, as crypto users pointed out, he has been mostly wrong about his BTC’s price prediction.

As seen below, Kiyosaki has been talking about this doomsday scenario for over a decade. In 2017, he tweeted about a potential crash in the real estate market, this prediction proceeded a major bull run in the sector.

Kiyosaki’s market predictions across the past decade compared to the S&P 500. Source: Fintwit via Twitter

Related Reading | TA: Bitcoin is Plunging, But It’s Too Early to Say Bulls Have Given Up

Therefore, it seems wise to take his words with a grain of salt. The crypto market seems soft and susceptible to macro-conditions, but for BTC to return to the $1,000 levels seems unlikely.

What’s wrong with my buyToken function?

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