How to destory a KittyItemsMarket.Collection?

Iā€™m playing with Kitty-items demo and made some modifications.

When I try to destroy and re-create a KittyItemsMarket.Collection resource and it does not work.
Here is the problem code:

https://flow-view-source.com/testnet/tx/ea6cd1cb24c17008f300d1210f1706b25694ce39427adbb68c159ca089e9b621

My code to destroy the collection:

if let oldToken ā† acct.load<@KittyItemsMarket.Collection>(from: KittyItemsMarket.CollectionStoragePath) {
destroy oldToken
}

What should I do?

1 Like

The code looks good, what is the problem?

error: failed to save object: path /storage/kittyItemsMarketCollection002 in account 0x251636ac5575c613 already stores an object
ā†’ 6246af60526d4be3be82a76e5efc90279adc0235f394eaaa8c04c55fd3f21d91:88:10
|
88 | acct.save(<-KittyItemsMarket.createEmptyCollection(), to: KittyItemsMarket.CollectionStoragePath)

I got this error. since I have destroy the old one, the new created collection should be saved, right?

I see. Are you using the emulator?

Iā€™m using Testnet.

Hi @newbdez33 , I am also facing the same issue. I once removed my contract and tried to redeploy it but it throws an error

error: failed to save object: path /storage/PinataPartyContract in account 0xXXXXXX already stores an object.

Can anyone help me on this one. Thanks in advance.

1 Like