【问题标题】:I am having error : "Inbox" -- Invalid number of parameters for "undefined". Got 0 expected 1我遇到错误:“收件箱”-“未定义”的参数数量无效。得到 0 预期 1
【发布时间】:2022-01-25 04:36:48
【问题描述】:

我正在编写一个简单的智能合约,即“inbox.sol”。我正在使用 truffle 框架来测试并使用 Infura API 将其部署到 rinkeby 网络。我有这个错误。请帮忙。我是初学者。

This is deployed contract in migration

This is my smart contract code

error i got

【问题讨论】:

  • 显然需要设置一个构造函数参数
  • 下次请分享代码而不是图片。这对想要提供帮助的人会更有帮助。

标签: blockchain ethereum solidity smartcontracts truffle


【解决方案1】:

你的合约有一个构造函数并且需要一个参数。

constructor(string memory initialMessage) public {
        message = initialMessage;
    }

因此,当您部署它时,您必须传递一个参数。

const Inbox = artifacts.require("Inbox");

module.exports = function (deployer) {
  // passing an argument 
  deployer.deploy(Inbox, "myInitialMessage");
};

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-29
    • 2021-08-22
    • 2019-08-28
    • 1970-01-01
    • 1970-01-01
    • 2020-11-07
    • 2020-11-22
    相关资源
    最近更新 更多