TokenScript Weekly meeting #31

This is mostly about renaming elements.

  • unify id/name/ref attributes across the board and finding a new name for <name> element. (Weiwu proposes label)

Previously we have

<ts:transaction>
   <ts:ethereum function="…" >
       <data>…</data>
      <value ref="amount"/>
   </ts:ethereum>
</ts:transaction>

Thanks to the introduction of ethereum: namespace, which is introduced to pave the way for multi-blockchain support (e.g. Cardano), we replaced all

<ethereum function="…"/>

to

<ethereum:call function="…"/>

So the example code becomes:

<ts:transaction>
   <ethereum:call function="…" >
       <data>…</data>
      <value ref="amount"/>
   </ethereum>
</ts:transaction>

Furthermore, I (Weiwu) made a change as noticed value here, which represent the value field in a transaction, is easily mistaken as the value reference in data. I figure that

<ethereum:ether ref="amount"/>

less ambiguously mean that amount amount of ether is to be transferred. That is, the following is less ambiguous:

<ts:transaction>
   <ethereum:call function="…" >
       <data>…</data>
      <ether ref="amount"/>
   </ethereum>
</ts:transaction>

By Boon: But Ethereum docs and tutorials say:

  • "call — invoke without gas + read-only"
  • "transaction - invoke function with gas"

If we follow that, we might define a new element called ethereum:transaction based on ethereum:call, which has one additional element

<ts:transaction>
   <ethereum:transaction function="…" >
       <data>…</data>
      <ether ref="amount"/>
   </ethereum:transaction>
</ts:transaction>

Now, at first, this may look confusing because you get a transaction element right nested into another transaction element. But that two transactions meant differently.

In database lingo (which TS borrows), a transaction is a bunch of operations that either success or fail together. Typically, two operations, one that changes the balance and the other changes the effect (e.g. one deducts $10 and the other prolongs Netflix subscription by 1 month).

In Ethereum lingo, a transaction is either a call to a smart contract function with some ether attached or a transfer of ether to a new address. It's not possible to do two operations in one transaction, but you can write a smart contract to do that.

We have:

  1. Accept the lingo, and use transaction inside transactions (I can provide a few examples where this make sense).

  2. Consider ethereum:call inside <ts:transaction> to actually represent a call inside a transaction in terms of Ethereum. (A separate ethereum:transfer is used to represent simple Ether transfers).

The decision is we go for 1.

Also, between

<ethereum:value ref="amount"/>

and

<ethereum:ether ref="amount"/>

We chose the former, as Ethereum developer (Sangalli) felt it more natural.