【问题标题】:sending signTransaction with web3.js. but I can't confirm this transaction in ganache使用 web3.js 发送 signTransaction。但我无法在 ganache 中确认这笔交易
【发布时间】:2020-12-06 23:46:02
【问题描述】:

我想把数据放到rawTransaction中,然后发送给ganache本地节点的智能联系人。 顺便说一句,我使用数据进行的原始交易已创建,但我在 ganache 上看不到交易。你为什么这样做?

const Web3 = require('web3');
let web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:7545/'));
const Accounts = require('web3-eth-accounts');

let user_addr = "dummy addr"
let user_cash = "dummy cash"
let userInfo = [user_addr, user_cash];
let payment_user = web3.utils.toHex(userInfo);
console.log(payment_user);


web3.eth.accounts.signTransaction({
    from: "0xa22b061113adf71a54E9a12F7480256D8C342d8F",
    to: '0xEf938B9eCC089D47BAA7B4582Cdb69C526bfD827',
    value: '10000',
    gas: 200000,
    data: payment_user
}, '052607c87473b31777d0f208021da7b68949f0b02b09bcecb0248198dbed765d');

结果:

 messageHash: '0x4a2dbabb5a7a8e16102fef48f5f1e2154c266c14c3095033d5b3c496bc179e13',
  v: '0x0a95',
  r: '0xc01ea799c002a1eac82bd0aa1856ae5f86f6a74c6985ac74695fedcf55a755c3',
  s: '0x200fdb3e4f6013e9dcc9ed47ae28e0b95a7837498c9e173734312b616629a827',
  rawTransaction: '0xf884158504a817c80083030d4094ef938b9ecc089d47baa7b4582cdb69c526bfd8278227109b5b2264756d6d792061646472222c2264756d6d792063617368225d820a95a0c01ea799c002a1eac82bd0aa1856ae5f86f6a74c6985ac74695fedcf55a755c3a0200fdb3e4f6013e9dcc9ed47ae28e0b95a7837498c9e173734312b616629a827',
  transactionHash: '0xa71361fed8d1cb69cc67e801aa118a151ec50bcf3f1b95053af7258265e151c5'

ganache(这些交易基于智能合约部署):

enter image description here

【问题讨论】:

    标签: ethereum solidity truffle web3js ganache


    【解决方案1】:

    在您的 js 文件中没有任何代码可以发送交易。您所做的只是使用私钥签署了交易。您可以使用web3.eth.sendSignedTransaction 发送。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-22
      • 2019-10-25
      • 2023-02-12
      • 2023-01-13
      • 2022-11-11
      • 2018-10-01
      • 2018-09-22
      • 2019-12-05
      相关资源
      最近更新 更多