1

Given a simple address to address mapping as follows:

mapping (address => address) public matches;

Can someone give me an idea of the cost in ether to store something like this in a solidity contract? I understand that there are gas costs associated with every alteration of the blockchain and storage is expensive but I am having trouble finding estimations of what simple storage like a mapping would cost.

The feasibility of my Dapp idea depends on storing mappings from address to address cheaply. Ideally around 1 cent USD or so. If mappings are more expensive are there any workarounds? Thanks.

2

In the simplest implementation I can think of:

pragma solidity ^0.4.6;

contract Mapping {
    mapping(address => address) public matches;

    function writeMapping(address addr) {
        matches[addr] = msg.sender;
    }
}
  1. First write 42K gas
  2. Overwrite 27K gas

enter image description here

Gas price in Eth and ETH price in $ both float on markets, so any estimate would be a forecast.

The gas cost operations are knowable and should be consistent (in the example) but are subject to periodic change at the protocol level. That is, if the cost/OP table is adjusted in the future.

Hope it helps.

  • Thanks Rob. Any idea where I can find what 42K gas equates to at this moment or perhaps before the price rise? – Cameron Taylor Apr 6 '17 at 10:55
  • It's a two-step. I see a gas price of 18gwei right here: ethstats.net. Convert to 0.000000018ETH ... so 42K times that. Then off to exchange etc., to convert ETH to USD, etc. Good indication of current cost. Usual disclaimer: Past results are not indicative of future performance ... – Rob Hitchens - B9lab Apr 6 '17 at 11:21

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.