getBlockWithTransactions - SDK
Returns the block from the network based on the provided block number or hash. In addition to the transaction hashes included in the block, it also returns the full transaction objects.
Don’t have an API key?
Start using this method in your app today. Get started for free
Description
Returns the block from the network based on the provided block number or hash. In addition to the transaction hashes included in the block, it also returns the full transaction objects.
Parameters
Response
BlockWithTransactions
response object parameters
Example Request and Response
Prerequisite: You will need to install the Alchemy SDK before making requests with it.
The commands for installing it using npm or yarn are given below:
Request
Here is an example of how to make a getBlockWithTransactions
request using the Alchemy SDK:
Response
Use Cases
Here are some possible use cases for this method:
-
Blockchain Explorer: When building a blockchain explorer, it is important to be able to retrieve detailed information about blocks and their transactions.
getBlockWithTransactions
can be used to fetch this information and display it to users. -
Smart Contract Verification: When verifying the correctness of a smart contract execution, it may be necessary to retrieve the block and its transactions that triggered the execution.
getBlockWithTransactions
can be used to fetch this information and verify that the smart contract executed correctly. -
Payment Processing: When processing payments on a blockchain, it may be necessary to retrieve the block and its transactions that confirm the payment.
getBlockWithTransactions
can be used to fetch this information and confirm that the payment was successfully processed.
Related Methods
Here are the methods related to getBlockWithTransactions
:
- getBlock: Returns the block from the network based on the provided block number or hash.
- getBlockNumber: Returns the result of executing the transaction, using call.