2
votes

I'm trying to deploy a smart contract to the mainnet via 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)?

The error message in remix

Thanks!

1
Can you post the call you make to deploy the contract? From my experience a simple array of string should be enough, something like: params = ["addr1","addr2"], and then you pass params as the contructor parameter.nikos fotiadis
I can't seam to upload another picture unfortunately to show it better, but it's just the Remix Deploy in the web app. In the Run section, where you enter the constructor parameters under Deploy. I'm not doing any code to deploy, just add the array into the params box under deploy.Adremalin
Can you at least post the parameter you are passing to the constructor. Of course if it is to big to post here just add ..... in the middle. I tested it and it would accept an array of addresses passed like this: ["0xca35b7d915458ef540ade6068dfe2f44e8fa733c","0x14723a09acff6d2a60dcdf7aa4aff308fddc160c"]nikos fotiadis

1 Answers

1
votes

You just need to pass in the array of addresses in double quotes. For example,

pragma solidity ^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"]

Result (notice first address shows up in the log output): enter image description here