CHIP 2022-02 CashTokens: Token Primitives for Bitcoin Cash

No, I’m not agreeing with him; he described that the ban on implicit destruction is a conservative choice, because it preserves the possibility of paying miners in tokens (instead of BCH) in the future. I’m arguing that this possibility threatens the long term health of BCH, and we’re much better off sealing it permanently (by allowing implicit destruction), hence the strong NACK.

thanks for replying to my ps. I still stand by what I wrote.

Would you be able to answer my question?

Edit; how do you come to the conclusion that this “threatens the long term health of BCH”, please.
Again, I probably agree. It feels you have a point. But if you have arguments spelled out that would be awesome to read.

The concept of abstraction, aka success of the network while the coin fades into obscurity, is very real. Paying fees in BCH is an anchor of value that preserves a utility even if all else fails; threatening that prospect is hence threatening the long term health of BCH the coin, which I’m primarily aligned with. I’ll strongly and unambiguously fight against anyone who proposes a BCH replacement as fee payment above all else.

I’ll recommend searching for “abstraction” in cryptocurrency context to read more on this.

right, that makes sense. BCH is the tree-trunk and we can add lots of fun little things as extra branches up until a point where they become bigger than the trunk and then the whole thing collapses.

so, to your reading of this topic; I saw this line:

This strategy is also conservative at the protocol level

or to write out the reference;

Disallowing Implicit Destruction of Immutable Tokens is also conservative at the protocol level

as a line that doesn’t actually imply it is a good idea to do the reverse and allow implicit destruction. Hence you two agree. Implicit destruction is a bad idea and specifically forbidden in the proposal.

The rest of the paragraph just ponders about different strategies in different contexts. Reading Jasons reddit post he was thinking about a sidechain and in that sidechain paying with a token may make sense. Naturally that would not change how the mainchain behaves.

Thanks for your awesome reply!

3 Likes

Talking with @im_uname over the last few months, we were all on the same track, trying to find a minimal set of primitives that can later enable features/products that we can’t even imagine right now. We had no idea you were doing a sort of “clean room design” and it’s brilliant!

When this landed at first I was like, oh damn, 2 CHIPs now, this will spread us thin, but on a second thought it’s awesome because your CHIP is really good!! It’ll help more people grasp the idea and make a stronger case for activating the tech, I don’t really care what we call it, CashTokens sounds good to me :slight_smile: Thinking about how to avoid spreading ourselves thin I think there is a way: if we can converge on the same spec, we’ll have 2 CHIPs making a bullet-proof case for the same thing! 2 CHIPs, one tech!

First step in that direction, edited mine to take out groupType into its own field: Remove vanity gen for the groupType, expand groupID to 33 bytes (bf37f2db) · Commits · ac-0353f40e / Unforgeable Groups for Bitcoin Cash · GitLab and as discussion progresses I hope to make some more edits.

The other day, thanks to your heads up and @tom 's idea from long time ago I had a breakthrough discovery with genesis setup, that’s now the main difference between the 2 CHIPs and I hope you’ll carefully evaluate v6.0 genesis setup and see what I’m seeing there, it’s such a powerful primitive!

1 Like

To avoid threads getting lost, I’ll try to respond to everything so far in one post.

Thanks! I’ve been trying to work out various designs for covenants which implement sidechain bridges/decentralized oracles, but I only convinced myself in the past couple weeks that the CashToken primitives truly belong in the BCH VM. (When I realized it would impact your work, I messaged you guys and dropped everything to get the draft done.)

Just to summarize, I think two different categories of work need to happen next:

Implementation & Tooling

This draft specification needs to be implemented in branches for nodes, Libauth, Bitauth IDE, Chaingraph, and any other high-use software. Since having these commitment primitives would even simplify the mental model required for covenant design, we have some thinking to do about development tooling and authentication template design, both of which are required for real-world wallets to interact with these covenants. Even if the CashTokens CHIP were deployed today, there’s a considerable amount of development work to be done before end users will be making predictions or trading on DEXs in their preferred wallet app. (But we have a clear path!)

Token Standards

The CashTokens CHIP describes the minimum network upgrade required to support any token standard. But that’s not enough: token issuers need complete, application-specific standards, guidance on best practices, and application-specific tooling.

Some of the low-level technical standards we’ll likely need:

  • Migration strategies from SLP(v1?)
  • Standards for issuing “collectable” NFTs
  • Metadata standards for tokens (name, icon, symbol, description, etc.):
    • Standards for immutable metadata (e.g. one-time issued tokens)
    • Standards for mutable metadata (e.g. issuers of trust-based assets need to be able to update the icon using e.g. Bitauth, users’ wallets need to notify the user and ask for confirmation to change how the asset is represented in the app)
  • Standards for multi-category, fungible tokens (e.g. for issuer who somehow need to issue more fungible tokens which they consider “fungible” with an existing batch of tokens. This may happen for some covenants which have shareholder votes, and probably will happen with lots of centralized issuers who don’t plan far enough ahead. Might be related to SLPv1 migration standards.)

We also need industry-specific standards, for example:

  • Standards for issuing equity in companies (companies who want to issue shares/options on Bitcoin Cash and then pay dividends directly to shareholders) – consistent standards here allow the whole Bitcoin Cash ecosystem to innovate on services and user experience, while preventing users from being locked-in to centralized holding institutions.
  • Standards for issuing event tickets – allowing ticket to be safely sold and transferred without being the event coordinators’ problem (a lot of event coordinators are not happy with centralized solutions, the fees they charge, and poor user experiences driven by lack of competition)
    • E.g. standards for transferring the ticket to a P2PKH key which can be displayed in an offline QR code (to be printed or displayed on screen for the ticket “collector” to scan/redeem)
  • Standards for loyalty points – while existing issuers of loyalty points often prefer that they can’t be transferred, customers want to transfer their points, and innovative issuers can differentiate themselves by making their points transferable.
  • Standards for gift cards and store credit – as with loyalty points, some issuers won’t be interested in making issued credit more transferrable, but customers want better ways to hold/transfer gift cards – if Bitcoin Cash offers a truely open standard, innovative companies will move the industry forward.

These are standards that need champions, wide coordination between stakeholders, and hopefully, innovative Bitcoin Cash startups to drive standardization and adoption.

In the same way that Bitcoin Cash already disintermediates money and payment networks – where existing companies/governments/central banks extract rent from a widely-used network – these token standards would allow Bitcoin Cash to disintermediate other industries where users “own” assets they cannot practically control – stocks, event tickets, loyalty points, store credit, etc.

By sharing a ledger, companies on Bitcoin Cash token standards can both compete with each other and benefit from a shared network effect. Institutions currently extracting rent from controlled networks are not competing with any one Bitcoin Cash company, they’re competing with all of them at the same time. Bitcoin Cash users get to choose which services or user interfaces they prefer for various assets/use cases, and all competition contributes to the value of the Bitcoin Cash network. (Note, this observation implies that these use cases could be lucrative for Bitcoin Cash startups.)

I should also note, this isn’t a call to move the internal database of every company on earth onto the Bitcoin Cash blockchain (that would be absurdly inefficient). Our goal should be to encode the minimum bytes needed to record asset ownership, so individuals can have meaningful control of their assets. Bitcoin Cash is a ledger for globally coordinating economic activity with the informed consent of every user; the network has no administrators to rent-seek or violate property rights. My current heuristic: if putting something on-chain improves individual sovereignty, do it.


Responses

On to specific questions – some of these were also answered above in the “theory” summary or in discussion on CashToken Devs, but just going to reply to each here for completeness:

Exactly – dropped. If we want logical consistency in the VM, token amounts should never exceed the maximum VM number. This is important for contracts because it eliminates a class of overflow bugs. Note however, it’s not a limitation in practice: Other token standards built on top of CashTokens can allow for an unlimited supply. (E.g. multi-category tokens, see: Limitation of Fungible Token Supply.)

Thanks for bringing that up – I’m now thinking that paragraph in the CHIP’s rationale is just incorrect: it’s almost certainly more efficient (in terms of real-world transaction costs) to have liquidity pools for various tokens which allow you to hand the pool some tokens and receive some BCH. If you wanted to pay for a transaction in another asset, you would simply swap it and not claim all of the released BCH (paying some BCH as a fee). This is far simpler to coordinate, and doesn’t require the “coincidence of wants” issue where the miner of the next block might not care about the particular token you’re hoping to use for fees. So token holders can already pay fees in BCH using atomic swaps, and that paragraph can be deleted. (Done :+1:, thanks!)

It fully replaces the inductive proof use case behind PMv3. PMv3 let us create transactions which themselves plan for a future transaction to be able to prove something about the contents of that transaction, i.e. an inefficient CashToken NFT.

You’re right that the “collectable NFT” use case can be partially replaced by a covenant which forces the user to re-add the same bytes in some part of the locking/redeem bytecode (in fact, it doesn’t even need OP_RETURN to do so). However, things fall apart with more interesting use cases: every such “token” needs to know (in advance) the structure of every contract which might “hold” it. (CashTokens v0 actually demonstrates the kind of hack you need for this with its optional multisig path.) In practice, this means covenants are forced to be closed systems, i.e. limited cross-contract interfaces, no decentralized ecosystem. (And as mentioned above, my goal is not to support collectable NFTs, they just happen to be made efficient by CashTokens.)

