web.eth.sendTransaction不起作用

时间:2018-07-06 01:39:21

标签: typescript ethereum web3js

我正在创建以太坊示例程序,以使用Express和web3 1.0.0发送交易。

但是在解锁帐户后,未调用发送交易。

router.post('/send', async (req, res, next) => {
  // console.log(req.body)
  // const senderId = req.body.senderId
  // const receiverId = req.body.receiverId
  const senderId = '0x1C925b08ABCD86A5a157D610A283eA54B7183577'
  const senderPassword = 'e659e73d38f2f152258f824c6427ae05143393aeb3d7d273e4ddd032f4b7a40a'
  const duration = 30.0
  const receiverId = '0x6F1328bf39BD5570db3fD876ba272089592Ee225'
  const amount = req.body.amount

  web3.eth.personal.unlockAccount(senderId, senderPassword, duration).then((result) => {
    web3.eth.sendTransaction({
      from: senderId,
      to: receiverId,
      value: amount
    })
    const response = {txId: '12345678901234567890'}
    res.send(response)
  }).catch((err) => {
    res.send(err)
  })
})

我的类型文件如下所示

unlockAccount(sender: string, password: string, duration: number): Promise<string>;
sendTransaction(tx: Tx, passphrase: string): Promise<string>;

并且ganache日志屏幕是:

enter image description here

我不知道如何从这里调试。

感谢您的帮助。

0 个答案:

没有答案