eos icon indicating copy to clipboard operation
eos copied to clipboard

How to remove(delete / replace) a contract ?

Open swdevMPaul opened this issue 8 years ago • 6 comments

Hi,

Does anyone know which command to execute in order to delete previously published(uploaded) contract ?

Kind Regards,

Paul.

swdevMPaul avatar Feb 14 '18 14:02 swdevMPaul

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?

sim31 avatar Jun 21 '18 13:06 sim31

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.

andriantolie avatar Jun 29 '18 08:06 andriantolie

With eosjs, the following code should do the trick:

eos.setcode(account_name, 0, 0, new Uint8Array());

xJonathanLEI avatar Aug 04 '18 23:08 xJonathanLEI

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 avatar Aug 04 '18 23:08 xJonathanLEI

@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?

jjgonecrypto avatar Nov 29 '18 19:11 jjgonecrypto

Update: according to @michaeljyeates on Telegram, you should first empty any tables out before setting the wasm code to an empty array.

jjgonecrypto avatar Nov 29 '18 19:11 jjgonecrypto