2

The estimation wont work if the from account doesn't have the tokens, since the call would fail. You need to put the tokens you're estimateGasing for into the from address, or use a wallet that already has the tokens as the from address


2

No. It's a compile-time concern. It wasn't always required but it has been added to the compiler to make the developer's intent more clear - the compiler will throw an error if you try to override a function that is not marked virtual. If you do override the function, the only version of the function that matters is the highest-order function that overrode ...


1

No, the transaction size is bounded by the block size. Hence specifying a gas-limit larger than the block's gas-limit is useless.


1

My understanding is that currently you could do that. It would require to be patient to be able to send your transaction because the moment when you are lucky enough to mine a block is not predictable. But with enough hashpower you could try and expect your transaction do be mined. I looked at some node code and I can't see anything preventing this. It did ...


1

I guess you can use a modifier to do this. modifier refundGas { uint256 gasAtStart = gasleft(); _; uint256 gasSpent = gasAtStart - gasleft() + 28925; msg.sender.transfer(gasSpent * tx.gasprice); } function anyFunction() refundGas public { // Do something } Note: The number 28925 is an approx. of the gas used for calculations + transfer at the end. I've ...


1

You don't need ether in order to run estimateGas. The only reason for estimateGas to revert is if the function which is being estimated reverts. In other words, the function that you are trying to estimate gas for (function transfer I assume), requires some condition which doesn't hold for the input that you are passing to it when you execute the ...


1

It is because you are using string which does not has a particular size i.e., it is unbound data type. You can use bytes32 in place of string to limit the cost of gas on execution code because solidity considers it a 32 bit literal.


Only top voted, non community-wiki answers of a minimum length are eligible