SDK
crossbell.js
Contract API
Tip
Read Methods

Read Methods

The following methods are used to read $MIRA related data from the blockchain.

getMiraBalanceOfCharacter

This gets the balance of $MIRA token of a character.

If it is a normal character, this returns the balance of the address of the character. If it is a newbie-village character, this returns the balance of the character in the contract.

This throws if the character is not found.

getMiraBalanceOfCharacter(
  characterId: BigNumberish,
  overrides: CallOverrides = {},
): Promise<Result<string>> | never

Usage

Get the balance of a character with ID 42.

import { formatEther } from 'ethers/lib/utils'
const result = contract.getMiraBalanceOfCharacter(42)
const balanceInWei = result.data

Parameters

characterId

  • Type: BigNumberish

The ID of the character.

Returns

interface Returns {
  data: string // The balance in wei.
}

getMiraBalance

This gets the balance of $MIRA token of an address.

async getMiraBalance(
  address: string,
  overrides: CallOverrides = {},
): Promise<Result<string>> | never
⚠️

If use this method to get the balance of a character, it will return the balance of the address of the character. This will not work as expected for newbie-village characters because they share the same address. It is recommended to use getMiraBalanceOfCharacter instead.

Usage

Get the balance of an address.

import { formatEther } from 'ethers/lib/utils'
const result = contract.getMiraBalance('0x1234567890123456789012345678901234567890')
const balanceInWei = result.data

Parameters

address

  • Type: string

The address of the character.

Returns

interface Returns {
  data: string // The balance in wei.
}

getMiraTokenAddress

This gets the address of the $MIRA token contract.

getMiraTokenAddress(overrides: CallOverrides = {}): Promise<Result<string>> | never

Usage

Get the address of the $MIRA token contract.

const result = contract.getMiraTokenAddress()
const address = result.data

Returns

interface Returns {
  data: string // The address of the $MIRA token contract.
}

getMiraTokenDecimals

This gets the decimals of the $MIRA token contract.

getMiraTokenDecimals(overrides: CallOverrides = {}): Promise<Result<number>> | never

Usage

Get the decimals of the $MIRA token contract.

const result = contract.getMiraTokenDecimals()
const decimals = result.data

Returns

interface Returns {
  data: number // The decimals of the $MIRA token contract.
}