Returns the transactions from the current user or address. Returns an object with the number of transactions and the array of native transactions (asynchronous).
Options:
chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
from_date (optional): The date from where to get the transactions (any format that is accepted by momentjs). Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used.
to_date (optional): Get the transactions to this date (any format that is accepted by momentjs). Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used.
from_block (optional): The minimum block number from where to get the transactions Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used.
to_block (optional): The maximum block number from where to get the transactions. Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used.
offset(optional): Offset.
limit(optional): Limit
// get mainnet transactions for the current userconsttransactions=awaitMoralis.Web3API.account.getTransactions();// get BSC transactions for a given address// with most recent transactions appearing firstconstoptions= { chain:"bsc", address:"0x3d6c0e79a1239df0039ec16Cc80f7A343b6C530e", from_block:"0",};consttransactions=awaitMoralis.Web3API.account.getTransactions(options);
import React from"react";import { useMoralisWeb3Api } from"react-moralis";constWeb3Api=useMoralisWeb3Api();constfetchTransactions=async () => {// get mainnet transactions for the current userconsttransactions=awaitWeb3Api.account.getTransactions();console.log(transactions);// get BSC transactions for a given address// with most recent transactions appearing firstconstoptions= { chain:"bsc", address:"0x3d6c0e79a1239df0039ec16Cc80f7A343b6C530e", from_block:"0", };constbscTransactions=awaitWeb3Api.account.getTransactions(options);console.log(bscTransactions);};
usingMoralisUnity;usingMoralisUnity.Web3Api.Models;usingUnityEngine;publicclassExample{publicasyncvoidGetTransactions() { // get BSC transactions for a given addressTransactionCollection BSCtransactions =awaitMoralis.Web3Api.Account.GetTransactions("0x3d6c0e79a1239df0039ec16Cc80f7A343b6C530e".ToLower(),ChainList.bsc);Debug.Log(BSCtransactions.ToJson()); }}
Returns native balance for a specific address (asynchronous).
Options:
chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
to_block (optional): The block number on which the balances should be checked.
address (optional): The address for which the native balance will be checked. If specified, the user attached to the query is ignored and the address will be used instead. If user is not authenticated with a Wallet, then address has to be specified.
// get mainnet native balance for the current userconstbalance=awaitMoralis.Web3API.account.getNativeBalance();// get BSC native balance for a given addressconstoptions= { chain:"bsc", address:"0x3d6c0e79a1239df0039ec16Cc80f7A343b6C530e", to_block:"1234",};constbalance=awaitMoralis.Web3API.account.getNativeBalance(options);
import React from"react";import { useMoralisWeb3Api } from"react-moralis";constWeb3Api=useMoralisWeb3Api();constfetchNativeBalance=async () => {// get mainnet native balance for the current userconstbalance=awaitWeb3Api.account.getNativeBalance();console.log(balance);// get BSC native balance for a given addressconstoptions= { chain:"bsc", address:"0x3d6c0e79a1239df0039ec16Cc80f7A343b6C530e", to_block:"1234", };constbscBalance=awaitWeb3Api.account.getNativeBalance(options);console.log(bscBalance);};
usingMoralisUnity;usingMoralisUnity.Web3Api.Models;usingUnityEngine;publicclassExample{publicasyncvoidGetNativeBalance() { // get BSC native balance for a given addressNativeBalance BSCbalance =awaitMoralis.Web3Api.Account.GetNativeBalance("0x4c6Ec2448C243B39Cd1e9E6db0F9bF7436c0c93f".ToLower(),ChainList.bsc);Debug.Log(BSCbalance.ToJson()); }}
Example result:
{"balance": "1234567890"}
getTokenBalances
Retrieve all token balances of a current user or specified address. Returns an object with the number of tokens and the array of token objects (asynchronous).
Options:
chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
to_block (optional): The block number on which the balances should be checked
Without any parameters specified, it defaults to 'Eth' as chain and the current user, but you can also specify the chain and addressin an options object:
Get ERC20 token transfers from the current user or address. Returns an object with the number of token transfers and the array of token transfers (asynchronous).
Options:
chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
from_date (optional): The date from where to get the transactions (any format that is accepted by momentjs). Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used.
to_date (optional): Get the transactions to this date (any format that is accepted by momentjs). Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used.
from_block (optional): The minimum block number from where to get the transactions Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used.
to_block (optional): The maximum block number from where to get the transactions. Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used.
offset(optional): Offset.
limit(optional): Limit
// get mainnet transfers for the current userconstuserTrans=awaitMoralis.Web3API.account.getTokenTransfers();// get BSC transfers for a given address// with most recent transfers appearing firstconstoptions= { chain:"bsc", address:"0x3d6c0e79a1239df0039ec16Cc80f7A343b6C530e", from_block:"0",};consttransfers=awaitMoralis.Web3API.account.getTokenTransfers(options);
import React from"react";import { useMoralisWeb3Api } from"react-moralis";constWeb3Api=useMoralisWeb3Api();constfetchTokenTransfers=async () => {// get mainnet transfers for the current userconstuserTrans=awaitWeb3Api.account.getTokenTransfers();console.log(userTrans);// get BSC transfers for a given address// with most recent transfers appearing firstconstoptions= { chain:"bsc", address:"0x3d6c0e79a1239df0039ec16Cc80f7A343b6C530e", from_block:"0", };consttransfers=awaitWeb3Api.account.getTokenTransfers(options);console.log(transfers);};
Get all NFTs from the current user or address. Supports both ERC721 and ERC1155. Returns an object with the number of NFT objects and the array of NFT objects (asynchronous).
Options:
chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
// get NFTs for current user on MainnetconstuserEthNFTs=awaitMoralis.Web3API.account.getNFTs();// get testnet NFTs for userconsttestnetNFTs=awaitMoralis.Web3API.account.getNFTs({ chain:"ropsten" });// get polygon NFTs for addressconstoptions= { chain:"polygon", address:"0x75e3e9c92162e62000425c98769965a76c2e387a",};constpolygonNFTs=awaitMoralis.Web3API.account.getNFTs(options);
import React from"react";import { useMoralisWeb3Api } from"react-moralis";constWeb3Api=useMoralisWeb3Api();constfetchNFTs=async () => {// get NFTs for current user on MainnetconstuserEthNFTs=awaitWeb3Api.account.getNFTs();console.log(userEthNFTs);// get testnet NFTs for userconsttestnetNFTs=awaitWeb3Api.Web3API.account.getNFTs({ chain:"ropsten", });console.log(testnetNFTs);// get polygon NFTs for addressconstoptions= { chain:"polygon", address:"0x75e3e9c92162e62000425c98769965a76c2e387a", };constpolygonNFTs=awaitWeb3Api.account.getNFTs(options);};console.log(polygonNFTs);
Get the NFT transfers. Returns an object with the number of NFT transfers and the array of NFT transfers (asynchronous).
Options:
chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
format (optional): The format of the token id. Available values : decimal, hex. Default value : decimal.
offset(optional): Offset.
direction(optional): The transfer direction. Available values : both, to, from . Default value : both.
limit(optional): Limit.
address (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.
// get mainnet NFT transfers for the current userconsttransfersNFT=awaitMoralis.Web3API.account.getNFTTransfers();// get BSC NFT transfers for a given address// with most recent transactions appearing firstconstoptions= { chain:"polygon", address:"0x75e3e9c92162e62000425c98769965a76c2e387a", limit:"5",};consttransfersNFT=awaitMoralis.Web3API.account.getNFTTransfers(options);
import React from"react";import { useMoralisWeb3Api } from"react-moralis";constWeb3Api=useMoralisWeb3Api();constfetchNFTTransfers=async () => {// get mainnet NFT transfers for the current userconsttransfersNFT=awaitWeb3Api.account.getNFTTransfers();console.log(transfersNFT);// get BSC NFT transfers for a given address// with most recent transactions appearing firstconstoptions= { chain:"polygon", address:"0x75e3e9c92162e62000425c98769965a76c2e387a", limit:"5", };constbscTransfersNFT=awaitWeb3Api.account.getNFTTransfers(options);console.log(bscTransfersNFT);};
Returns an object with the NFT count for the specified contract and an NFT array belonging to the given address for the specified contract (asynchronous).
Options:
chain(optional): The blockchain to get data from. Valid values are listed on Supported Chains. Default value Eth.
format (optional): The format of the token id. Available values : decimal, hex. Default value : decimal.
offset(optional): Offset.
limit(optional): Limit.
address (optional): The owner of a given token (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead.