How integrations 𝑏𝑒𝑡𝑤𝑒𝑒𝑛 tokens are supposed to be handled?

Still confused as to how we are supposed to represent the relationship of one token to another.

For example, let's say the cryptokitty dapp allows for a discount on the purchase of a kitty if you own a crypto dragon. How do we define that interaction inside the file? Is the TokenScript file of the crypto dragon automatically found via a curl to the repo server?

Hi Sangalli, I wished you had asked about integration between token and web applications. Your confusion is justified because I haven't got a full explanation on the integration between token and token.

The integration examples in a casebook and the design paper were focused on how to integrate tokens with web services (dapp websites).

About a token integration with another token, there are a few cases.

  1. A token can be used with another in a transaction. See the example of shipment label used with payment token case†. Itself might be consumed.
  2. Like 1, but itself is not consumed. In this manner, the token is like an attestation.
  3. A token's function depends on another.‡

† https://github.com/AlphaWallet/TokenScript/releases/ and search shipment in the PDF.

‡ https://github.com/AlphaWallet/TokenScript/releases/ and search for the car example, observe that the car insurance token 𝑑𝑒𝑝𝑒𝑛𝑑𝑠 on the car token itself.

In the case 3, it's clear that dependency as a token relationship must be consciously defined in TokenScript (although I don't know what syntax is that defined). e.g. a car's insurance token depends on the validity of a car's rego token (an unregistered car can't be insured).

Similarly, the relationship of authorisation (a special kind of token owned by the authorised person) with accounts (accounts can be thought of as a wrapped-eth token contract with authorise() stuff) must be defined in TokenScript. If an account is closed, all authorisations on it are invalidated.

But the example you gave is of case 2. It can be conceptualised as related only to an action (purchase-cryptokitty action of cryptokitty TokenScript), 𝑛𝑜𝑡 related to a token, because the cryptokitty you bought at discount with a crypto dragon is the same as the cryptokitty you bought at full price. It's a relationship defined on an action, which is more interesting since I don't know how it would be defined.

It's our design goal to cover such relationships.


That's what I can provide now. But let's assume you are asking the question for a very different reason, not as a designer but as a user, then I can give you a straightforward answer on what the final result should look like.

  1. the user sees the button to buy a crypto kitty on any website (not only crypto kitty dapp website).
  2. the user hit the button.
  3. an action card opens (purchase-kitty action). Since kitty's TokenScript declared relationship with a dragon, the user is prompted that you have a dragon and that can give you a discount. The user checks "use discount" to finalise the purchase.

About privacy, as you know, an action card is rendered by the user-agent, therefore the dapp website does not learn about your ownership of a cryptodragon token (unless it wants to decompile the transaction payload after having learned the transaction is done).