<ethereum:call> element

The Ethereum:Call element gets information from an Ethereum smart contract.

In many cases you need to get information from a smart contract: To display it to the user, to create a transaction and much more. In TokenScript a smart contract call is triggered by the Ethereum:Call element. It is usually put inside the attribute root and there inside the origin element.

Code Examples

Define the attribute emailRecord from an ENS domain by calling the smart contract.

<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>

Ask a smart contract if an entry token is expired or still valid

<ts:attribute name="expired"> 
        <ts:type><ts:syntax>1.3.6.1.4.1.1466.115.121.1.7</ts:syntax></ts:type>
      <ts:origins>
        <ethereum:call function="isExpired" contract="EntryToken" as="bool">
          <ts:data>
            <ts:uint256 ref="tokenId"/>
          </ts:data>
        </ethereum:call>
      </ts:origins>
</ts:attribute>

Get the address of a lending pool.

<ts:attribute name="lendingPoolAddress">
    <ts:type><ts:syntax>1.3.6.1.4.1.1466.115.121.1.15</ts:syntax></ts:type>
    <ts:origins>
        <ethereum:call function="getLendingPool" contract="LendingPoolAddressesProvider" as="address">
         </ethereum:call>
     </ts:origins>
</ts:attribute>