Skip to main content

FLOW Token Management

Some actions on the network will require an account to have a certain amount of FLOW (tokens) - transaction and storage fees, account creation, etc. Framework provides a method to query FLOW balances with getFlowBalance and mint new tokens via mintFlow.

getFlowBalance(address)

Returns current FLOW token balance of the specified account.

Arguments

NameTypeDescription
addressAddressaddress of the account to check

Returns

TypeDescription
stringUFix64 amount of FLOW tokens stored in account storage

Usage


_22
import {
_22
init,
_22
emulator,
_22
getAccountAddress,
_22
getFlowBalance,
_22
} from "@onflow/flow-js-testing"
_22
_22
const main = async () => {
_22
const basePath = path.resolve(__dirname, "../cadence")
_22
_22
await init(basePath)
_22
await emulator.start()
_22
_22
const Alice = await getAccountAddress("Alice")
_22
_22
const [result, error] = await getFlowBalance(Alice)
_22
console.log(result, error)
_22
_22
await emulator.stop()
_22
}
_22
_22
main()

mintFlow(recipient, amount)

Sends transaction to mint the specified amount of FLOW and send it to recipient.

⚠️ Required: Framework shall be initialized with init method for this method to work.

Arguments

NameTypeDescription
recipientAddressaddress of the account to check
amountstringUFix64 amount of FLOW tokens to mint and send to recipient

Usage


_17
import {init, emulator, mintFlow} from "@onflow/flow-js-testing"
_17
_17
const main = async () => {
_17
const basePath = path.resolve(__dirname, "../cadence")
_17
_17
await init(basePath)
_17
await emulator.start()
_17
_17
const Alice = await getAccountAddress("Alice")
_17
const amount = "42.0"
_17
const [mintResult, error] = await mintFlow(Alice)
_17
console.log(mintResult, error)
_17
_17
await emulator.stop()
_17
}
_17
_17
main()