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
Name | Type | Description |
---|---|---|
address | Address | address of the account to check |
Returns
Type | Description |
---|---|
string | UFix64 amount of FLOW tokens stored in account storage |
Usage
_22import {_22 init,_22 emulator,_22 getAccountAddress,_22 getFlowBalance,_22} from "@onflow/flow-js-testing"_22_22const 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_22main()
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
Name | Type | Description |
---|---|---|
recipient | Address | address of the account to check |
amount | string | UFix64 amount of FLOW tokens to mint and send to recipient |
Usage
_17import {init, emulator, mintFlow} from "@onflow/flow-js-testing"_17_17const 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_17main()