Skip to content

Create a token

This tutorial describes the process of creating a basic fungible token on Magi.

Clone the Magi token contract template:

Terminal window
git clone https://github.com/vsc-eco/magi_token_contract your-token
cd your-token

Compile your token contract:

Terminal window
tinygo build -gc=custom -scheduler=none -panic=trap -no-debug -target=wasm-unknown -o build/main.wasm ./contract
wasm-tools strip -o build/main-striped.wasm build/main.wasm

Then deploy the contract:

Terminal window
# If not done already, init config and fill in deployer active key
contract-deployer -init
# Deploy token
contract-deployer -wasmPath build/main-striped.wasm -name "your token name"

Call the init function from your token contract owner address (contract deployer if not specified) with the following payload:

{"name":"Token Name","symbol":"TKN","decimals":3,"maxSupply":1000000000}

Call the mint function from the token owner address with the below payload. The tokens minted will be sent to your address.

{"amount":1000}

Call the burn function with the below payload. The tokens will be burnt from the caller address.

{"amount":500}

Call the transfer function with the below payload specifying the destination address and amount.

{"to":"hive:recipient","amount":100}

For more details on Magi token standards, please refer to the README.