简体   繁体   English

主网在Remix Solidity智能合约中将地址数组部署为构造函数参数不起作用

[英]Mainnet deploying array of addresses as constructor parameter in Remix Solidity smart contract does not work

I'm trying to deploy a smart contract to the mainnet via Remix/Metamask. 我正在尝试通过Remix / Metamask将智能合约部署到主网。 I have an array of addresses for the constructor parameter and can't get the transaction accepted. 我有一个用于构造函数参数的地址数组,并且无法接受该事务。 I have tried both double quotes "" and single '' around each address. 我在每个地址周围都尝试了双引号“”和单引号“。 Anyone have an idea of how to write the array parameter so that it's interpreted as an array and not string (see picture)? 任何人都知道如何编写array参数,以便将其解释为数组而不是字符串(参见图片)?

混音中的错误消息

Thanks! 谢谢!

You just need to pass in the array of addresses in double quotes. 您只需要在双引号中输入地址数组即可。 For example, 例如,

pragma solidity ^0.4.25; 语用强度^ 0.4.25;

contract Test {
  address[] mAddrs;
  event Deployed(address indexed theaddr);

  constructor(address[] addrs) public {
    mAddrs = addrs;

    for (uint8 i = 0; i < mAddrs.length; i++)
      emit Deployed(mAddrs[i]);
  }
}

Deploy with argument set to ["0xca35b7d915458ef540ade6068dfe2f44e8fa733c", "0x14723a09acff6d2a60dcdf7aa4aff308fddc160c", "0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"] 部署参数为["0xca35b7d915458ef540ade6068dfe2f44e8fa733c", "0x14723a09acff6d2a60dcdf7aa4aff308fddc160c", "0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"]

Result (notice first address shows up in the log output): 结果(通知的第一个地址显示在日志输出中): 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM