0

Whenever I try to get the block using the eosjs in NodeJS like in the example I get the error 'Invalid Block number or ID, must be greater than 0 and less than 64 characters'

Altho when I use other fetch methods such as the fetch from nodeos, it works just fine: https://developers.eos.io/eosio-nodeos/reference#get-block

I got the info on how to do this fetch from the eos documentation: https://eosio.github.io/eosjs/latest/reading-blockchain-examples/#get-block

const { JsonRpc } = require('eosjs');
const fetch = require('node-fetch');
const rpc = new JsonRpc('https://api.eosnewyork.io/', { fetch });

async function main() {
  try {
    let info = await rpc.get_info();
    console.log(await rpc.get_block(info.last_irreversible_block_num));
  } catch (error) {
    console.error(JSON.stringify(error));
  }
}
main();
New contributor
Roy is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
0

EOS New York disabled get_block API. Use another endpoint. You can find one from the next:

https://www.eosdocs.io/resources/apiendpoints/

Your Answer

Roy is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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