carboncredits / x4c

MIT License
2 stars 0 forks source link

Specify what "amount" means when retiring #47

Closed patricoferris closed 1 year ago

patricoferris commented 2 years ago

Currently whenever we retire offsets, we specify an amount to retire. This is some natural number. At the moment it would seem most of us were under the assumption this represented one tonne, but this would mean we couldn't offset smaller amounts (e.g. LHR-BFS is 113.86kg (0.11368 tonnes)).

The suggestion is that the amount should actually reference grams rather than tonnes. From the michelson docs:

Integers and naturals are arbitrary-precision, meaning that the only size limit is gas.

I'm not knowledgable enough to comment on the implications of our amounts all shifting to the left by 6 digits, but hopefully that's not an issue. If we go for this we should:

  1. Document it very clearly
  2. Make it very clear in the APIs e.g. a key amount should maybe become amount_grams

The last thing we want to do is under-retire because of a programming error!

mdales commented 2 years ago

The amount is just the number of tokens. The token unit is arbitrary, and we get to make that.

I don't think we want to rename the amount field, as it's been clear that the FA2 contract has to be a standard FA2 contract so that it interoperates with other FA2 compatible views, and there the standard parameter is "amount" as per TZIP-12.

We could rename it in retire, but then it looks odd against the other fields in the contract.

The custodian contract we could make grams, and I have no strong opinion on that (work wise it's just a find and replace), but I'd dislike that the custodian retire method has a different signature from the FA2 contract personally, but I don't really mind.

patricoferris commented 1 year ago

This, as pointed out, is more of a client deciding what it means rather than doing anything specifically in the backend/contracts.