Skip to content

Instantly share code, notes, and snippets.

@niteshbalusu11
Last active August 26, 2022 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niteshbalusu11/643f4afb364975291a92b7d81cac06e8 to your computer and use it in GitHub Desktop.
Save niteshbalusu11/643f4afb364975291a92b7d81cac06e8 to your computer and use it in GitHub Desktop.
Call Bitcoin JSON RPC Using NodeJS
import axios from 'axios';
try {
const username = 'rpcUser';
const password = 'rpcPassword';
const url = `http://${username}:${password}@localhost:18443`;
const postPody = {
jsonrpc: '1.0',
id: 'curltest',
method: 'getblockchaininfo',
};
const response = await axios.post(url, postPody);
const data = await response.data;
console.log(data);
} catch (error) {
console.log(error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment