citycoins / ui

Basic UI components for interacting with the CityCoin contract. Requires Stacks Wallet for Web.
https://minecitycoins.com
GNU General Public License v3.0
28 stars 13 forks source link

🐞[BUG] Claiming MIA keeps getting rolled back by post-condition #167

Open eric-hendrickson opened 1 year ago

eric-hendrickson commented 1 year ago

Describe the bug Every time I try to claim my MIA, the transaction goes through, but the transaction says "Notice This transaction would have succeeded, but was rolled back by a supplied post-condition."

To Reproduce Steps to reproduce the behavior:

  1. Go to https://minecitycoins.com/stacking?chain=mainnet
  2. Select city "MIA"
  3. Click on button "Claim"
  4. Approve transaction

Expected behavior Transaction should succeed and I should receive my 199,870.000000.

Desktop (please complete the following information):

Additional context I have tried doing this several times, with several fee rates. This is an example with the largest fee rate: https://explorer.hiro.so/txid/0x456578e655754526cea5beb4b2c875e6c511bb6f1e01bdf3da7219f6177328c7?chain=mainnet.

The transaction in question is from cycle 62 for DaoV1. I also have a similar issue with claiming my NYC coin.

whoabuddy commented 10 months ago

This is interesting - you have a post condition set on the provided transaction as seen here:

image

The result would've been successful with (ok true) so we know that's the correct post-condition as well.

However the cityName variable doesn't appear to be set (at least from this view on the Explorer)

image

eric-hendrickson commented 7 months ago

Bump. This issue is still current, as can be seen with this new transaction I made today. Is anyone going to take this up? I would REALLY like to get my MIA and NYC back.

eric-hendrickson commented 7 months ago

@whoabuddy In order to compare with the screenshots from the previous transaction:

Screenshot 2024-03-12 at 1 12 02 AM

And the cityName variable appears to be properly populated:

Screenshot 2024-03-12 at 1 10 36 AM

Is there something I'm missing? Can this be fixed, or is this something that I would need to use the scripts for?

eric-hendrickson commented 7 months ago

If it helps, this is the transaction that stacked that MIA: https://explorer.hiro.so/txid/0xdfd6e609d69193a954c253c2faea3497e5dbd42c6d2730497e2cb71cb611608e

whoabuddy commented 7 months ago

Thanks for the additional information! Looking at what you provided cycle 62 should return both MIA and STX, but the STX value is not included in the post condition. If a contract tries to transfer any assets that aren't specified in the post conditions it will fail as a safety precaution.

This is likely due to some loading errors we're seeing with minecitycoins.com, a newer version is in the works but until then you can try https://jing.cash created by another community member.

To show the analysis in more detail and explain how one can get to that conclusion with on-chain data, see below.

The original stacking transaction outputs the following data:

{
  amountStacked: u199870000000,
  cityId: u1,
  cityName: "mia",
  cityTreasury: 'SP8A9HZ3PKST0S42VM9523Z9NV42SZ026V4K39WH.ccd002-treasury-mia-stacking,
  event: "stacking",
  firstCycle: u58,
  lastCycle: u62,
  lockPeriod: u5,
  userId: u418
}

Here we see the cityId, firstCycle, lastCycle, and userId which are used to query the contract to get different information.

Now let's look at the failed tx for cycle 62:

Since there is no STX mentioned in the post-conditions let's take a look at what this address should receive from the contract by claiming cycle 62. There are two functions to do that which can be accessed from the Explorer sandbox.

get-stacker with:

This returns the value (tuple (claimable u199870000000) (stacked u199870000000)) which means:

get-stacking-reward with:

This returns the value (some u1855650) which equals 1.855650 STX.

So for the transaction to succeed it needs to have the post condition for both the MIA and the STX, or the function can be called in allow mode which bypasses the post conditions from jing.cash.