Closed swdevMPaul closed 6 years ago
To replace code you can just use the same cleos command you used to upload code. To delete code - upload wast and abi files which does nothing? To free RAM your contract uses, the only way I'm aware of is to do it from contract itself (add an action in your contract which deletes all the rows in all of the tables). Maybe someone else can suggest a better way of doing these things?
Yes, to replace just use the same command you use to upload the contract. I don't think there's a way to delete the uploaded contract but you can always replace it with a contract that does nothing.
With eosjs
, the following code should do the trick:
eos.setcode(account_name, 0, 0, new Uint8Array());
Setting the code to an empty byte array also changes code hash to 0. It's a much better solution than replacing it with a contract that does nothing, as such a contract still takes up RAM space and thus EOS.
@xJonathanLEI What would happen to any tables that were already in use for that contract? Would they be orphaned yet still cost RAM? Should you first empty the tables out?
Update: according to @michaeljyeates on Telegram, you should first empty any tables out before setting the wasm code to an empty array.
Hi,
Does anyone know which command to execute in order to delete previously published(uploaded) contract ?
Kind Regards,
Paul.