Description
I noticed two issues on https://stxnft.com (using the Stacks API) which I think can both be traced back to transactions in the same block.
The symptoms are:
- Discrepancies in NFT balances between the Stacks and PlanBetter explorers
- Discrepancies between the result of contract calls and balances according to the Stacks API
I'll go over the cases here:
Case 1
I noticed that on our marketplace balance, I can see ThisIsNumberOne 129 as belonging to the marketplace, but with no corresponding listing in the contract map. This is (to my knowledge) not possible with the contract is coded. I suspected a bug in the contract, but we can take a look at the transactions a bit further.
Listing transaction, block #32719: https://explorer.stacks.co/txid/0xb5c7d7b01c55e917cc4a583b899553da475936a4ab398712a3bc18a23e880885?chain=mainnet
You can see my-nft::129
was transferred from the owner to the marketplace contract. Everything is fine there.
Purchase transaction, block #32859 according to Stacks Explorer and block #32861 according to PlanBetter (!), https://explorer.stacks.co/txid/0xf04705c8695afc39775a17823dd8491ab9f25544fe037d844be95ae20a9e461a?chain=mainnet
https://explorer.planbetter.org/txid/0xf04705c8695afc39775a17823dd8491ab9f25544fe037d844be95ae20a9e461a?chain=mainnet
Even though this says it is a non-canonical fork, the contract seems to be updated as if the transaction went through successfully. The balances, however, do not reflect the state of the world as if the transaction went through successfully
On PlanBetter you can see that the purchaser does own the NFT they purchased (my-nft
) (https://explorer.planbetter.org/address/SP2K3MDQE5YB2PK3BAVJ7C3YM2M48ZFG604EJ57ND) but on Stacks Explorer they don't (https://explorer.stacks.co/address/SP2K3MDQE5YB2PK3BAVJ7C3YM2M48ZFG604EJ57ND).
Either way is fine — whether the transaction went through or not is ok with me, but the weird thing is that the contract acts as if the transaction went through (deleting the entry in the map) while the balances do not (the marketplace still owns the NFT while the contract treats it as sold)
Case 2
I received a message from the owner of FreePunk 9314 saying they tried to list the NFT on our marketplace but couldn't find the asset.
Looking at the account from which the FreePunk supposedly came from, I couldn't find a transaction listing that specific FreePunk on the marketplace: https://explorer.stacks.co/address/SP3RMX8BVN638M2T3E2QNAWXAJ2J19TSG5Q7P5ECW?chain=mainnet
However, again, this is where it gets weird. The contract shows that the FreePunk has been listed on the marketplace, though the marketplace balance doesn't reflect that!
Also, get-owner
on the FreePunk returns the marketplace address, whereas the Stacks Explorer shows it as still belonging to the original owner: https://freestxpunks.surge.sh/details/9314
Again, the transaction shows up in the PlanBetter website but not the Stacks Explorer, in block #32861 (the same problematic block as the previous purchase transaction):
https://explorer.planbetter.org/txid/0x139264ec7b6e12fed3349aec88d0cf141428c4edcb4b76ce4bfa0b3f4966dde3?chain=mainnet
Again, the weird thing here is that the contract call acts as if the transaction went through successfully, but the balance does not!
Notes
Here's a link to the offending block on the Stacks explorer. You can see some of the transactions show up as "not found" or show as belonging to an orphaned chain: https://explorer.stacks.co/block/0x2f07bddfb857c4378dd39bf0c11c408c8af41d9e7b6f27f322a0171e8e8cb39e?chain=mainnet