我想从react组件中通过JSON调用geth方法。我尝试过这样做,但我总是得到错误: 405 (方法不允许)
这是我的代码:
try {
const response = await axios.post('http://localhost:8501', {
jsonrpc: '2.0',
id: + new Date(),
method: 'eth_accounts',
params: {
},
}, {
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
},
})
console.log(response.data.result.address)
console.log(response.data.result.publicKey)
console.log(response.data.result.wif)
console.log(response.data.result)
} catch(error) {
console.error(error)
}这些请求必须是邮寄还是索取?
我的geth实例使用以下参数运行:
geth --datadir node1/ --syncmode 'full' --port 30311 --rpc --rpcaddr 'localhost' --rpcport 8501 --rpcapi 'personal,db,eth,net,web3,txpool,miner' --bootnodes 'enode://<enode@<127.0.0.1:30310' --networkid 1515 --gasprice '1' -unlock '0x0' --mine非常感谢你的帮助
https://ethereum.stackexchange.com/questions/65327
复制相似问题