Transactions & Fees
getLatestBlockhash
Returns the latest blockhash
Parameters
Response
Code Examples
Basic Request
Using web3.js
Using Python
Notes
- This method returns the latest blockhash and how long it will be valid for
- Replaces the deprecated
getRecentBlockhash
method - The blockhash is used for transaction processing and deduplication
- The blockhash is valid until the specified lastValidBlockHeight is reached
- Different commitment levels can be specified for the response
Best Practices
- Use blockhash for transaction submission and signing
- Monitor lastValidBlockHeight to determine blockhash validity
- Refresh blockhash if lastValidBlockHeight is reached or exceeded
- Handle network errors and retry when appropriate
- Cache the blockhash for multiple transactions within its validity period