How to get transactions by type
Prerequisites
Before getting started, make sure you have the following ready:
- Node v.14+
- NPM
Step 1: Setup Blocklens
First register your Blocklens account and get your Blocklens API Key.
Once you have your Blocklens API Key, install the Blocklens SDK in your project.
npm i blocklens-sdk
Step 2: Get transactions by type
In order to get transactions by type, Blocklens provides you a getTransactionsByType endpoint to do so.
Here you'll need a parameter: type
.
Once you've obtained the type
, you can copy the following code:
import Blocklens from "blocklens-sdk";
const blocklens = new Blocklens();
blocklens.init({ apiKey: "YOUR_API_KEY" });
const runApis = async () => {
const response = await blocklens.APTOS_MAINNET.getTransactionsByType("block_metadata_transaction");
console.log(response);
};
runApis();
Step 3: Run the script
ts-node index.ts
In your terminal, you should see the following JSON response with the data: In your terminal, you should see the following JSON response with the data blocks:
[
{
"block_height": 96067736,
"timestamp": 1695600620,
"version": 274267807,
"type": "block_metadata_transaction",
"hash": "0xda50116556f3a222cc8edbfe13bfe926b66905ecb03db1fa60a1e6831d6c3d4c",
"sender": "null",
"receiver": "null",
"function": "null",
"amount": 0,
"gas_used": 0,
"accumulator_root_hash": "0xdd9955ca438172b1d93fc2afbb81f138f849dd491246ee420bfd164a9b63f422",
"block_hash": "0xdab649c98f9e577c295e7a9eec2fc7e908aef10d6701c8e8894961b12de193ea",
"epoch": 4177,
"event_root_hash": "0x1b57c226de1bad74da15f2c793a2cd74d47a2b18b79c8fec57598a57781e4922",
"expiration_time": "2023-09-25 00:10:20",
"gas_unit_price": 0,
"max_gas_limit": 0,
"proposer": "0x48179547b95487f77214c12e2561d53531122a91e5f79ee9be968ce8185bc444",
"round": 11676,
"sequence_number": 0,
"signature": "null",
"smart_contract": "null",
"state_change_hash": "0xb12402e7e91bb8c00547525f25631444fe0749d4e01de628662ecd45da4ff478",
"success": true,
"vm_status": "Executed successfully"
},
{
"block_height": 96067738,
"timestamp": 1695600620,
"version": 274267814,
"type": "block_metadata_transaction",
"hash": "0x083d5f380dab22579ef8e478d0c4ec85ab6292ecd518f4062e9a7d92c97c3cdd",
"sender": "null",
"receiver": "null",
"function": "null",
"amount": 0,
"gas_used": 0,
"accumulator_root_hash": "0x3d3cb65b6822627e6a4ed0550720f177bc5ba3db25f36af49c86a46f122b1527",
"block_hash": "0x773290017b578fa19a2f2e83aa0c5f114238306b50434e377ad1fc6602f6549a",
"epoch": 4177,
"event_root_hash": "0x40d8588ff5435e7a9d52f146511372e4a788e5cae595264ef2729dacea168b37",
"expiration_time": "2023-09-25 00:10:20",
"gas_unit_price": 0,
"max_gas_limit": 0,
"proposer": "0x48179547b95487f77214c12e2561d53531122a91e5f79ee9be968ce8185bc444",
"round": 11678,
"sequence_number": 0,
"signature": "null",
"smart_contract": "null",
"state_change_hash": "0x0d1c536eb49a9492059bb954254e5b9876799ab85143c6ade6b63d6a49264d43",
"success": true,
"vm_status": "Executed successfully"
},
{
"block_height": 96067753,
"timestamp": 1695600624,
"version": 274267857,
"type": "block_metadata_transaction",
"hash": "0xb7985cc6616518c9015ce8c3ac0272587ece404cfe761a809ad1640857a3d524",
"sender": "null",
"receiver": "null",
"function": "null",
"amount": 0,
"gas_used": 0,
"accumulator_root_hash": "0x1c7f2e7f8393af209b12d03e212a665f89dd50ff4654c4b89d8a46c446f01260",
"block_hash": "0x793e217cb9d37222108a750c3adf84409df5da56fc6b0c69aa4a37a5aa6d9278",
"epoch": 4177,
"event_root_hash": "0x626485c29ccaddeaa04c524a43b03a99c391f1f5061722a065743b2b18844b29",
"expiration_time": "2023-09-25 00:10:24",
"gas_unit_price": 0,
"max_gas_limit": 0,
"proposer": "0x189093e65faaea1d0c1c367b7c78b4d2ea569fc3d1e7d20b226eec0361b1a116",
"round": 11693,
"sequence_number": 0,
"signature": "null",
"smart_contract": "null",
"state_change_hash": "0xc99b94fabd6c2f7bcc56588141981888c2d81fa243f3385d1237a131db9cb939",
"success": true,
"vm_status": "Executed successfully"
},
{
"block_height": 96067766,
"timestamp": 1695600632,
"version": 274267917,
"type": "block_metadata_transaction",
"hash": "0xd633887ff274e9a5ab512987c3849ad10fb95af1899565c6adac3981a9d994b7",
"sender": "null",
"receiver": "null",
"function": "null",
"amount": 0,
"gas_used": 0,
"accumulator_root_hash": "0xea21e35ba8dfbbb8011d0974cbbedb0ab97101f6c187c88acc6263cb8a729203",
"block_hash": "0x36581980505da137c3e4ace0571560c318ddfe749684229b01b2a619854b54a4",
"epoch": 4177,
"event_root_hash": "0x94c8ea01fed0f71264347a4b8be8e5a237eb931a86ed39f37cd3ccf1474c26f3",
"expiration_time": "2023-09-25 00:10:32",
"gas_unit_price": 0,
"max_gas_limit": 0,
"proposer": "0xe8fac9c24a3bfc71ed79d466fa3c2c2b4787f1f9686e1d1e9e97fde473898788",
"round": 11707,
"sequence_number": 0,
"signature": "null",
"smart_contract": "null",
"state_change_hash": "0x1781c1fe083468d540381bfbedc259c78aa29fdc2079b28b7141bfef5066a88f",
"success": true,
"vm_status": "Executed successfully"
},
{
"block_height": 96067769,
"timestamp": 1695600634,
"version": 274267929,
"type": "block_metadata_transaction",
"hash": "0xfe00d7c16045dcb33d1beb46b84fa0a6419aaaf0e3c1c703f87fbfc3cf96b243",
"sender": "null",
"receiver": "null",
"function": "null",
"amount": 0,
"gas_used": 0,
"accumulator_root_hash": "0xa2fd174e4d5cc0c962f5d5c54ae2e1ea5cd8d0d5a7efceb3c215cf120d32fbcf",
"block_hash": "0x686569c24f2f5e6d9d149dae4ddea3aa65b2bd5e6e6e6f2abb5d1c99b05a1b47",
"epoch": 4177,
"event_root_hash": "0x67f0d1f08e3c7502ee3656b3417107a6f3de1b6220b8e92405e7d5940e2be176",
"expiration_time": "2023-09-25 00:10:34",
"gas_unit_price": 0,
"max_gas_limit": 0,
"proposer": "0x550fe3956e44112599b8410404e0977e74cc5bcb59a11b0706da734cd0f9beb2",
"round": 11710,
"sequence_number": 0,
"signature": "null",
"smart_contract": "null",
"state_change_hash": "0x0df9ae21cccf1f46360f132803ba2473a02ab7316aee3ed24e07be23a5b28326",
"success": true,
"vm_status": "Executed successfully"
},
{
"block_height": 96067790,
"timestamp": 1695600639,
"version": 274267991,
"type": "block_metadata_transaction",
"hash": "0xb64d6dd1a0e507c41977f03ad2893368dbf20a52742439368c422ed0a8822341",
"sender": "null",
"receiver": "null",
"function": "null",
"amount": 0,
"gas_used": 0,
"accumulator_root_hash": "0x8bffe5e1aea3cd4befedde8a0e25b0ae1f143c54a95adf9af74b5e44555ce223",
"block_hash": "0x2b105681efe1f0bca0a6688d180986661bb2d37f3e3df4d2af0841f20e3c1f6a",
"epoch": 4177,
"event_root_hash": "0x7662f3a5307ad726f260eb9cd563c821dea84f731599c7fc1dfb5da9420b11f2",
"expiration_time": "2023-09-25 00:10:39",
"gas_unit_price": 0,
"max_gas_limit": 0,
"proposer": "0x189093e65faaea1d0c1c367b7c78b4d2ea569fc3d1e7d20b226eec0361b1a116",
"round": 11731,
"sequence_number": 0,
"signature": "null",
"smart_contract": "null",
"state_change_hash": "0xe52b24d729779f36385616c7e728a4a0183e7d22f5e4026150d816f7a873352d",
"success": true,
"vm_status": "Executed successfully"
},
{
"block_height": 96067803,
"timestamp": 1695600642,
"version": 274268030,
"type": "block_metadata_transaction",
"hash": "0x7b29edabc7dd6c0dd85622a87c53fd836bd9925273df990f79ed693498ec07af",
"sender": "null",
"receiver": "null",
"function": "null",
"amount": 0,
"gas_used": 0,
"accumulator_root_hash": "0xf668866e78ff052498a5b16a78d60336aeee297bb4acc19f691cd695d5dfb562",
"block_hash": "0xd091fd17540fec4a857daf00b4e78f0c9b1eda44f6493180c6f01e7808a6c369",
"epoch": 4177,
"event_root_hash": "0x1cc3c3310a494fb472f833a998b82f5aea57ae80e1192f00c296f7151987b08e",
"expiration_time": "2023-09-25 00:10:42",
"gas_unit_price": 0,
"max_gas_limit": 0,
"proposer": "0x9da88926fd4d773fd499fc41830a82fe9c9ff3508435e7a16b2d8f529e77cdda",
"round": 11744,
"sequence_number": 0,
"signature": "null",
"smart_contract": "null",
"state_change_hash": "0xdf4ea6c1e5530d43575c5d53ab9c6a38334ef32c7fb1a65f396bb54d40bb9def",
"success": true,
"vm_status": "Executed successfully"
},
{
"block_height": 96067808,
"timestamp": 1695600643,
"version": 274268051,
"type": "block_metadata_transaction",
"hash": "0x55e44000e3910a045a476ac473afb20269d9f67f16174acdd3bf20ff2da9322b",
"sender": "null",
"receiver": "null",
"function": "null",
"amount": 0,
"gas_used": 0,
"accumulator_root_hash": "0x96a2e21303ff455317e978c03bb10feb3f942523d08137aef2ed8e731a898a0b",
"block_hash": "0xd6165ca62dd8b67a74a4f85b1ada573f63777cd0829ffa4faf20ae1d13f35f07",
"epoch": 4177,
"event_root_hash": "0xd658a8d676270dc6aa96c8634dcb95b2be4b88da231c4e42b79b68e9a38123ec",
"expiration_time": "2023-09-25 00:10:43",
"gas_unit_price": 0,
"max_gas_limit": 0,
"proposer": "0xf05d2fe6618a3cb4258e94f2da24c1ee71ae4e7942b4f8b5836ad5267e59568f",
"round": 11749,
"sequence_number": 0,
"signature": "null",
"smart_contract": "null",
"state_change_hash": "0xf564cce996af8be00b5ac46cd75f38f6f5ee050af7b48d2e8c4a009ff0672190",
"success": true,
"vm_status": "Executed successfully"
},
{
"block_height": 96067820,
"timestamp": 1695600646,
"version": 274268089,
"type": "block_metadata_transaction",
"hash": "0x1056101541fe73b05788878460203715837a4a4b717ebbaef152148757e4be85",
"sender": "null",
"receiver": "null",
"function": "null",
"amount": 0,
"gas_used": 0,
"accumulator_root_hash": "0xf37d8a59d7f24065f0515a3a4ee3fc6a2bf46bf32c22e56b82cf8031adbfe360",
"block_hash": "0xfda76274d72b9b157ecae3e97149db7ed013beb6b79bd083bff23d71f3da1988",
"epoch": 4177,
"event_root_hash": "0x0588c633d42d3410296bbf15277bc5d95c46f5ae677c5f422c4f076305b67b24",
"expiration_time": "2023-09-25 00:10:46",
"gas_unit_price": 0,
"max_gas_limit": 0,
"proposer": "0x48179547b95487f77214c12e2561d53531122a91e5f79ee9be968ce8185bc444",
"round": 11761,
"sequence_number": 0,
"signature": "null",
"smart_contract": "null",
"state_change_hash": "0x8ec2349fc9284f8543e333406800f1c314f88d62734d3103217b6667aaac9e8c",
"success": true,
"vm_status": "Executed successfully"
},
{
"block_height": 96067824,
"timestamp": 1695600647,
"version": 274268100,
"type": "block_metadata_transaction",
"hash": "0xdea9d1a02eb79fa3736ebab51207db46a467fad3cc00bda241221bd76516bca1",
"sender": "null",
"receiver": "null",
"function": "null",
"amount": 0,
"gas_used": 0,
"accumulator_root_hash": "0xb0aa4b0c0c82253a0f7356de31cb241544a57b7060b3217aedd6723da74d9b2e",
"block_hash": "0xc40bdfb0e604930c7de41b305a66681fda9c60f54239435ccc68238f127c8ff3",
"epoch": 4177,
"event_root_hash": "0x9502c84cbf7604678eebd36537a1434306fb8f36d4c6c4f1350922799549f563",
"expiration_time": "2023-09-25 00:10:47",
"gas_unit_price": 0,
"max_gas_limit": 0,
"proposer": "0x947c6451ad9a8659cba4e60a6da41086eb66e73fc07936bd3b7044873b5e094d",
"round": 11765,
"sequence_number": 0,
"signature": "null",
"smart_contract": "null",
"state_change_hash": "0x1554f1b3e8ad38b8a172d6bedea1dd81ab1bfbeb75f8609246a2202a1dc25b08",
"success": true,
"vm_status": "Executed successfully"
}
]
Congratulations 🥳 you just found the get transactions by type on multiple chains with only a few lines of code using the Blocklens Wallet API!
API Reference
If you want to know more details on the endpoint and optional parameters, check out:
Support
If you face any trouble following the tutorial, feel free to reach out to our community engineers in our Discord or Forum to get 24/7 developer support.