GAS Consumption Issue


In order to operate a Contract on Ethereum, you need to deploy the Contract, but a large amount of GAS is required for deployment.

Suppose, for example, that in order to assign an ID per IoT device, we prepare the following simple contract.

  • Class diagram


  • Code

    contract SomeThing {
        bytes32 private id;
        string private name;
        function SomeThing(bytes32 _id, string _name) {
            id = _id;
            name = _name;
        function getId() constant returns(bytes32) {
            return id;
        function getName() constant returns(string) {
            return name;

It is a simple contract with a getter/setter only, but if we try to create this instance with Browser-Solidity.

Used GAS

The transaction cost here is 219,000 GAS. (State without Enable Optimization)

The price of GASPrice and Ether will fluctuate, but if 1 GAS is assumed to be 0.00000002 Ether and 1 Ether is set to $10.

0.00000002Ether x 219,000GAS x $10 = $0.0438

It costs about 0.04 cents or so.

This is clear if you look at the "data" section of "Web 3 deploy" and it is necessary to include all the data compiled for all sources in the transaction for the contract deployment.

  • Web3 deploy

    var somethingContract = web3.eth.contract([{"constant":true,...}]);
    var something =
      from: web3.eth.accounts[0],
      gas: '4700000'
    }, function (e, contract){
      console.log(e, contract);
      if (typeof contract.address !== 'undefined') {
          console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);

Also, another problem arises with this.

If you deploy a large number of contracts over time this way, it is difficult to guarantee that all contracts contain identical logic.

Solution - GAS Consumption Issue

results matching ""

    No results matching ""