See above, but to expand on the second question – this actually highlights one of the simplifications we’re able to make when we acknowledge the incompatibility between fungible and non-fungible tokens:

Non-fungible tokens must be able to support a minting capability, a token which enables one-to-many token creation. (The mutable capability offers the corresponding one-to-one behavior, and every token has the default “burnable” behavior of one-to-none.) Because non-fungible is the more general of the two types (its the “raw” identity commitment), its “minting tokens” can also be used to demonstrate category-ownership for fungible tokens (but not the reverse). So even though it seems like we might need some equivalent “minting” capability for fungible tokens, that would add unnecessary complexity to these basic types. Any kind of fungible token standard can be implemented with just these basic types, and because all tokens use PREFIX_TOKEN, we even get a definition of “circulating supply” for free.

Both of these questions relate to storing data in token category preimages: this can achieve one behavior of CashToken NFTs – passing an authenticated message from a past transaction to a future transaction, but it’s less flexible and extremely inefficient. Pulling data from those preimages requires reconstructing the preimages, which doesn’t actually matter to the transaction in the future – it only needs the authenticated data. Having an explicit “identity commitment” primitive accomplishes the same task with smaller transaction sizes.

As for the mining use case – that’s not too difficult with just a covenant. Covenants can hand out tokens to any miners who prove they have the 0th output of a coinbase transaction (the covenant can inspect the preimage, which also includes the height since BIP34). Different people can deploy the same covenant, so a “miner vote” is available to any covenant system.

There are some significant disadvantages to this: Avoiding Proof-of-Work for Token Data Compression. And also relevant, any hashing strategy precludes the use of transaction IDs as token category IDs.

Yes, we’re fundamentally adding new data fields to the transaction format (in a way which is backwards compatible with v1/v2 transactions). The VM supports introspection of every property of transaction and evaluation state for operation set completeness, so every bit of new static state should have its own, single-byte opcode.

There is a design decision here I should share, though:

Including Capabilities in Token Category Inspection Operations

The token category inspection operations (OP_*TOKENCATEGORY) in this proposal push the concatenation of both category and capability (if present). While token capabilities could instead be inspected with individual OP_*TOKENCAPABILITY operations, the behavior specified in this proposal is valuable for contract efficiency and security.

First, the combined OP_*TOKENCATEGORY behavior reduces contract size in the most common case: every covenant which handles tokens must regularly compare both the category and capability of tokens. With the separated OP_*TOKENCATEGORY behavior, this common case would require at least 3 additional bytes for each occurrence – <index> OP_*TOKENCAPABILITY OP_CAT, and commonly, 6 or more bytes: <index> OP_UTXOTOKENCAPABILITY OP_CAT and <index> OP_OUTPUTTOKENCAPABILITY OP_CAT (<index> may require multiple bytes).

There are generally two other cases to consider:

  • covenants which hold mutable tokens (somewhat common) – these covenants are also optimized by the combined OP_*TOKENCATEGORY behavior. Because their mutable token can only create a single new mutable token, they need only verify that the user’s transaction doesn’t steal that mutable token: OP_INPUTINDEX OP_UTXOTOKENCATEGORY <index> OP_OUTPUTTOKENCATEGORY OP_EQUALVERIFY (saving at least 4 bytes when compared to the separated approach: OP_INPUTINDEX OP_UTXOTOKENCATEGORY OP_INPUTINDEX OP_UTXOTOKENCAPABILITY OP_CAT <index> OP_OUTPUTTOKENCATEGORY <index> OP_OUTPUTTOKENCAPABILITY OP_CAT OP_EQUALVERIFY).
  • covenants which hold minting tokens (rare) – because minting tokens allow for new tokens to be minted, these covenants must exhaustively verify all outputs to ensure the user has not unexpectedly minted new tokens. (For this reason, minting tokens are likely to be held in isolated, minting-token child covenants, allowing the parent covenant to use the safer mutable capability.) For most outputs (verifying the output contains no tokens), both behaviors require the same bytes – <index> OP_OUTPUTTOKENCATEGORY OP_0 OP_EQUALVERIFY. For expected token outputs, the combined behavior requires a number of bytes similar to the separated behavior, e.g.: <index> OP_OUTPUTTOKENCATEGORY <32> OP_SPLIT <0> OP_EQUALVERIFY <depth> OP_PICK OP_EQUALVERIFY (combined, where depth holds the 32-byte category set via OP_INPUTINDEX OP_UTXOTOKENCATEGORY <32> OP_SPLIT OP_DROP) vs. OP_INPUTINDEX OP_UTXOTOKENCATEGORY <index> OP_OUTPUTTOKENCATEGORY OP_EQUALVERIFY OP_INPUTINDEX OP_UTXOTOKENCAPABILITY <index> OP_OUTPUTTOKENCAPABILITY (separated).

