<origins> element

The origins element can be a root element to define the contract a token uses, but can also be inside attributes to get the source of an attribute, like through an ethereum call.

The origins element is usually used at two occasions: First, at the beginnung of a TokenScript to define the underlying smart contract, like DAI. Second, to get the value of an Attribute.

Code examples

Defining the underlying Smart Contract

<ts:origins>
     <ts:ethereum contract="DAI"/>
</ts:origins>

Get an attribute value from a user entry

<ts:attribute name="amount">
    <ts:type>
        <ts:syntax>1.3.6.1.4.1.1466.115.121.1.36</ts:syntax>
    </ts:type>
        <ts:label>
            <ts:string xml:lang="en">Amount in DAI</ts:string>
                <ts:string xml:lang="zh">代幣金額</ts:string>
          </ts:label>
        <ts:origins>
                  <ts:user-entry as="e18"/>
        </ts:origins>
</ts:attribute>

Get an attribute value from an Ethereum call

<ts:attribute name="emailRecord">
    <ts:type>
        <ts:syntax>1.3.6.1.4.1.1466.115.121.1.15</ts:syntax>
    </ts:type>
        <ts:origins>
              <ethereum:call as="utf8" contract="PublicResolver" function="text">
               <ts:data>
                          <ts:bytes32 local-ref="nodeHash"/>
                          <ts:string>email</ts:string>
                    </ts:data>
              </ethereum:call>
        </ts:origins>
</ts:attribute>


Related information

Attributes

We make tokens smart

Smart Token Labs is the creator of TokenScript and AlphaWallet two open source solutions for a tokenized future.