I am using brownie python script to interact with smart contract. In the smart contract there is a function which accepts string array as argument like below
function Multiple(string[] memory my_ids) public onlyOwner {
for (uint i = 0; i < my_ids.length; i++) {
performCalc(my_ids[i]);
}
}
In python I tried several ways to pass but its always giving me error. The code I used is
parser.add_argument('--mylist', type=str, help='Provide List')
Then passing to the smart contract by
if args.mylist:
Multiple(args.mylist)
The error received is
TypeError: Multiple '[troy1,troy2,troy3]' - Expected list or tuple, got str
If passed from python like ["['troy1','troy2','troy3']"]
, then error wont be there. But characters are splitted and considered as
['[', '[', "'", 't', 'r', 'o', 'y', '1', "'", ',', "'", 't', 'r', 'o', 'y', '2', "'", ',', "'", 't', 'r', 'o', 'y', '3', "'", ']', ']']
In remix IDE
If argument is given like ['troy1','troy2','troy3']
, it works