Last active
August 26, 2022 00:43
-
-
Save niteshbalusu11/643f4afb364975291a92b7d81cac06e8 to your computer and use it in GitHub Desktop.
Call Bitcoin JSON RPC Using NodeJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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