Given this constructor:

function Voting(bytes32[] candidateNames) public {
    candidateList = candidateNames;

How to pass pass the value in the parameter candidateNames when I deploy the contract in remix?

enter image description here

  • 1
    What did you try? Did you try entering any value in the textbox infront of Deploy? Jun 3, 2018 at 12:57
  • yes i am giving candidateName but it gives an error.
    – Rohit Sahu
    Jun 3, 2018 at 15:09
  • Can you please update the question with what you tried and what is the error you got? Jun 3, 2018 at 15:49
  • Rohit Sahu try it by using hexadecimal notation. means to say include 0x with input. i think it'll run. so try it.
    – San Ayush
    Aug 21, 2018 at 18:25
  • Can you edit your answer and add an example of the input? Remember that the constructor parameter is an array.
    – Ismael
    Aug 22, 2018 at 3:25

1 Answer 1


If you're willing to do a little text editing, here's a mostly painless way. Make new a contract (or temporarily add the function below to this contract and pass [] to the constructor when you run it). Hardcode the candidate names (note that I set the array size to 3 since I know it for this example):

function getBytes32ArrayForInput() pure public returns (bytes32[3] b32Arr) {
    b32Arr = [bytes32("candidate1"), bytes32("c2"), bytes32("c3")];

Compile and run the function. You should get this output:


Then use a text editor to format it like this:


It's now in the proper format so that Remix will accept it in the constructor text field as bytes32[].

  • To compile this we need to tell the compiler to look in memory for the bytes array. The code would be updated like E.g. (bytes32[3] memory b32Arr) Jun 18, 2021 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.