【问题标题】:how do you send a transaction to a contract in the truffle console?如何在 truffle 控制台中向合约发送交易?
【发布时间】:2020-07-01 23:13:09
【问题描述】:

我的合同中有一个未定义的应付函数。我正在使用 genache,我的所有联系人都已迁移,并且功能按预期工作,我不知道如何从 truffle 控制台支付这份合同。我跑了

web3.eth.sendTransaction({from:"0xB5c830d954cBf18643Df7236F0BdD6d1e48087c6", to: "0xEBBd2f9ECCf86c8E635ceDff979276fCD7EaBeA0", value: 2})

但我收到以下错误

Error: Returned error: VM Exception while processing transaction: invalid opcode
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:318:1)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:208:1)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-providers-http/src/index.js:96:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:112:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-core-requestmanager/src/index.js:140:1
    at Object.ErrorResponse (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/src/errors.js:29:1)
truffle(development)> web3.eth.sendTransaction({from:"0xB5c830d954cBf18643Df7236F0BdD6d1e48087c6", to: "0xEBBd2f9ECCf86c8E635ceDff979276fCD7EaBeA0", value: 2})

如果可以的话,请帮助我。我花了好几天才弄明白

【问题讨论】:

    标签: solidity truffle


    【解决方案1】:

    也许这会有所帮助:

    https://www.trufflesuite.com/docs/truffle/getting-started/interacting-with-your-contracts#making-a-transaction

    1. 松露控制台
    2. let instance = await your-contract-name.deployed()
    3. 实例

    --> 检查你的功能...

    或者,您可以将 imo 部署到测试网 - ropsten 左右。

    【讨论】:

      猜你喜欢
      • 2021-01-13
      • 2018-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-03
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      相关资源
      最近更新 更多