in

Created a token sale contract and gas usage is different from my Rinkeby test

Basically the title. Created a token for fun and education but the gas limits I put in place dont work on the main net. I was under the impression the state should be same which would lead to the same gas units being used. Heres the method(s)


//Taken from DS-Math. [https://github.com/dapphub/ds-math/blob/master/src/math.sol]
function multiply(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x);
}

function buyTokens(uint256 _numberOfTokens) public payable {
require(msg.value == multiply(_numberOfTokens, tokenPrice));
require(tokenContract.balanceOf(address(this)) >= _numberOfTokens);
require(tokenContract.transfer(msg.sender, _numberOfTokens));

tokensSold += _numberOfTokens;

emit Sell(msg.sender, _numberOfTokens);
}

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *

GIPHY App Key not set. Please check settings

Daily General Discussion – April 16, 2021

The Uranium Thesis: Have your cake (but don’t eat it)