Creating Move Coin
Overview
This tutorial guides you through the process of creating and minting your own coin using the 0x1::managed_coin module on the Initia blockchain. It includes initializing your coin, obtaining metadata, minting coins, and checking the balances.
Tutorial
Step 1: Initialize Your Coin
To initialize your coin, you must call the 0x1::managed_coin::initialize function.
public entry fun initialize(
account: &signer,
maximum_supply: Option<u128>,
name: String,
symbol: String,
decimals: u8,
icon_uri: String,
project_uri: String,
)> initiad tx move execute 0x1 managed_coin initialize \
--args "option<u128>:null string:my_coin string:MYCOIN u8:6 string: string:" \
--from [key-name] \
--gas auto --gas-adjustment 1.5 --gas-prices 0.15uinit \
--node [rpc-url]:[rpc-port] --chain-id [chain-id]import {
bcs,
LCDClient,
MnemonicKey,
MsgExecute,
Wallet,
} from '@initia/initia.js';
async function createCoin() {
const lcd = new LCDClient('[rest-url]', {
gasPrices: '0.15uinit',
gasAdjustment: '1.5',
});
const key = new MnemonicKey({
mnemonic: 'beauty sniff protect ...',
});
const wallet = new Wallet(lcd, key);
const msgs = [
new MsgExecute(
key.accAddress,
'0x1',
'managed_coin',
'initialize',
[],
[
// max supply, if you want to set max supply, insert number instaed of null
bcs.option(bcs.u128()).serialize(null).toBase64(),
bcs.string().serialize('my_coin').toBase64(), // name
bcs.string().serialize('MYCOIN').toBase64(), // symbol
// decimal point (raw value 1 consider to 10 ** (- decimalPoint))
bcs.u8().serialize(6).toBase64(),
bcs.string().serialize('').toBase64(), // icon uri
bcs.string().serialize('').toBase64(), // project uri
]
),
];
// sign tx
const signedTx = await wallet.createAndSignTx({ msgs });
// send(broadcast) tx
lcd.tx.broadcastSync(signedTx).then(res => console.log(res));
// {
// height: 0,
// txhash: '40E0D5633D37E207B2463D275F5B479FC67D545B666C37DC7B121ED551FA18FC',
// raw_log: '[]'
// }
}
createCoin();Step 2: Mint Coin
To mint coins, you will use the 0x1::managed_coin::mint function.
Before minting, you need to obtain the metadata for your coin, which can be done through the 0x1::coin::metadata view function or by using sha3_256(creator+symbol+0xFE).
Obtaining Metadata
Minting Coins
After minting, you can check the balances to verify the minting process. You can refer to this section for checking balances.
Last updated