# Transaction Error execution error code 1101: \[Error Code: 1101\] cadence runtime error Execution failed:

**URL:** <https://forum.flow.com/t/transaction-error-execution-error-code-1101-error-code-1101-cadence-runtime-error-execution-failed/2133>\
**Category:** 🏄🏻‍♀️ Cadence\
**Created:** [June 28, 2021, 5:40pm UTC](https://forum.flow.com/t/transaction-error-execution-error-code-1101-error-code-1101-cadence-runtime-error-execution-failed/2133 "2021-06-28T17:40:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![buzz](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@buzz](https://forum.flow.com/u/buzz)\
**Post date:** [June 28, 2021, 5:40pm UTC](https://forum.flow.com/t/transaction-error-execution-error-code-1101-error-code-1101-cadence-runtime-error-execution-failed/2133/1 "2021-06-28T17:40:58Z")

</div>

This is the transaction code which will be used to list item in market

```
import PinataPartyContract from 0xf8d6e0586b0a20c7
import PinnieToken from 0xf8d6e0586b0a20c7
import MarketplaceContract from 0xf8d6e0586b0a20c7

transaction {

prepare(acct: AuthAccount) {
    let receiver = acct.getCapability<&{PinnieToken.Receiver}>(/public/MainReceiver)
    let sale <- MarketplaceContract.createSaleCollection(ownerVault: receiver)

    let collectionRef = acct.borrow<&PinataPartyContract.Collection>(from: /storage/NFTCollection)
        ?? panic("Could not borrow owner's nft collection reference")

    let token <- collectionRef.withdraw(withdrawID: 1)

    sale.listForSale(token: <-token, price: 10.0)

    acct.save(<-sale, to: /storage/NFTSale)

    acct.link<&MarketplaceContract.SaleCollection{MarketplaceContract.SalePublic}>(/public/NFTSale, target: /storage/NFTSale)

    log("Sale Created for account 1. Selling NFT 1 for 10 tokens")
}

```

}

This is where the error is coming from line 27

```
pub contract PinataPartyContract {
    pub resource NFT {
        pub let id: UInt64
        init(initID: UInt64) {
        self.id = initID
        }
    }

pub resource interface NFTReceiver {
    pub fun deposit(token: @NFT, metadata: {String : String})
    pub fun getIDs(): [UInt64]
    pub fun idExists(id: UInt64): Bool
    pub fun getMetadata(id: UInt64) : {String : String}
}

pub resource Collection: NFTReceiver {
    pub var ownedNFTs: @{UInt64: NFT}
    pub var metadataObjs: {UInt64: { String : String }}

    init () {
        self.ownedNFTs <- {}
        self.metadataObjs = {}
    }

    pub fun withdraw(withdrawID: UInt64): @NFT {
        let token <- self.ownedNFTs.remove(key: withdrawID)!
        console.log(token);
        return <-token
    }

    pub fun deposit(token: @NFT, metadata: {String : String}) {
        self.metadataObjs[token.id] = metadata
        self.ownedNFTs[token.id] <-! token
    }

    pub fun idExists(id: UInt64): Bool {
        return self.ownedNFTs[id] != nil
    }

    pub fun getIDs(): [UInt64] {
        return self.ownedNFTs.keys
    }

    pub fun updateMetadata(id: UInt64, metadata: {String: String}) {
        self.metadataObjs[id] = metadata
    }

    pub fun getMetadata(id: UInt64): {String : String} {
        return self.metadataObjs[id]!
    }

    destroy() {
        destroy self.ownedNFTs
    }
}

pub fun createEmptyCollection(): @Collection {
    return <- create Collection()
}

pub resource NFTMinter {
    pub var idCount: UInt64

    init() {
        self.idCount = 1
    }

    pub fun mintNFT(): @NFT {
        var newNFT <- create NFT(initID: self.idCount)

        self.idCount = self.idCount + 1 as UInt64

        return <-newNFT
    }
}

init() {
    self.account.save(<-self.createEmptyCollection(), to: /storage/NFTCollection)
    self.account.link<&{NFTReceiver}>(/public/NFTReceiver, target: /storage/NFTCollection)
    self.account.save(<-create NFTMinter(), to: /storage/NFTMinter)
}

```

}

The error says:  
Transaction Error  
execution error code 1101: [Error Code: 1101] cadence runtime error Execution failed:  
error: unexpectedly found nil while forcing an Optional value  
 → f8d6e0586b0a20c7.PinataPartyContract:27:63  
|  
27 | let token ← self.ownedNFTs.remove(key: withdrawID)!

---

<div class="post-metadata">

**Author:** ![flowjosh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/flowjosh/32/362_2.png) [@flowjosh](https://forum.flow.com/u/flowjosh)\
**Post date:** [June 29, 2021, 8:14pm UTC](https://forum.flow.com/t/transaction-error-execution-error-code-1101-error-code-1101-cadence-runtime-error-execution-failed/2133/2 "2021-06-29T20:14:32Z")

</div>

It looks like the token that you are trying to withdraw does not exist in the collection. You should make sure it exists before trying to withdraw it. 👍

---

<div class="post-metadata">

**Author:** ![David28](https://avatars.discourse-cdn.com/v4/letter/d/7cd45c/32.png) [@David28](https://forum.flow.com/u/David28)\
**Post date:** [December 10, 2021, 9:36am UTC](https://forum.flow.com/t/transaction-error-execution-error-code-1101-error-code-1101-cadence-runtime-error-execution-failed/2133/3 "2021-12-10T09:36:46Z")

</div>

Hello I am having the same problem as you with the same code, could you solve it?
