General
init()
Factory function to that creates a read-only or writeable client. By providing a signer
additional write APIs that require signing, like joinNetwork
and delegateStake
are available. By default, a read-only client is returned and no write APIs are available.
// read-only client
const ario = ARIO.init();
// read-write client for browser environments
const ario = ARIO.init({ signer: new ArConnectSigner(window.arweaveWallet, Arweave.init({}))});
// read-write client for node environments
const ario = ARIO.init({ signer: new ArweaveSigner(JWK) });
getInfo()
Retrieves the information of the ARIO process.
const ario = ARIO.mainnet();
const info = await ario.getInfo();
Output:
{
"Name": "ARIO",
"Ticker": "ARIO",
"Owner": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
"Denomination": 6,
"Handlers": ["_eval", "_default_"], // full list of handlers, useful for debugging
"LastCreatedEpochIndex": 31, // epoch index of the last tick
"LastDistributedEpochIndex": 31 // epoch index of the last distribution
}
getTokenSupply()
Retrieves the total supply of tokens, returned in mARIO. The total supply includes the following:
total
- the total supply of all tokenscirculating
- the total supply minus locked, withdrawn, delegated, and stakedlocked
- tokens that are locked in the protocol (a.k.a. vaulted)withdrawn
- tokens that have been withdrawn from the protocol by operators and delegatorsdelegated
- tokens that have been delegated to gatewaysstaked
- tokens that are staked in the protocol by gateway operatorsprotocolBalance
- tokens that are held in the protocol's treasury. This is included in the circulating supply.
const ario = ARIO.mainnet();
const supply = await ario.getTokenSupply();
Output:
{
"total": 1000000000000000000,
"circulating": 998094653842520,
"locked": 0,
"withdrawn": 560563387278,
"delegated": 1750000000,
"staked": 1343032770199,
"protocolBalance": 46317263683761
}
getBalance()
Retrieves the balance of the specified wallet address.
const ario = ARIO.mainnet();
// the balance will be returned in mARIO as a value
const balance = await ario
.getBalance({
address: 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ',
})
.then((balance: number) => new mARIOToken(balance).toARIO()); // convert it to ARIO for readability
Output:
100000
getBalances()
Retrieves the balances of the ARIO process in mARIO
, paginated and sorted by the specified criteria. The cursor
used for pagination is the last wallet address from the previous request.
const ario = ARIO.mainnet();
const balances = await ario.getBalances({
cursor: '-4xgjroXENKYhTWqrBo57HQwvDL51mMdfsdsxJy6Y2Z_sA',
limit: 100,
sortBy: 'balance',
sortOrder: 'desc',
});
Output:
{
"items": [
{
"address": "-4xgjroXENKYhTWqrBo57HQwvDL51mMvSxJy6Y2Z_sA",
"balance": 1000000
},
{
"address": "-7vXsQZQDk8TMDlpiSLy3CnLi5PDPlAaN2DaynORpck",
"balance": 1000000
}
// ...98 other balances
],
"hasMore": true,
"nextCursor": "-7vXsQZQDk8TMDlpiSLy3CnLi5PDPlAaN2DaynORpck",
"totalItems": 1789,
"sortBy": "balance",
"sortOrder": "desc"
}
transfer()
Transfers mARIO
to the designated target
recipient address. Requires signer
to be provided on ARIO.init
to sign the transaction.
Note: Requires signer
to be provided on ARIO.init
to sign the transaction.
const ario = ARIO.mainnet({
signer: new ArweaveSigner(jwk),
});
const { id: txId } = await ario.transfer(
{
target: '-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5',
qty: new ARIOToken(1000).toMARIO(),
},
// optional additional tags
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
);
How is this guide?