1

I'm writing a smart contract that has a functionality of distributing ethers (for gas money) and tokens. The function looks like this

function distribute(address to, uint256 token, uint256 gasMoney) payable onlyAuthorized returns (bool sucess) { 
    createToken(to, token); 
    to.transfer(gasMoney); 
    currentContractBalance -= gasMoney; 
    return true; 
}

However, whenever I call the function through web3 py as

mycontract.transact().distribute(myAddress, numberOfTokens, gasMoney)

it returns an error saying

ValueError: Contract does not appear to be deployable within the current network gas limits.  Estimated: 4704624. Current gas limit: 4700036

I haven't been able to figure out the error from my side. I've made the default account the address that was used to deploy the contract.

2
1

ValueError: Contract does not appear to be deployable within the current network gas limits. Estimated: 4704624. Current gas limit: 4700036

This error means that createToken is a very heavy function. Some earlier comments suggested increasing the gas limit, but that won't help you here. The block gas limit is too low to run your transaction. That means that even if you set your gas limit to 10M and no other transactions were included in a block, your transaction still wouldn't fit. (When I say "fit" here, I mean computationally, not number of bytes)

The only options you really have are to 1) split createToken into separate parts or 2) make it more efficient. You probably want to make it more efficient because 4.7M gas is expensive! Not too long ago, a cheap gas price was 4 Gwei. At that price, issuing the transaction (if it were even possible) would cost 0.0188 ether, which is $6.20 at today's ETH/USD price.

At this moment gas is very cheap, so it would only cost you about $0.155 for each transaction, but that might not last for long.

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.