Migration Guide
Summary of changes
This migration guide covers the following:
- Deprecation of
total
anddisable_total
- Changes to
getLogsByAddress
- Deprecation of
direction
ongetNFTTransfers
- Deprecation of endpoints
Deprecation of total
and disable_total
As outlined in an earlier post, we have been planning to remove the total
counts from a number of endpoints for quite some time.
As of 4th September, the total
returned on the below endpoints will no longer be returned. This also means that we deprecate the disable_total
(or disableTotal
when using the Javascript SDK) parameter. Remove this parameter from your request, and remove any usage of the total
from your code. This affects the following endpoints:
getTokenTransfers
getNFTs
getWalletNFTCollections
getNFTTrades
getNFTTransfers
getContractNFTTransfers
getNFTOwners
getTokenAddressTransfers
getWalletTokenIdTransfers
getAllTokenIds
getNFTTransfersFromToBlock
getNFTTransfersByBlock
getTokenIdOwners
getTransactions
getContractEvents
We plan to launch 5 new endpoints that will provide you with these totals. This will be launched mid-August, giving you 2-3 weeks to prepare your codebase prior to the breaking changes going live.
The endpoints are:
New: Get wallet stats
- Endpoint:
/wallets/{address}/stats
- Example response:
{
"nfts": "14",
"collections": "3",
"tokens": "4",
"transactions": {
"total": "5433"
},
"nft_transfers": {
"total": "321"
},
"token_transfers": {
"total": "2141"
}
}
New: Get NFT collection stats
- Endpoint:
/nft/{address}/stats
- Example response:
{
"total_tokens": "1000",
"owners": {
"current": "511"
},
"transfers": {
"total": "5311"
}
}
New: Get NFT token ID stats
- Endpoint:
/nft/{address}/{token_id}/stats
- Example response:
{
"owners": {
"current": "1"
},
"transfers": {
"total": "5311"
}
}
New: Get ERC20 token stats
- Endpoint:
/erc20/{address}/stats
- Example response:
{
"transfers": {
"total": "5311"
}
}
New: Get Block stats
- Endpoint:
/block/{block_number_or_hash}/stats
- Example response:
{
"nft_transfers": {
"total": "511"
}
}
Changes to getLogsByAddress
Now a topic0
must be provided when making a request to getLogsByAddress
. The topic0
is the keccak256 hash of the event signature. This signature can be found in the ABI of the contract. For example, the Transfer event signature for an ERC20 contract is: Transfer(address indexed from, address indexed to ,uint256 value)
.
Also, it is no longer possible to provide a topic1
, topic2
or topic3
in the request. If you need to filter out specific values in the logs, then you should do it in the client side, after the request is made.
Update your code in the following way:
1. You are already providing a topic0
, and no other topics in your request
No changes needed.
2. You are not providing any topic in your request
Now you need to provide a topic0
. To find this topic:
Check out the event signature in the ABI. It should look something like
Transfer(address indexed from, address indexed to ,uint256 value)
Remove the parameters from this signature so it looks like
Transfer(address,address,uint256)
. Also make sure there are no whitespaces in the string. Hash it with keccak256 (use any library that you want: web3js/ethersjs etc.):Some examples on how to get the
topic0
from the event signature using ethersJs. Many other web3/crypto libraries support similar functions.
const ethers = require('ethers');
const eventSignature = 'Transfer(address,address,uint256)';
const hash = ethers.utils.solidityKeccak256(['string'], [eventSignature]);
For example for the Transfer
event, that we showed above, we get: 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
Note: Make sure that the hash is prefixed with 0x
. If the library that you use does not include the 0x
, then make sure to manually prefix the hash with 0x
.
3. You are providing topic1
/topic
2/topic3
If you are providing any topics other than topic0
, then you should remove them from the request. If you need to filter out specific values in the logs, then you should do it in the client side, after the request is made.
4. You are using all events/logs from a contract
If you want all events/logs from a contract, you now need to make multiple calls for each topic0
. This needs to be done for all events of the contract. These events can be found in the ABI (or search via Etherscan for example). Refer to 2. on how to get the topic0
from the event signature.
Deprecation of direction
on getNFTTransfers
The direction
parameter on getNFTTransfers
is deprecated. Remove this parameter from your request, and remove any usage of the direction
from your code.
Deprecation of endpoints
The following endpoints will be deprecated:
Deprecation of getErc20Transfers
If you are using getErc20Transfers
then please start using getTokenTransfers
and/or getTokenAddressTransfers
.
Deprecation of getErc20Approvals
If you are using getErc20Approvals
for wallet approvals, then please start using getTokenAllowance
. The below example illustrates how to migrate to getTokenAllowance
Taking the following request on getErc20Approvals
:
curl --request GET \
--url 'https://deep-index.moralis.io/api/v2/0xd8da6bf26964af9d7eed9e03e53415d37aa96045/erc20/transfers?chain=eth' \
--header 'accept: application/json' \
--header 'X-API-Key: YOUR_API_KEY'
Returns the following response, and we can see that the allowance is 144999999999999999
for the contract_address
of 0xae7ab96520de3a18e5e111b5eaab095312d7fe84
.
{
"cursor": null,
"result": [
{
"token_name": "stETH",
"token_symbol": "stETH",
"token_logo": "https://cdn.moralis.io/eth/0xae7ab96520de3a18e5e111b5eaab095312d7fe84.png",
"token_decimals": "18",
"from_wallet": "0xcb1c1fde09f811b294172696404e88e658659905",
"from_wallet_label": null,
"to_wallet": "0x1111111254eeb25477b68fb85ed929f73a960582",
"to_wallet_label": "1inch v5: Aggregation Router",
"contract_address": "0xae7ab96520de3a18e5e111b5eaab095312d7fe84",
"block_hash": "0xb0bfa1a5d52ed5abc15b5dcd1e4cb351f3cc3b35d4b8c3bf4e0e91ec78d76670",
"block_number": "17654765",
"block_timestamp": "2023-07-09T07:47:59.000Z",
"transaction_hash": "0x8ddc6e9cf29aac7b5d2d42e60d6452ca1874c05ca3f44d97bdf5007bc3e5cdce",
"transaction_index": "132",
"log_index": "559",
"value": "144999999999999999",
"possible_spam": false,
"value_decimal": "0.145"
}
]
}
To get the same allowance using getTokenAllowance
, you would make the below request with the following inputs:
Path parameters:
address
=0xae7ab96520de3a18e5e111b5eaab095312d7fe84
(i.e.contract_address
from the above)
Query parameters:
owner_address
=0xcB1C1FdE09f811B294172696404e88E658659905
(i.e.from_wallet
from the above)spender_address
=0x1111111254eeb25477b68fb85ed929f73a960582
(i.e.to_wallet
from the above)
curl --request GET \
--url 'https://deep-index.moralis.io/api/v2/erc20/0xae7ab96520de3a18e5e111b5eaab095312d7fe84/allowance?chain=eth&owner_address=0xcB1C1FdE09f811B294172696404e88E658659905&spender_address=0x1111111254eeb25477b68fb85ed929f73a960582' \
--header 'accept: application/json' \
--header 'X-API-Key: YOUR_API_KEY'
When making this request, we get the following response:
{
"allowance": "144999999999999999"
}
We then see that allowance
returned mirrors value
from the getErc20Approvals
.
Deprecation of searchNFTs
, getErc20Mints
, getErc20Burns
If you are using searchNFTs
, getErc20Mints
or getErc20Burns
please remove these endpoints from your code base.