Account

getTransactions

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 the intro page in the Transactions and Balances section. 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
1
// get mainnet transactions for the current user
2
const transactions = await Moralis.Web3API.account.getTransactions();
3
​
4
// get BSC transactions for a given address
5
// with most recent transactions appearing first
6
const options = { chain: "bsc", address: "0x...", order: "desc", from_block: "0" };
7
const transactions = await Moralis.Web3API.account.getTransactions(options);
Copied!

Example result:

1
[
2
{
3
"hash": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
4
"nonce": "326595425",
5
"transaction_index": "25",
6
"from_address": "0xd4a3BebD824189481FC45363602b83C9c7e9cbDf",
7
"to_address": "0xa71db868318f0a0bae9411347cd4a6fa23d8d4ef",
8
"value": "650000000000000000",
9
"gas": "6721975",
10
"gas_price": "20000000000",
11
"input": "string",
12
"receipt_cumulative_gas_used": "1340925",
13
"receipt_gas_used": "1340925",
14
"receipt_contract_address": "0x1d6a4cf64b52f6c73f201839aded7379ce58059c",
15
"receipt_root": "string",
16
"receipt_status": "1",
17
"block_timestamp": "2021-04-02T10:07:54.000Z",
18
"block_number": "12526958",
19
"block_hash": "0x0372c302e3c52e8f2e15d155e2c545e6d802e479236564af052759253b20fd86"
20
}
21
]
Copied!

getNativeBalance

Returns native balance for a specific address (asynchronous).

Options:

  • chain(optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. 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.
1
// get mainnet native balance for the current user
2
const balance = await Moralis.Web3API.account.getNativeBalance();
3
​
4
// get BSC native balance for a given address
5
const options = { chain: "bsc", address: "0x...", to_block: "1234" };
6
const balance = await Moralis.Web3API.account.getNativeBalance(options);
Copied!

Example result:

1
{
2
"balance": "1234567890"
3
}
Copied!

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 the intro page in the Transactions and Balances section. 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
1
const balances = await Moralis.Web3API.account.getTokenBalances();
Copied!
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:
1
const options = { chain: 'bsc', address: "0x...", to_block: "10253391" }
2
const balances = await Moralis.Web3API.account.getTokenBalances(options);
Copied!

Example result:

1
[
2
{
3
"token_address": "0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09",
4
"name": "Kylin Network",
5
"symbol": "KYL",
6
"logo": "https://cdn.moralis.io/eth/0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c.png",
7
"thumbnail": "https://cdn.moralis.io/eth/0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c_thumb.png",
8
"decimals": "18",
9
"balance": "123456789"
10
}
11
]
Copied!

getTokenTransfers

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 the intro page in the Transactions and Balances section. 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
1
// get mainnet transfers for the current user
2
const userTrans = await Moralis.Web3API.account.getTokenTransfers();
3
​
4
// get BSC transfers for a given address
5
// with most recent transfers appearing first
6
const options = { chain: "bsc", address: "0x...", from_block: "0" };
7
const transfers = await Moralis.Web3API.account.getTokenTransfers(options);
Copied!

Example result:

1
[
2
{
3
"transaction_hash": "0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09",
4
"address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
5
"block_timestamp": "2021-04-02T10:07:54.000Z",
6
"block_number": "12526958",
7
"block_hash": "0x0372c302e3c52e8f2e15d155e2c545e6d802e479236564af052759253b20fd86",
8
"to_address": "0x62AED87d21Ad0F3cdE4D147Fdcc9245401Af0044",
9
"from_address": "0xd4a3BebD824189481FC45363602b83C9c7e9cbDf",
10
"value": "650000000000000000"
11
}
12
]
Copied!

getNFTs

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 the intro page in the Transactions and Balances section. 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.
1
// get NFTs for current user on Mainnet
2
const userEthNFTs = await Moralis.Web3API.account.getNFTs();
3
​
4
// get testnet NFTs for user
5
const testnetNFTs = await Moralis.Web3API.account.getNFTs({ chain: 'ropsten' });
6
​
7
// get polygon NFTs for address
8
const options = { chain: 'matic', address: '0x...' };
9
const polygonNFTs = await Moralis.Web3API.account.getNFTs(options);
Copied!

Example result:

1
[
2
{
3
"token_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
4
"token_id": "15",
5
"contract_type": "ERC721",
6
"owner_of": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
7
"block_number": "88256",
8
"block_number_minted": "88256",
9
"token_uri": "string",
10
"metadata": "string",
11
"synced_at": "string",
12
"amount": "1",
13
"name": "CryptoKitties",
14
"symbol": "RARI"
15
}
16
]
Copied!

getNFTTransfers

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 the intro page in the Transactions and Balances section. 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.
  • order (optional): The field(s) to order on and if it should be ordered in ascending or descending order.
  • 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.
1
// get mainnet NFT transfers for the current user
2
const transfersNFT = await Moralis.Web3API.account.getNFTTransfers();
3
​
4
// get BSC NFT transfers for a given address
5
// with most recent transactions appearing first
6
const options = { chain: "bsc", address: "0x...", limit: "10" };
7
const transfersNFT = await Moralis.Web3API.account.getNFTTransfers(options);
Copied!
Use the token_address param to get results for a specific contract only.
Note results will include all indexed NFTs.
Any request which includes the token_address param will start the indexing process for that NFT collection the very first time it is requested.

Example result:

1
[
2
{
3
"token_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
4
"token_id": "15",
5
"from_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
6
"to_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
7
"amount": "1",
8
"contract_type": "ERC721",
9
"block_number": "88256",
10
"block_timestamp": "2021-06-04T16:00:15",
11
"block_hash": "string",
12
"transaction_hash": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
13
"transaction_type": "string",
14
"transaction_index": "string",
15
"log_index": 0
16
}
17
]
Copied!

getNFTsForContract

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 the intro page in the Transactions and Balances section. Default value Eth.
  • format (optional): The format of the token id. Available values : decimal, hex. Default value : decimal.
  • offset(optional): Offset.
  • limit(optional): Limit.
  • order(optional): The field(s) to order on and if it should be ordered in ascending or descending order.
  • 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.
  • token_address(required): Address of the contract
1
const options = { chain: 'matic', address: '0x...', token_address: '0x...' };
2
const polygonNFTs = await Moralis.Web3API.account.getNFTsForContract(options);
Copied!
Use the token_address param to get results for a specific contract only.
Note results will include all indexed NFTs.
Any request which includes the token_address param will start the indexing process for that NFT collection the very first time it is requested.

Example result:

1
[
2
{
3
"token_address": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
4
"token_id": "15",
5
"contract_type": "ERC721",
6
"owner_of": "0x057Ec652A4F150f7FF94f089A38008f49a0DF88e",
7
"block_number": "88256",
8
"block_number_minted": "88256",
9
"token_uri": "string",
10
"metadata": "string",
11
"synced_at": "string",
12
"amount": "1",
13
"name": "CryptoKitties",
14
"symbol": "RARI"
15
}
16
]
Copied!
Last modified 2mo ago