Beyond efficiency, this combined behavior is also critical for the general security of the covenant ecosystem: it makes the most secure validation (verifying both category and capability) the “default” and cheaper in terms of bytes than more lenient validation (allowing for other token capabilities, e.g. during minting).

For example, assume this proposal specified the separated behavior: if an upgradable (e.g. by shareholder vote) covenant with a tracking token is created without any other token behavior, dependent contracts may be written to check that the user has also somehow interacted with the upgradable covenant (i.e. <index> OP_UTXOTOKENCATEGORY <expected> OP_EQUALVERIFY). If the upgradable covenant later begins to issue tokens for any reason, a vulnerability in the dependant contract is exposed: users issued a token by the upgradable covenant can now mislead the dependent contract into believing it is being spent in a transaction with the upgradeable contract (by spending their issued token with the dependent contract). Because the dependent contract did not include a defensive <index> OP_UTXOTOKENCAPABILITY <0xfe> OP_EQUALVERIFY (either by omission or to reduce contract size), it became vulnerable after a “public interface change”. If OP_UTXOTOKENCATEGORY instead uses the combined behavior (as specified by this proposal) this class of vulnerabilities is eliminated.

Finally, this proposal’s combined behavior preserves two additional, unused codepoints in the Bitcoin Cash VM instruction set.

(Didn’t have that polished before I published the draft, but it’s now in the CHIP :+1:)


I hope that answers all the open questions in this thread, please keep them coming!

3 Likes

I want to merge the 2 proposals so we can all use our energy better.
As you said, there’s much work to do post-activation, tooling, standards, etc.
The sooner we can “lock-in” a spec for activation, the sooner we can move to doing all those other exciting things!

Analyzing the “diff” between this CHIP and Group’s v6, there are “merge conflicts” and I intend to resolve those by implementing your spec into some v7 which can be just for reference if we bless your chip for activation - and it will also help me and anyone who’s followed Group’s progress better reason about it in familiar terms, and better understand your design decisions.

Your rationale for dropping the “singularity/baton” amount overload is convincing, and as you say - multi-category tokens make infinite supply viable while avoiding making a problem for the Script VM.
I gave up vanity-gen already for the same reason - it complicates things for Script.

So really, I think the only merge conflict will be the genesis setup, and there I hope it will be CT2.0 to resolve it by implementing the v6 genesis, I’ll make some arguments below as to why…

Note that I’m not (anymore) suggesting to replace your “commitment” field with packing it into “category”. I will be suggesting to have both primitives available. My only suggestion then is to replace your category genesis definition with an adaptation of Group’s (v6) and add the 7th introspection opcode, which can actually use the same codepoint (1 codepoint, 3 contexts - input prefix, opcode, output prefix) which is fitting because it’ll all relate to how the category came into existence.

What if the “authenticated data” needed is the information on the genesis setup?
What if you want to pick up any random UTXO and store its information for later?
You’d have to use another output as carrier, prepare it in advance (create it as vout 0), then spend it alongside the UTXO you want to store, and copy its TXID/index into the commitment field, and then the NFT will have to replicate this data all the time on every transfer, and when you need data from its preserved TX you still have to unpack the TXID by providing the preimage. If you wanted to store more than the output’s txid/index you’d have had to hash it all anyway so it can fit into the commitment field of the other output.
Sometimes having the data moved in “plaintext” is beneficial when you want to scan the blockchain for particular data, sometimes it is not.

The v6 genesis setup lets you pick and pack any existing UTXO (even another token) into the category (or commitment) of a new NFT created by consuming it, it may or may not be fully compressed in transit (depending on what you want), and sure, at the end destination it may or may not require some more of proof to unpack, depending on the genesis script/parameters you chose.
If v6 genesis setup is merged with your “commitment” extension, then it’ll enable more cool stuff, you can pack any UTXO and add a message to it, all in one output.

With your genesis setup, how do you resolve the problem of txid/0 already having a category? Is it prohibited or does it get burned? You can’t have both because then the input category inspection opcode would be ambiguous. This introduces a sort of discrimination against existing UTXOs… feels gnarly.

With a variant v6 genesis, you can pick any existing UTXO for genesis, and the input can carry both and the Script placed on prevout chooses what happens (new category genesis prohibited or old category burned, or prevout’s token simply ignored), and prevout inspection works the same (obtains prevout data), while a 7th opcode would be used to obtain the genesis preimage (which would contain non-deterministic parameters so you can validate the genesis setup - NFT type or genesis amount)

