Initia (Closed Testnet)
  • Reminder
    • ⛔Confidentiality Disclaimer
  • WELCOME TO CLOSED TESTNET
    • Welcome to Closed Testnet
  • About Initia
    • What is the Initia Platform?
      • Architecture
        • Layer 1
        • Layer 2
      • Aligning Initia (coming soon!)
    • InitiaDEX
    • Enshrined Liquidity and Staking
  • Developers
    • Initiad
      • Download Initiad
      • Using Initiad
    • Get INIT token
    • Build your own Minitia
      • Simple Minitia Setup
      • Connect Minitia to L1
        • OPinit Stack
          • OPinit Module
          • OPinit Bots
        • Relayer
          • Fetching Oracle Prices
    • Virtual Machines
      • MoveVM
        • Interact with CLI
      • WasmVM
    • Contracts
      • Move Contracts
      • CosmWasm Contracts
      • EVM Contracts (Coming Soon)
    • Oracles
  • Initia Developer Tutorials
    • 1. Create account
    • 2. Send Move coin
    • 3. Interchain Message
    • 4. Create your own Move coin
    • 5. Create your own Move NFT
    • 6. Build and Publish Contracts
      • Move Module
      • CosmWasm Contract
  • Core Applications
    • Core Applications
      • Wallet
      • Initia App
      • Usernames
      • Initia Scan
  • Node Operators
    • Running Initia Node
      • Prerequisites
      • Oracle
      • Boot an Initia Node
      • Connect to Initia Network
      • Cosmovisor Guide
    • Configuring Initia Validator
  • References and Tools
    • Move Language
    • Rust Language (CosmWasm)
    • Closed Testnet Chain Information
    • Chain Parameters
    • Initia.js
    • API Docs
    • API Docs (minimove)
    • API Docs (miniwasm)
    • Whitelisted Tokens and Pairs
Powered by GitBook
On this page
  • Step 1: Get coin from faucet (Optional)
  • Step 2: Send Coin
  1. Initia Developer Tutorials

2. Send Move coin

This tutorial covers multiple ways to send coins on the Initia blockchain, and how to send transactions on Initia and Minitias.

Step 1: Get coin from faucet (Optional)

Get Testnet INIT tokens from the Initia Faucet if the account does not hold any tokens. See Get INIT token.


Step 2: Send Coin

Check balances before sending coin.

> initiad query bank balances [addr] \
    --node [rpc-url]:[rpc-port]

balances:
- amount: "100000000"
  denom: uinit
pagination:
  next_key: null
  total: "0"
  
> initiad query bank balances [addr] \
    --node [rpc-url]:[rpc-port]

balances: []
pagination: null

TIP: On Cosmos ecosystem, the u prefix on the token denom defines as μ(0.000001). The above example with 100,000,000 uinit means 100 INIT.

Send coin

> initiad tx bank send [key-name] [addr] 100000uinit \
    --gas auto --gas-adjustment 1.5 --gas-prices 0.15uinit \
    --node [rpc-url]:[rpc-port] --chain-id [chain-id]

gas estimate: 909531
auth_info:
  fee:
    amount:
    - amount: "136430"
      denom: uinit
    gas_limit: "909531"
    granter: ""
    payer: ""
  signer_infos: []
  tip: null
body:
  extension_options: []
  memo: ""
  messages:
  - '@type': /cosmos.bank.v1beta1.MsgSend
    amount:
    - amount: "100000"
      denom: uinit
    from_address: init17exjfvgtpn5ne4pgmuatjg52mvvtj08773tgfx
    to_address: init1ehg0xxyksp69kfsvq8k336e7mpscf29nt50sjl
  non_critical_extension_options: []
  timeout_height: "0"
signatures: []
confirm transaction before signing and broadcasting [y/N]: y
code: 0
codespace: ""
data: ""
events: []
gas_used: "0"
gas_wanted: "0"
height: "0"
info: ""
logs: []
raw_log: '[]'
timestamp: ""
tx: null
txhash: A33D7F2E8472506FCC8C1C480817C040B19D0340766B861781D5A822AD55D882

