Ethereum:Transaction

The ethereum:transaction element is used to create an Ethereum transaction.

The ethereum:transaction element usually is nested inside the transaction tag which is a part of an Action Card. It requires to specify a contract, which is defined above in the contract element, as well as a function, which is part of the smart contract. Usually it requires some data, which can be defined with the ethereum:value element in simple cases or with the data tag for more complicated transactions.

Code Examples

An Action card which creates an Ethereum transaction to wrap an amount of Ether given by the user.

<ts:card type="action" name="wrap">
        <ts:label>
          <ts:string xml:lang="en">Wrap</ts:string>
        </ts:label>
      <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 WETH</ts:string>
         </ts:label>
         <ts:origins>
             <ts:user-entry as="e18"/>
         </ts:origins>
        </ts:attribute>
      <ts:transaction>
          <ethereum:transaction function="deposit" contract="weth">
             <ethereum:value ref="amount"/>
            </ethereum:transaction>
        </ts:transaction>
      <ts:view xml:lang="en">
          <xhtml:style type="text/css">&style;</xhtml:style>
         <xhtml:script type="text/javascript">&wrap.en;</xhtml:script>
       </ts:view>
</ts:card>

An Action Card which approves the Compound smart contract to use WBTC.

<ts:card type="action" exclude="enabled" name="enable">
        <ts:label>
            <ts:string xml:lang="en">Enable</ts:string>
        </ts:label>
        <ts:transaction>
            <ethereum:transaction function="approve" contract="WBTC" as="bool">
                <ts:data>             <ts:address>0xC11b1268C1A384e55C48c2391d8d480264A3A7F4</ts:address>            <ts:uint256>115792089237316195423570985008687907853269984665640564039457584007913129639935</ts:uint256>
                </ts:data>
            </ethereum:transaction>
        </ts:transaction>
        <ts:view xml:lang="en">
            <xhtml:style type="text/css">&style;</xhtml:style>
            <xhtml:script type="text/javascript">&enable.en;</xhtml:script>
        </ts:view>
 </ts:card>