3

I published a contract to my localnet using:

cleos set contract myaccount mycontractfolder -p myaccount

Then I made some updates to the code, and want to publish them, I type the same command again, but this time, I get the error message:

Error 3160008: Contract is already running this version of code
Error Details:
contract is already running this version of code
pending console output:

How can I publish the contract updates without restarting nodeos?

4
  • 1
    did you recompile? your command looks correct but you need to recompile after modifications
    – confused00
    Commented Jul 24, 2018 at 8:05
  • Yes I recompiled. Commented Jul 24, 2018 at 8:27
  • 1
    could it be that the change didn't update the wasm as it got optimised out? maybe you could try introducing a new function or a print function
    – confused00
    Commented Jul 24, 2018 at 8:34
  • 1
    You are right! The wasm code was not updated because the change was optimized out. If you write an answer I'll accept it. Commented Jul 24, 2018 at 11:14

3 Answers 3

4

Certain small code changes get optimised out by the WASM compiler, resulting in an identical .wasm file, so nodeos may reject the update.

Try making a more significant code update such as introducing a new function or calling eosio::print(), and you can see if it works.

0

You should write or edit new code in it, and recompile it.

try below:

eosiocpp -g path/to/mycontractfolder.abi path/to/mycontractfolder.cpp
eosiocpp -o path/to/mycontractfolder.wast path/to/mycontractfolder.cpp

If you're using docker, you should send your contract to container via docker cp.

2
  • You wrote this answer after the comments on the question explained already that he did recompile the code. Read the comments on a question as well before writing an answer, to make sure you get all the details. Commented Jul 24, 2018 at 14:58
  • @AndresBerrios Thanks. I'll check the comments next time.
    – CHANN
    Commented Jul 25, 2018 at 0:11
0

@confused00 is right in that you need to make significant changes because of wasm optimazation. I want to add that don't forget to update the EOSIO_ABI macro at the bottom of the contract. Too many times I have forgotten this and wondered why it wasn't updating.

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.