Check balances after sending coin.

> initiad query bank balances [addr] \
    --node [rpc-url]:[rpc-port]

balances:
- amount: "99763570"
  denom: uinit
pagination:
  next_key: null
  total: "0"
> initiad query bank balances init1ehg0xxyksp69kfsvq8k336e7mpscf29nt50sjl \
    --node https://next-stone-rpc.initia.tech:443

balances:
- amount: "100000"
  denom: uinit
pagination:
  next_key: null
  total: "0"

You can check that the Sender's balance has decreased by fee + send amount, and the receiver's balance increased by the send amount.

Check balances before sending coin.

import { LCDClient, MnemonicKey } from '@initia/initia.js';

async function checkBalances() {
  const lcd = new LCDClient('[rest-url]', {
    gasPrices: '0.15uinit',
    gasAdjustment: '1.5',
  });

  const key = new MnemonicKey({
    mnemonic:
      'beauty sniff protect ...',
  });
  const receiver = 'init10v3kg8hfvsj6tklfj5aam9ya5lmvtl9snqsawg';

  const senderBalances = await lcd.bank.balance(key.accAddress);
  const receiverBalances = await lcd.bank.balance(receiver);

  console.log('sender balances:', senderBalances[0]);
  // sender balances: Coins {
  //   _coins: {
  //     uinit: Coin { denom: 'uinit', amount: '100000000', isDecimal: false }
  //   }
  // }
  console.log('receiver balances:', receiverBalances[0]);
  // receiver balances: Coins { _coins: {} }
}

checkBalances();

TIP: On Cosmos ecosystem, the u prefix on the token denom defines as μ(0.000001). The above example with 100,000,000 uinit means 100 INIT.

Send coin

import { LCDClient, MnemonicKey, MsgSend, Wallet } from '@initia/initia.js';

async function sendCoin() {
  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 receiver = 'init10v3kg8hfvsj6tklfj5aam9ya5lmvtl9snqsawg';

  const msgs = [
    new MsgSend(
      key.accAddress, // sender
      receiver,       // receiver
      '100000uinit'   // amount
    ),
  ];

  // sign tx
  const signedTx = await wallet.createAndSignTx({ msgs });
  // send(broadcast) tx
  lcd.tx.broadcastSync(signedTx).then(res => console.log(res));
  // {
  //   height: 0,
  //   txhash: 'EA9021C165FF676820C4FB3C01DD88626FCE0202B1511F0DD42FB6A58C92C730',
  //   raw_log: '[]'
  // }
}

sendCoin();

Check balances after sending coin.

import { LCDClient, MnemonicKey } from '@initia/initia.js';

async function checkBalances() {
  const lcd = new LCDClient('[rest-url]', {
    gasPrices: '0.15uinit',
    gasAdjustment: '1.5',
  });

  const key = new MnemonicKey({
    mnemonic:
      'beauty sniff protect ...',
  });
  const receiver = 'init10v3kg8hfvsj6tklfj5aam9ya5lmvtl9snqsawg';

  const senderBalances = await lcd.bank.balance(key.accAddress);
  const receiverBalances = await lcd.bank.balance(receiver);

  console.log('sender balances:', senderBalances[0]);
  // sender balances: Coins {
  //   _coins: {
  //     uinit: Coin { denom: 'uinit', amount: '99763592', isDecimal: false }
  //   }
  // }
  console.log('receiver balances:', receiverBalances[0]);
  // receiver balances: Coins {
  //   _coins: {
  //     uinit: Coin { denom: 'uinit', amount: '100000', isDecimal: false }
  //   }
  // }
}

checkBalances();

You can check that the Sender's balance has decreased by fee + send amount, and the receiver's balance increased by the send amount.

Previous1. Create accountNext3. Interchain Message

Last updated 1 year ago