let multichain = require("multichain-node")({
port: 6001,
host:'localhost',
user:'myuser',
pass:'mypassword'
});
multichain.getInfo((error,info) => {
if(error){
throw error;
}
console.log(info);
})
output:version: '1.0',
nodeversion: 10000901,
protocolversion: 10008,
chainname: 'chain1',
description: 'chain1',
protocol: 'multichain',
port: 6001,
setupblocks: 60,
nodeaddress: 'mulmul@localhost:6001',
burnaddress: '1XXXXXXWh4XXXXXXXyXXXXXXZdXXXXXXYjGhfn',
incomingpaused: false,
miningpaused: false,
walletversion: 60000,
balance: 0,
walletdbversion: 2,
reindex: false,
blocks: 127,
timeoffset: 0,
connections: 0,
proxy: '',
difficulty: 6e-8,
testnet: false,
keypoololdest: 1506490805,
keypoolsize: 2,
paytxfee: 0,
relayfee: 0,
errors: '' }
此输出显示在命令提示符中,如何在浏览器中执行此代码
答案 0 :(得分:0)
multichain-node
是一个节点模块;在浏览器中运行它是没有意义的。
特别是它使用node的http模块来发出http请求;如果您想在浏览器中执行此操作,则需要使用fetch
或XMLHttpRequest
来执行此操作,并且您需要正确设置CORS。