Solidity Remix – How to Input bytes32[] on Remix?

remixsolidity

I have a constructor like so:

constructor(bytes32[] proposalNames) public {
...

How do I input values for it on deplyoment with remix? I tried ["foo", "bar"] but it said:

creation of Ballot errored: Error encoding arguments: Error: invalid
bytes32 value (arg="", coderType="bytes32", value="foo",
version=4.0.47)

Best Answer

This:

const Web3 = require("web3");

console.log(Web3.utils.asciiToHex("foo"));
console.log(Web3.utils.asciiToHex("bar"));

Gives:

0x666f6f
0x626172

So I believe that one of the following should work for you:

[0x666f6f, 0x626172]
["0x666f6f", "0x626172"]
[0x666f6f0000000000000000000000000000000000000000000000000000000000, 0x6261720000000000000000000000000000000000000000000000000000000000]
["0x666f6f0000000000000000000000000000000000000000000000000000000000", "0x6261720000000000000000000000000000000000000000000000000000000000"]