2

How can I access getBlocksWithLimit method using Solana-web3.js ?

When I try to access using the following method:

let get_blocks_with_limit = await connection.getBlocksWithLimit(start_slot,1);

I get the following error:

Uncaught (in promise) TypeError: connection.getBlocksWithLimit is not a function

I cant find its defnation in Web3.js file source code either.

1 Answer 1

1

getBlocksWithLimit hasn't been added to web3.js yet. PRs are welcome though!

You can probably just copy the getBlocks implementation, change the second parameter name to limit, and rename the underlying RPC call to getBlocksWithLimit.

Here's the implementation for reference https://github.com/solana-labs/solana/blob/8c47e2168e462e935b87b856b28bc9ba7ed76628/web3.js/src/connection.ts#L4932-L4947

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.