New answers tagged

0

Loops often increase the use of gas, moreover if you need to perform searches. In your contract, there are several of them, including a nested one in function getTabs. Try to change to data structure to avoid using them at all.


0

Shortly put: exchanges work in mysterious ways. In general, there's no telling from which account and to which account your requested transaction happens if it's between two exchanges. Exchanges have different hot wallets and whatnot. And many of transactions happen only internally and don't produce an actual transaction to the blockchain - although a ...


0

Most (if not all) testnets will return a fixed price. Since gas price doesn't affect priority of request mining, almost all transactions provide 1 Gwei. When you check gas price with web3, it sends the eth_gasPrice RPC method call to Geth/Parity, which returns the median gas price for transactions from the last 10 blocks. Remember, this is median, not mean.


0

ORIGINAL ANSWER Wallets calculate the gas limit to use by calling a node with the eth_estimateGas RPC method. This call works by performing a dry-run of the transaction based on the current state of the blockchain, and seeing how much gas is consumed. What you are asking to do amounts to "Can a gas estimation be performed that takes into consideration ...


1

I though I will comment to @lunr's answer but adding as an answer due to it's length. And if that's true, will that transaction take longer to get confirmed than say a regular transfer transaction? (given they're both sent with the same gas price) The answer is it depends. Let A be a regular transaction and B be the one that consumes gas limit. Suppose ...


2

When calling associatedToken.transfer(address(this), _ammount) the caller of this transaction is your contract, so it tries to transfer contract's 82 DAI to itself. To transfer DAI you should be the caller of the transaction with transfer() function call. You should upload DAI's code to Remix and use "At address" button and then call transfer() function at ...


1

Does a transaction that requires the entire block gas limit to be executed (currently ~8M) take the entire block by itself? Yes. And if that's true, will that transaction take longer to get confirmed than say a regular transfer transaction? (given they're both sent with the same gas price) Probably. That's because including that tx in a block will be ...


1

Well, you can obviously change this: while (count != 0) { ... count = count.sub(1); } To this: while (count != 0) { ... count -= 1; } Which will reduce a little bit of gas whenever this loop is executed. You can also change every occurrence of div into a simple /. The div function is generally "symbolic", and it is designated just for ...


0

The only function with a variable loop is calculateReward, having a loop in general not a good idea. /** * Reward is based on the amount held, relative to total supply of tokens. */ function calculateReward(uint256 _amount, address _sender) internal view returns (uint256) { uint256 reward = 0; for (uint256 i= (depositor[_sender].time.sub(startTime)...


1

the answer lie in this article: https://link.medium.com/7oxDTDmKpZ tl;dr: they are the same but the order of method_id make func1 more expensive than func2 Update: So i have try to my theory it seem like somehow it is the solidity function name problem. The reverse code: pragma solidity ^0.5.0; contract Test { uint public value; function func2(...


Top 50 recent answers are included