<expected parameters> // expected parameters hardcoded in redeem script
OP_INPUTINDEX OP_INPUTCATEGORYGENESIS // push the genesis parameters
OP_EQUALVERIFY // verify

OP_INPUTCATEGORYGENESIS returns either a <0> if not a genesis input, or genesis parameters:

- genesis version (1 byte),
- genesis prefix `has_nonfungible` parameter,
- genesis prefix `commitment_length` parameter,
- genesis prefix `commitment` parameter,
- genesis prefix `amount` parameter.

The categoryID preimage is then:

  1. prevout ref and genesis input index (txid + vout index + genesis input index)
  2. genesis parameters
  3. optional - whole prevout

The 1. MUST be there regardless of the version, it’s our security guarantee and ensures unique, unforgeable, and unmalleable (changing input slot) ID. The 2. can be used to prove how the token was created to some other contract. The 3. can be signalled by the genesis version byte, and used only when needed.

To prevent malleation you either “sign” the ID by hardcoding expected parameters (P2SH) as above, or you sign 1 output of the category being created (P2PKH).

Note that: if 3. is a commitment-carrying NFT, then its message will get compressed into the new token, too!

I claim that these primitives are emergent from the design of the Bitcoin Cash virtual machine: I did not design them to accomplish a set of “features”, I just discovered they are missing.

I will argue the same - going over many possible ways to do genesis (commiting to just the first input as Andrew propsoed, adding the prevout to that, using TXID as Tom proposed, using a genesis prototype prevout with ID=0x00, using the whole genesis TX for the preimage…) and thinking about how it could be later used in contracts I discovered what’s missing - input genesis declaration. :slight_smile:

2 Likes

aaah now I see it… the output caries BOTH the NFT and the leftToMint FT’s supply ie mint pool (in the amount) of the same category… the NFT mint type is then like a permission to take from the supply, right? And this way lets you enforce the MAX_SUPPLY globally to prevent funny situations in Script.

aand you can achieve infinite supply tokens by using the commitment as a sort of “family identifier” so even tokens of a distinct category could be fungible!

Right you are then, I’m pretty much on-board with CT as it is, it’s just this genesis setup described above I have strong feelings about because I really think it’s a breakthrough :slight_smile:

For other details, I’ll know better when I try to resolve “merge conflicts” by matching it with group chip and see if I discover anything that I’m not seeing yet.

2 Likes

If I understand your question, the goal is to encode some information in the category ID by making the category ID a hash of a specific, genesis data structure – a “genesis commitment”. But the category ID is a transaction ID, the hash of a specific data structure (the “pre-genesis” transaction) – a “pre-genesis commitment”. Is there some application of genesis commitments which cannot be supported by pre-genesis commitments? (The token issuer can easily create a “pre-genesis” transaction with whatever OP_RETURN outputs are needed by downstream applications or protocols.) If not, using transaction IDs as category IDs enables token-related applications to be powered by existing indexes.

It helps to focus only on UTXOs – every transaction has exactly one UTXO at index 0. The network already prevents UTXOs from being spent twice, so Category IDs are guaranteed to be unique by double-spending prevention.

Yes, that will be a common behavior for covenants. :+1:

I should clarify though, there is no fundamental minting designation specifically for the fungible tokens in an output – like “minting buckets”. All fungible CashTokens must be created in the category’s genesis transaction (even if some amount is still in the issuers control, i.e. reserved supply). But this is just how the underlying primitives work – standards built on top of CashTokens can easily standardize a strategy for issuing later batches of fungible tokens. (And there are many ways to design trustless migrations for category IDs using covenants.)

Note that even if we had some concept of “minting buckets”, off-chain token issuers could still fail to “properly label” their reserved supply (such that circulating supply is easy to calculate by all indexing applications). So the best we can do is make sure issuers know that “labelling” their reserved supply is possible (and token standards built on top of CashTokens should encourage compatibility too).

One cool side effect of simplifying away “minting buckets” is that it makes reserved/circulating supply easy to calculate for covenant-issued tokens by default – a covenant would have to be intentionally designed to make calculating its reserved/circulating supply harder for e.g. block explorers. So we get a more consistent/block-explorable token ecosystem for free.

3 Likes

It’s not just about the data although I arrived there thinking in that direction, trying to achieve similar functionality to “detached proofs” of PMv3, and that led me to a version (4.3 I think) where the whole genesis TX (except genesis IDs being generated) was the preimage (input scripts individually hashed) but that was too complex and still rigid so I had dropped it and went back to simple hash of the full prevout ref + prevout itself, thinking the same: you can move one step back and unwrap TXID to prove parts of “pre-genesis”.

