1

I'm trying to setup a private blockchain and deploy some contracts to it. I have the blockchain running but I am running into issues when I'm trying to deploy a contract to it.

This is my genesis block:

{
   "config": {
      "chainId": 1994,
      "homesteadBlock": 0,
      "eip150Block": 0,
      "eip155Block": 0,
      "eip158Block": 0,
      "byzantiumBlock": 0
   },
   "difficulty": "1",
   "gasLimit": "900000000",
   "alloc": {
      "0xE9cA452f53C9541eDf0461A4160D348d6953C230": { 
          "balance": "9999999999999999" 
      }
   }
}

And I'm running it with this:

./geth/build/bin/geth --datadir ./geth/data --networkid 1994 --rpc --rpcport 8543 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --rpcapi "eth,net,web3,personal,miner" --allow-insecure-unlock --unlock "0xe9ca452f53c9541edf0461a4160d348d6953c230" console 2>>eth_log.log

I am trying to deploy the following smart contract:

pragma solidity >=0.5.16;
contract helloWorld {
    function render() public pure returns (string memory) {
        return 'Hello World!';
    }
}

However truffle is giving me the following error when I do:

======================

   Deploying 'Migrations'
   ----------------------
   > transaction hash:    0xbd2e3abaf89fe79f3942270847bb981c0f3bb3c0113a758a41baf42d9dfa855f
   > Blocks: 0            Seconds: 0
   > contract address:    0x63BaB74Bf18c73c3E38D85fc3c04CCd53d2C5AE0
   > block number:        489
   > block timestamp:     1615140207
   > account:             0xE9cA452f53C9541eDf0461A4160D348d6953C230
   > balance:             1467.009999999999999999
   > gas used:            221555 (0x36173)
   > gas price:           0.000000001 gwei
   > value sent:          0 ETH
   > total cost:          0.000000000000221555 ETH


   ⠴ Saving migration to chain.
Transaction: 0x530d80bd2fff3265cdbc94d5bf6cf41d5c937e4be4b84789a4110224cf8babf2 exited with an error (status 0) after consuming all gas.
     Please check that the transaction:
     - satisfies all conditions set by Solidity `assert` statements.
     - has enough gas to execute the full transaction.
     - does not trigger an invalid opcode by other means (ex: accessing an array out of bounds).
Truffle v5.2.3 (core: 5.2.3)
Node v10.19.0

I'm obviously missing something but I can't spot it. Can someone let me know how to get this contract deployed? Thanks

EDIT: It seems to be happening during the "Saving migration to chain" of the 1_initial_migration.js file. These are my settings of my truffle config file:

development: {
      host: "127.0.0.1",     // Localhost (default: none)
      port: 8545,            // Standard Ethereum port (default: none)
      network_id: "*",       // Any network (default: none)
      from: "0x....",
    },
2
  • Try to do the same with ganache (don’t forget to lock the accounts in ganache). If this work then ur private network has something missing
    – Majd TL
    Commented Mar 7, 2021 at 18:22
  • I'm after running a test with ganache, it deployed as expected. I can't figure out what the difference in my network is.
    – Peck3277
    Commented Mar 8, 2021 at 17:31

1 Answer 1

1

I finally figured this out, it was a silly error in my genesis file. I'm answering here in case anyone has the same problem in the future.

I ran truffle using the --verbose-rpc

truffle migrate --network development --verbose-rpc

It showed me this error: "message": "invalid opcode: SHR"

After doing some googling it seems the newer solidity versions require some features enabled in Constantine and Petersburg. So I needed to add that to my genesis file.

{

   "config": {

      "chainId": 1994,

      "homesteadBlock": 0,

      "eip150Block": 0,

      "eip155Block": 0,

      "eip158Block": 0,

      "byzantiumBlock": 0,
      "constantinopleBlock": 0,
      "petersburgBlock": 0

   },

   "difficulty": "20",

   "gasLimit": "99999999",

   "alloc": {

      "0x1C9A64389D98DB6A5a57553c85fB48a98ab24FcC": { 

          "balance": "900000000000000000000000" 

      }

   }

}

Presumably this would all have been avoided if I had used something like puppeth to generate my genesis file, which is what I will be looking into now...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.