Search code examples
javascriptblockchainethereumevm

Ethereumjs-vm, run-transaction-complete example not printing storage


Running the example mentioned in the title, there is no output after the "---Storage---" line. According to my understanding, there should be a null_radix stored at the created address. (running gives no exceptions) please correct me if I’m wrong!


Solution

  • [update]

    At the following part of the example at the runTx function I've noticed that we refresh the createdAddress variable at every transaction even though it doesn't register a new contract. Therefore it leaves us with the loss of our contract's address and the readStorage function won't print any output.

    I've fixed it by checking the createdAddress property for null before saving the value.

    if (returns.createdAddress) {
      createdAddress = results.createdAddress
      console.log('address created: ' + createdAddress.toString('hex'))
    }