How to remove Smart Contract in NEAR Protocol?

578 views Asked by At

I am new to blockchain and Near Protocol. I have created 2 smart contracts on Near Protocol. The first one was successfully done but when I try to deploy the second one, I have deployed it but when I try to call a method ('increment' in this case) it gives error. I looked for the error and they say that this error executed because I tried to deploy another smart contract. So how can I remove the first one? Or can I? Or should I? Thanks. The error is below:

ServerTransactionError: {"index":0,"kind":{"ExecutionError":"Smart contract panicked: panicked at 'Cannot deserialize the contract state.: Custom { kind: InvalidData, error: \"Not all bytes read\" }
3

There are 3 answers

0
JacksWastedLife On BEST ANSWER

This depends. Are you running on testnet or mainnet and do you need to transfer any assets. You can only deploy 1 smart contract per wallet and it seems that you need to delete the wallet to remove the contract afaik

You can use near delete accountName.networkName

0
Peter Volnov On

You can deploy an empty contract

pip install py-near

from pynear.account import Account

async def f():
    acc = Account(
        "accoun_id",
        "private_key"
    )
    await acc.startup()
    res = await acc.deploy_contract(b"")

asyncio.run(f())
0
ecorrales On

I came across the same issue. Sounds like you were following Near's "Counter" tutorial. It appears that in your first deployment, the counter data size (ex: u64) was bigger than the size (ex: u8) in your second deployment.

Had you started with u8, and then changed to u64, you would still get an error, but a different one.

Or, you may have even added a new field to your Contract struct. (That one I haven't tried yet).

So, yes, you need another account.