I deployed the following smart contract both to Rinkeby and to Ropsten.

    pragma solidity ^0.5.8;

    contract storeHash{

        string private vehicleData;

        function setVehicleData(string memory _vehicleData) public{
           vehicleData = _vehicleData;


A transaction with an IPFS hash (QmRAQB6YaCyidP37UdDnjFY5vQuiBrcqdyoW1CuDgwxkD4) to the contracts consumes 26,719 Gas on Rinkeby (https://rinkeby.etherscan.io/tx/0x9d25520ba42f35e23943e9226a031c9fd287d3b9acb1ea0f0b0d9fbe40064991) and 41,119 on Ropsten (https://ropsten.etherscan.io/tx/0xed4863b705986353abda658661c00e682cadb446c36af7c7217f4e51ff050eef) why is that the case?


From eyeballing this, the difference is close to 15,000.

SSTORE operations cost 20,000 gas to write a value to a zero slot. That is, nothing was there before but now there is. The overall state of the blockchain has increased.

On the other hand, it costs only 5,000 gas to overwrite a non-zero value with a new value.

A difference of 15,000 explains much of the possible variance in cost in many transactions.

In the case that the value to write is the same as the value already in storage, it's a NOOP (after Canstopinople). That's significantly cheaper, again.


Functions that do this sort of thing have worst-case and best-case cost.

Smaller differences with emerge from the use of a string with arbitrary length. The exact cost will vary with the work involved in the iterative processes that unpack the input and copy it to storage.

A suggestion would be to focus on a testing methodology to ensure the test scenario is identical in both cases. I think you will find that the differences are not correlated to the networks but rather to the execution cost of different scenarios.

Hope it helps.

|improve this answer|||||
  • Thank you for your reply! I did send the same transaction several times on both networks but the difference persisted. In gerneral there should not be any difference between the networks and the consumed Gas, right? Like there is no rule, that Ropsten charges more for certain transactions. – Felix May 3 '19 at 18:11
  • Generally, no, provided they are the same EVM version, because OP pricing is a protocol-level concern. BUT, most developers left for Rinkey and Kovan (and newer ones). Ropsten uses PoW, (financial incentives), which don't effectively repel mischief when the ether itself is worthless. Ropsten has died a few times because of that, including a disorderly/failed upgrade to Constantinople last Fall. I find myself unsure if they ever completed the upgrade or just abandoned the effort. If not, then it would be the Byzantium price list. Perhaps someone will chime in clear up that doubt. – Rob Hitchens May 3 '19 at 20:33

At the moment Ropsten and Rinkeby use two different version of the ethereum protocol, for this reason the differences are normal. You may remember that on Ropsten it was tested the last fork various months ago (and they discovered the bug), while nobody did that on Rinkeby. As a matter of fact there are persisting differences.

|improve this answer|||||

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.