Then when you had pinged me I was thinking “what could it possibly be?” and I thought it must be that you cracked the genesis setup! And that led me to revisit some old ideas (ID=00…00 for pre-genesis, next TX would generate the real ID) but then it hit me: genesis naturally belongs on inputs! Little did I know that you cracked something else that was giving me a headache… since subgroups got dropped I never looked back to adding more data but I had tried to achieve similar thing to your “commitment” by overloading the amount field and implementing a groupType=NFT | hasAmount which would let you have 8 “free” bytes on an NFT.

Anyway, that was just for some background - it’s about all existing UTXOs having equal “genesis potential” and creators of UTXOs being able to make a covenant that can prohibit, ignore, or require a token genesis on top of itself, with parameters specified by the covenant creator, without having to make sure they put it in the right slot. Also, if genesis is implicit, then you have to do it the roundabout way: verify your genesis output(s) introspected ID against the input’s introspected prevout TXID, if it matches - it’s a genesis. What if you want to verify the supply being created at genesis? Then you have to tally genesis TX outputs from within Script which is something we’re trying to avoid, no?

using transaction IDs as category IDs enables token-related applications to be powered by existing indexes

Well aware of this benefit and the trade-off, it’s just that I’m not convinced that it’s a good one now that I see this genesis-on-input approach.

You’re sacrificing a genesis way that perfectly fits in with Script VM and other BCH blockchain primitives in order to make some secondary jobs easier, jobs that weren’t really hard to begin with.

From talking with some others I got the impression that this easy indexing is a solution looking for a problem. The whole ecosystem is used to indexing token IDs, and if you get a random token and don’t want to use an index, then finding the genesis TX is a simple matter of tracing back a chain between your UTXO and the genesis TXO.

Is there some application of genesis commitments which cannot be supported by pre-genesis commitments?

Yeah, pre-genesis covenants, like these 2 examples:

  • Require that 10,000 sats is paid into some P2SH covenant and a NFT token created. The target covenant later easily verifies NFT’s genesis and that it’s getting burned and releases the 10,000 sats. Cool aspect of this: you can take 10,000 from any covenant UTXO, even ones not created by you, because the covenant only verifies the NFT template. Bitauth IDE
  • Require a token genesis to be created. Just that lets us do something interesting: define a standard where tokens are created from a public covenant like this (or authenticate by verifying a “detached owner” at txid/n+1). This way, services can subscribe to a single address to be updated whenever a new standard token genesis gets created. Bitauth IDE
2 Likes

This is clear to me, it was not about this, I misunderstood your spec. Question was related to what would executing OP_UTXOTOKENCATEGORY return if executed on an input whose prevout is a txid/0 and the prevout already has a token? But from the spec it’s clear - it would return the “old” token, and Script running on the input would have to look at outputs to know if it’s creating a new category and of what kind.

1 Like

Sorry for the late reply - there are some excellent points addressing my concerns. Some more thoughts for @bitjson :

Exactly – dropped. If we want logical consistency in the VM, token amounts should never exceed the maximum VM number. This is important for contracts because it eliminates a class of overflow bugs. Note however, it’s not a limitation in practice: Other token standards built on top of CashTokens can allow for an unlimited supply.

Note that even if we had some concept of “minting buckets”, off-chain token issuers could still fail to “properly label” their reserved supply (such that circulating supply is easy to calculate by all indexing applications). So the best we can do is make sure issuers know that “labelling” their reserved supply is possible (and token standards built on top of CashTokens should encourage compatibility too).

Note taken, I suppose the “right way” to do mintable fungibles, then, is to establish a very large bucket that is locked away and accessible only to a baton NFT. Standardizing how a specific way to do this is “mintable” will help application interfaces to deal with this, and separate the intentions of a “very high supply token” and a “mintable token”. One way to be very clear about it is perhaps by standardizing “mintable” tokens as tokens who are simply minted with the maximum VM supply, then further defining how the reserve can be held.

On this point: (also thanks @bitcoincashautist for clarifying some of that above!)

The reserved supply of a fungible token category can be computed by retrieving all UTXOs which contain token prefixes matching the category ID, removing provably-destroyed outputs (spent to OP_RETURN ), and summing the amount s held in prefixes which have either the minting or mutable capability."

Is there any advantage to limit reserving to mutable/mintables? It seems to me that they don’t confer any additional advantage compared to vanilla NFTs; in fact using them may complicate identification of reserve pots down the line.

While this does not affect consensus, when specifying standards for mintable tokens I’d actually do the opposite: reserves should go to a vanilla NFT so they remain in one easily identifiable chain, and we can further specify they need to be at output x of genesis for easy identification, etc. Other configurations are possible but will take the form of additional standards.

