---
# System prepended metadata

title: Create ExeToken

---

# Create ExeToken
There are two ways to create ExeToken. One is to call the smart contract  and mint it directly. The other is to use the ExeToken editor in this site.
Here we will explain how to use the editor.

## Go to ExeToken editor
archive provides the editor to easily create ExeTokens. You can go to the editor from the 'Create' link in the account menu.

<img src="https://hackmd.io/_uploads/HJA5-KErh.png"  height="200px"/>

The ExeToken editor consists of the following features.

* Writing the function that implements ExeToken functionality
* Execution environment to test the function 
* Making the avator of ExeToken
* Minting ExeToken

## Write ExeToken function
The first step to create a ExeToken is to write a function. In this tutorial, we try to create [a ExeToken with the function to get a kitty data using CrytoKitties smart contracts](https://ikaruga.app/token/18) . Here is the whole code.

```Solidity
/**
* @name Kitty's gene decoder
* @desc This function gets the kitty from CryptoKitties and decodes its gene.
* @param kittyId the kitty id
* @return decoded gene
*/
function decodeKittyGene(kittyId=0) {
  // address of KittyCore contract
  var ckAddress = '0x06012c8cf97BEaD5deAe237070F9587f8E7A266d';

  // get the kitty data by kitty id
  var kitty = staticcallContract(
    ckAddress,
    'getKitty(uint256)',
    [{"name":"isGestating","type":"bool"},{"name":"isReady","type":"bool"},{"name":"cooldownIndex","type":"uint256"},{"name":"nextActionAt","type":"uint256"},{"name":"siringWithId","type":"uint256"},{"name":"birthTime","type":"uint256"},{"name":"matronId","type":"uint256"},{"name":"sireId","type":"uint256"},{"name":"generation","type":"uint256"},{"name":"genes","type":"uint256"}],
    kittyId);
  
  // get address of GeneScience contract for decoding gene
  var geneSciAddress = staticcallContract(
    ckAddress,
    'geneScience()',
    {"name":"","type":"address"});
    
  // decode the gene
  var decodedGene = staticcallContract(
    geneSciAddress,
    'decode(uint256)',
    {"name":"","type":"uint256[]"},
    kitty[9]); // 9th element is the encoded gene
    
  return decodedGene;
}
```

The exetoken function is implemented in [SnippetJS that is subset language of JavaScript](https://ikaruga.app/docs/snippet-js-overview). The decodeKittyGene() has a parameter 'kittyId' to get the kitty data from CryptoKitties, and returns the gene data of the kitty. In order to call the smart contracts of CrytoKitties, the decodeKittyGene() uses staticcallContract() which is the built-in function of SnippetJS. For example, the first staticcallContract() calls the 'getKitty' method included in the KittyCore contract with the kittyId of uint256 type and returns the return value of this method after decoding it into the data structure specified in the third argument.

The variable assigned the return value of call has a value type corresponding to the data structure specified by the third argument. In the example above, the variable 'kitty' has the value type of [bool,bool,number,number,number,number,number, number,number,number], 'geneSciAddress' has the string type, and 'decodedGene' has the number array type.


As you can see, the staticcallContract() requires the ABI of the method you want to call. The easiest way to get the ABIs is to use ABI JSON export feature of Etherscan. Once you have the ABI JSON, importing it in the ExeToken editor will generate the code for calling staticcallCall for the specific method.

<img src="https://hackmd.io/_uploads/H1zHGt4Hh.png" height="300px"/>

## Test the function
You can test the ExeToken function in the execution environment on Etherum blockchain through the ExeToken editor GUI.

<img src="https://hackmd.io/_uploads/HyFJzKNrn.png" width="80%"/>

In the 'Arguments' part, you can change the values of the arguments passed to the function. The run result or error will be displayed in the 'Result' part. Note that the ExeToken whose function causes errors is completely useless. Make sure the function runs successfully with at least the default arguments.

## Make the avator of the ExeToken
ExeToken has an avatar for visual identification. The avatar can be made from one of the following data sources.


| Source | Description |
| -------- | -------- |
| Token name     | The name of the token will be displayed as the avatar. The token name can be edit by @name tag in the JSDoc comment. |
| Description     | The description of the token will be displayed as the avatar. The description can be edit by @desc tag in the JSDoc comment. |
| Image     | Use any image as the avatar. Note that using images may result in very high gas cost or exceed the gas limit. It is recommended to resize the width and height of the image used for the avatar to 100px or less. |
| Code     | The source code of the ExeToken function will be displayed as the avator.  |
| Result     | The execution result of the ExeToken function will be displayed as the avator. The execution result means the stringified return value of the ExeToken function.   |
| Fill     | An image filled with a solid color will be displayed as an avatar   |
| None     | Nothing will be displayed. The avator will be like a transparent rectangle.    |


Avatars are generated by our smart contracts according to the specified data source when dataURI which is the one of the ERC721 interfaces is called. If 'Result' is specified, the function will be executed each time an avatar is generated, so avoid it if the execution time is long.

For our 'Kitty's gene decoder' token, we choose 'Image' avator and upload a image file of a CryptoKitties flavored kitty. Both width and height of the image will be resized to 100px to save mint cost.

<img src="https://hackmd.io/_uploads/r1THjeUS2.png" height="300px"/>

## Set categories
ExeTOken can have categories for easy classifying and searching them.　## Set categories
ExeTokens can have categories for easy classifying and searching them. 'Kitty's gene decoder' is a utility tool and it should be added to 'utility' cetegory.

## Mint the ExeToken
You can mint ExeTokens by signing mint transactions with MetaMask and paying the mint cost. There are some tips to reduce the mint cost.
* Make the implementation and comments of the ExeToken simple. (i.e. reduce the number of characters in the source code)
* Reduce the number of categories on the ExeToken. 
* Avoid the 'Image' type avatar. In terms of mint cost, 'Image' is by far the most expensive, others are about the same.
* When using 'Image', please lower the resolution of the image data.