EVM Compute Units
All Moralis plans have generous limits on the number of requests you can make per month. How many included requests you have depends on the plan you have, check the pricing page for more details.
Some requests are more expensive than others. By giving some heavy requests higher weight, we ensure that you only pay for what you use and not a cent more.
This allows you to get cheaper requests for most use cases while protecting our systems from abuse by weighing the computationally expensive endpoints.
What is a Compute Unit (CU)?
A compute unit is a measure of the requests needed to query computationally expensive API endpoints. Each request has both price and rate limit cost that are measured in terms of compute units. It is also important to note that some API will have dynamic pricing that will cost more CU the more inputs you add for the request.
Price
Request price refers to the amount of compute units that will be calculated towards your API usage billing.
Dynamic Prices
Some endpoints have a dynamically priced CU cost based on the number of resources being requested. The more resources being requested, the higher the CU cost for that particular request. Taking getNativeBalancesForAddresses as an example; the base CU cost of this endpoint when fetching the balance of a single address is 1 CU. If we wanted to fetch the balances of 5 addresses at once, then the CU cost for that particular call would be 5 CU.
Rate limit Cost
CUs play a big role in determining how frequently you can send API requests, thanks to something called rate limits. Think of rate limit costs as a way to keep track of your "API health", helping you avoid overloading the system with too many requests in a short span.
When you're setting up a function call, remember to factor in the query parameters as well! These can sometimes add to the CU cost. To stay on top of it, always check the individual query parameter costs in the query parameters table to have a clear picture of the total CU cost your call will incur. This way, you can make well-informed decisions and prevent any unexpected surprises in your CU usage.
Let's take the function getMultipleTokenPrices as an example. It has two query parameters: chain and include=percent_change. While specifying chain is essential, adding include=percent_change will cost an extra 5 CU according to the rate limit cost table. So, it's wise to consult the table to have a clear understanding of the potential costs involved and manage your CU allocation effectively.
By taking a moment to consult the table before making a call, you can avoid unexpected CU charges and keep your API interactions smooth and efficient.
Name | Path | Price | Rate Limit Cost | |
Base | Additional | |||
getBlock | /block/{block_number_or_hash} | 10 | 0 | 5 |
getContractEvents | /{address}/events | 2 | 0 | 2 |
getTransaction | /transaction/{transaction_hash} | 2 | 0 | 3 |
getTransactions | /{address} | 5 | 0 | 4 |
getTransactionVerbose | /transaction/{transaction_hash}/verbose | 5 | 0 | 5 |
getMultipleNFTs | /nft/getMultipleNFTs | 5 | +5 CUs per NFTs | 5 |
getTransactionsVerbose | /{address}/verbose | 10 | 0 | 10 |
getInternalTransactions | /transaction/{transaction_hash}/internal-transactions | 5 | 0 | 5 |
getNativeBalance | /{address}/balance | 1 | 0 | 1 |
getNativeBalancesForAddresses | /wallets/balances | 1 | +1 CU per wallet addresses | 1 |
getTokenBalances | /{address}/erc20 | 10 | 0 | 5 |
getWalletTokenBalancesPrice | /{address}/tokens | 10 | 0 | 5 |
getTokenTransfers | /{address}/erc20/transfers | 5 | 0 | 2 |
getTokenAddressTransfers | /erc20/{address}/transfers | 10 | 0 | 2 |
getNFTs | /{address}/nft | 5 | 0 | 5 |
getNFTTransfers | /{address}/nft/transfers | 5 | 0 | 5 |
getNftTransfersByBlock | /block/{block_number_or_hash}/nft/transfers | 2 | 0 | 2 |
getTokenMetadata | /erc20/metadata | 1 | 0 | 1 |
web3ApiVersion | /web3/version | 1 | 0 | 1 |
getTokenMetadataBySymbol | /erc20/metadata/symbols | 1 | 0 | 1 |
getTokenPrice | /erc20/{address}/price | 10 | +5 per token, if you add the query parameter include=percent_change | 3 |
getMultipleTokenPrices | /erc20/prices | 10 per token | +5 per token, if you add the query parameter include=percent_change | 3 |
getTokenAllowance | /erc20/{address}/allowance | 1 | 0 | 1 |
getAllTokenIds | /nft/{address} | 5 | 0 | 5 |
getContractNFTTransfers | /nft/{address}/transfers | 5 | 0 | 5 |
getWalletNFTCollections | /nft/{address}/collections | 5 | 0 | 5 |
getNFTOwners | /nft/{address}/owners | 5 | 0 | 5 |
getNFTMetadata | /nft/{address}/metadata | 5 | 0 | 5 |
syncNFTContract | /nft/{address}/sync | 5 | 0 | 25 |
reSyncMetadata | /nft/{address}/{token_id}/metadata/resync | 5 | 0 | 25 |
getTokenIdOwners | /nft/{address}/{token_id}/owners | 5 | 0 | 5 |
getWalletTokenIdTransfers | /nft/{address}/{token_id}/transfers | 2 | 0 | 2 |
resolveDomain | /resolve/{domain} | 1 | 0 | 1 |
resolveAddressToDomain | /resolve/{address}/domain | 1 | 0 | 1 |
resolveENSDomain | /resolve/ens/{domain} | 1 | 0 | 1 |
resolveAddress | /resolve/{address}/reverse | 1 | 0 | 1 |
getPairReserves | /{pair_address}/reserves | 1 | 0 | 1 |
getLogsByAddress | /{address}/logs | 5 | 0 | 2 |
getNftTransfersFromToBlock | /nft/transfers | 5 | 0 | 5 |
getNFTTrades | /nft/{address}/trades | 4 | 0 | 4 |
getNFTLowestPrice | /nft/{address}/lowestprice | 4 | 0 | 4 |
getWalletActiveChains | /wallets/{address}/chains | 10 | +10 CUs per chains | 5 |
getTopERC20TokensByMarketCap | /market-data/erc20s/top-tokens | 20 | 0 | 5 |
getTopERC20TokensByPriceMovers | /market-data/erc20s/top-movers | 20 | 0 | 5 |
getTopNFTCollectionsByMarketCap | /market-data/nfts/top-collections | 20 | 0 | 5 |
getHottestNFTCollectionsByTradingVolume | /market-data/nfts/hottest-collections | 20 | 0 | 5 |
contractsReview | /contracts-review | 0 | 0 | 1 |
endpointWeights | /info/endpointWeights | 0 | 0 | 1 |
getWalletStats | /wallets/{address}/stats | 5 | 0 | 5 |
getNFTCollectionStats | /nft/{address}/stats | 5 | 0 | 5 |
getNFTTokenStats | /nft/{address}/{token_id}/stats | 5 | 0 | 5 |
getTokenOwners | /erc20/{token_address}/owners | 10 | 0 | 2 |
getTokenStats | /erc20/{address}/stats | 5 | 0 | 5 |
getBlockStats | /block/{block_number_or_hash}/stats | 5 | 0 | 5 |
getWalletNetWorth | /wallets/{address}/net-worth | 50 | +50 CUs per chains | 5 |
getWalletHistory | /wallets/{address}/history | 15 | 0 | 3 |
Query Parameters
In addition to having compute units charged on each API request, there are additional query parameters that cost additional compute units when added to an API request.
Query parameter | CU Cost |
---|---|
include=internal_transactions on /{address} | 5 |
include=internal_transactions on /transaction/{transaction_hash} | 3 |
include=internal_transactions on /block/{block_number_or_hash} | 10 |
media_items=true | 2 |
include=percent_change on /erc20/prices | 5 |
How to Check Compute Units?
To check the latest compute units of our API offerings, you can use endpointWeights to do so.
- index.js (JavaScript)
- index.ts (TypeScript)
const Moralis = require("moralis").default;
await Moralis.start({
apiKey: "YOUR_API_KEY",
// ...and any other configuration
});
const response = await Moralis.EvmApi.utils.endpointWeights();
console.log(response?.toJSON());
import Moralis from "moralis";
await Moralis.start({
apiKey: "YOUR_API_KEY",
// ...and any other configuration
});
const response = await Moralis.EvmApi.utils.web3ApiVersion();
console.log(response?.toJSON());
Your output for the API request will be as follows:
[
{
"endpoint": "getBlock",
"path": "/block/{block_number_or_hash}",
"price": 5,
"rateLimitCost": 5
},
{
"endpoint": "getContractEvents",
"path": "/{address}/events",
"price": 2,
"rateLimitCost": 2
},
{
"endpoint": "getTransactions",
"path": "/transaction/{transaction_hash}",
"price": 1,
"rateLimitCost": 3
}
]
where price
refers to how much CU does the API request cost in terms of billing and rateLimitCost
refers to how much CU does the API request cost in terms of rate limits.
Streams and Compute Units
For Moralis Streams, it is important to note that each record has a fixed cost of 15 Compute Units.
You can read the article Records and Pricing to understand how records play a crucial role in the Streams API, allowing you to make the right decisions regarding usage and pricing.