Thanks for bringing that up – I’m now thinking that paragraph in the CHIP’s rationale is just incorrect: it’s almost certainly more efficient (in terms of real-world transaction costs) to have liquidity pools for various tokens which allow you to hand the pool some tokens and receive some BCH. If you wanted to pay for a transaction in another asset, you would simply swap it and not claim all of the released BCH (paying some BCH as a fee). This is far simpler to coordinate, and doesn’t require the “coincidence of wants” issue where the miner of the next block might not care about the particular token you’re hoping to use for fees. So token holders can already pay fees in BCH using atomic swaps, and that paragraph can be deleted. (Done :+1:, thanks!)

I don’t think it’s sufficient to delete the miner fee rationale - with that gone, the only remaining rationale is safety, and there are ways to get around it (for example, adding a requirement for, say, a SIGHASH_TOKEN bit in inputs spending tokens) without losing the freedom to destroy. I feel strongly that wallet owners should be able to destroy their tokens and recover the sats - I can attempt a PR to the specs if necessary.

4 Likes

They could, with OP_RETURN, but it would be cheaper with implicit destruction so there’s an argument there for allowing implicit destruction.

If you had 10 token UTXOs with distinct category IDs, you’d need 10 inputs and 10 OP_RETURN outputs to “eat” each token + 1 pure BCH change output.

With implicit destruction, you’d need just the 10 inputs and 1 BCH change output.

Wallet safety is one argument for keeping it explicit, although there may be alternatives as you suggested.

I wonder whether there are some Script VM implications but I can’t think of any right now. It’s just one more way to burn: 1bitcoineater, 0-amount OP_RETURN, omission (needs >= instead of == balancing rule).

3 Likes

Posting a review mixed with suggestions here.

2 Likes

@bitcoincashautist and I worked through the token genesis question offline. TL;DR: if any relevant use cases are discovered in the future, there are at least two good alternatives to a built-in category preimage data structure.

First observation: we haven’t yet identified any use case that requires a contract to “accept” tokens of an unknown category where some vetting process isn’t already required, e.g. a vote of shareholders, some staking process, submission with a liquidity pool of BCH, etc. Since these processes already imply that economic actors are somehow vetting the unknown token category (e.g. reviewing the details of the issuing covenant, verifying the tokens’ utility in an external system, checking that a pegged asset has audited reserves, etc.), (re)verifying a few details of the unknown token category’s genesis transaction in the on-chain contract bytecode doesn’t offer any additional value (it just wastes transaction bytes/fees).

However, if someone did discover a use case in the future, there are at least two good options available without modifying the current specification:

  1. Using the pre-genesis transaction as a commitment structure – e.g. committing data to OP_RETURN outputs or specifying a covenant which enforces constraints around token genesis, and/or
  2. Covenants-as-standards - well-known public covenants which oversee the creation of many new tokens according to strict rules, allowing those covenants to:
    1. Enforce uniqueness across a large, managed category of NFTs, and/or
    2. Freely issue “certification tokens” – tokens which attest to the newly created token category’s compliance, e.g. fixed supply below some limit, no minting tokens, minting tokens assigned to a strict covenant, etc. Such certification tokens could also be issued to public covenants which prevent them from being moved or destroyed, allowing any transaction to temporarily borrow them for a proof (and then return them to the same covenant).

Interestingly enough, the covenants-as-standards strategy is far more efficient than either commitment structure option. It cuts down the transaction size cost of verifying category genesis properties to 36 bytes (<index> OP_UTXOTOKENCATEGORY <covenant_managed_category_id> OP_EQUAL) rather than the hundreds of bytes required for contracts to reconstruct, verify, and inspect a category ID’s preimage (whether that preimage is a transaction or a new data structure).

So with that, we concluded it makes sense to leave that part of the CHIP as-is (using transaction IDs as category IDs).

3 Likes

Thanks for the comments @im_uname, @bitcoincashautist, and @emergent_reasons! I’ll try to respond here to everything in this thread, then respond on GitHub to activity there.

Yes, exactly. I think that would be a good start for standardizing “mintable, fungible tokens” in some “SLPv2” specification. I think it’s also good idea for standards to attempt to conform to how covenants will issue such tokens by recommending that trusted token issuers hold their “reserved” tokens in outputs with either minting or mutable capabilities. (More in below response.)

If I’m understanding the question – yes. If the goal were only to standardize a method for identifying circulating/reserved tokens, I would argue that definition belongs in complete token standards rather than in this CHIP.

The rationale behind including these particular supply definitions in this CHIP is that there is an important, “emergent standard” inherent to how most covenants must issue tokens (if they use the minimum possible contract/transaction sizes): most covenants hold easily identifiable reserves of their own, unissued tokens. This supply of unissued covenant-held tokens will almost always be held in a top-level or depository child covenant, many of which will use a tracking token with the mutable capability. Simpler covenants may also directly hold the minting capability, rather than isolating it to a privileged child covenant (somewhat like a linux superuser account). In both cases, the “reserved” supply is easy to calculate by outside observers (and without adding complexity to the covenant to accommodate some standard).

Given this reality, it makes sense for higher level token standards to attempt to standardize around compatible definitions, ensuring good application-layer compatibility between on-chain and off-chain token uses.

On higher level standards: I agree – it’s a great idea to standardize around minting and holding all reserves in the 0th transaction output. (Bonus: Bitauth-supporting infrastructure like Chaingraph already supports recursive lookups of the 0th output.) So this CHIP’s only contribution in that respect would be to clarify that each of those 0th outputs must have either the minting or mutable capability, ensuring that supply calculation for standards-compliant tokens issued by centralized entities are compatible with supply calculation for covenant-issued tokens.

This is a great point, thanks for noticing @im_uname! As @bitcoincashautist mentioned, requiring OP_RETURN for token destruction makes cleaning up “token dust” much more expensive than some sort of SIGHASH_TOKEN. A signing serialization type flag also simplifies away the awkward destruction policy difference between fungible or immutable tokens and minting or mutable tokens (where the former currently cannot be implicitly destroyed, but the later can).

In fact, to prevent offline signers from being mislead by omitting token information in signing requests, we also need to add the token information directly to the signing serialization. Maybe we include the full contents of the token output prefix (same encoding) after value in the algorithm for SIGHASH_TOKEN signatures?

If you’d be interested in sending a PR, I’d definitely appreciate it! (I’m also happy to write the update or any relevant rationale, just let me know what you’re interested in doing.)

Right, it will still be possible for tokens to be explicitly burned to OP_RETURN outputs (e.g. for protocols which require proof of burn), but the SIGHASH_TOKEN strategy is both more efficient and closes some possible vulnerabilities in offline signers.

Aside: funds/tokens sent to 1bitcoineater... are actually not safe for any token standard to consider “burned” – those funds can be unlocked in the future if someone manages to acquire that private key e.g. a break in the crypto, even decades from now. Even more plausible, a very expensive collision search could eventually create a new P2PKH “burn address” with a known private key. That’s one reason we can be pretty confident in the CHIP’s token supply definitions after only removing OP_RETURN outputs: OP_RETURN covers all provably unspendable outputs which can be generated by standard transactions. (To provably burn tokens with a different locking bytecode – e.g. OP_0 – each user would have to manually submit/mine a non-standard transaction.)

4 Likes

Thanks, I’ll try to submit a PR this week. :slight_smile:

3 Likes

That captures and summarizes it - for now :slight_smile:
Let’s keep it on the back-burner while we focus on other things, and maybe we’ll later hit some “Aha!” moment when we start working out examples and standards.

Just to add some closing thoughts: I wouldn’t mind if genesis was left as-is, although I’m not fully convinced, because I see workarounds for what I had in mind with using the TXID. If you need workarounds to achieve something, then maybe the whole thing could be reworked so you don’t need those workarounds.

I feel like our genesis setup could become an important “commitment primitive” as it can preserve and carry any TXID and with that preserve a proof that something happened in the past. With that in mind I’d like to future-proof it and would want it to be as generic and flexible as possible, so we don’t wake up one day thinking like we did with TXID: Damn, it would be real nice if TXID hashed locking scripts individually while constructing the preimage.
We’re looking at it from different angles/philosophies I guess. I’m thinking: if we’re introducing blockchain-native primitives, then they should allow for maximum expressiveness to blockchain-native agents (contract entities).

1 Like

Yes. I thought it would be “automatically” included as if it was part of hashOutputs scriptPubKey but better to spell it out.

This comment made me realize something: the prevout’s token payload is special because signing serialization sometimes uses the locking script and sometimes the redeem script so we should add the prevout’s PFX inside the scriptCode, prepended to the actual script.

2 Likes

(I think you mean hashPrevouts?) Right, hashPrevouts commits to the full contents of all the transactions with outputs being spent by the current transaction. The main reason value is included separately by BIP143 (and then by BCH’s signing serialization algorithm) is to make verification easy for offline signers. In practice, many offline signers weren’t actually verifying the values from the source transactions because to do so could require transferring, decoding, and inspecting MBs of raw transactions. Committing to the value directly in the signing serialization allows for equivalent security using much simpler offline signing implementations. (Even if all transaction data must be transferred e.g. by keyboard or a QR code.)

I’m not sure if I understand the logic here, but my initial reaction is that scriptCode is already a pretty complicated idea – I think we’re best off leaving it as-is and just committing to the full token prefix directly after value. (And only if SIGHASH_TOKEN is present.)

2 Likes