0

There are two contracts in my project:

  • admin groups
  • voting

Admin groups contain

mapping(uint => address[]) internal m_Admins

For example

  • [1][0] = admin #1 with level 1
  • [9][0] = admin #2 with level 9,
  • [9][1] = admin #3 with level 9,
  • etc.

Also contract contains a simple field

address[] internal m_AdminsList

which pushes on the end or removes by index a specific admin - it's just same as mapping but expressed as a list.

And voting, when it starts, I would like to send the array of admins that are allowed to process voting. The reason is when a new admin is added during active voting I would like to not allow him to give vote. I want him to be able to vote only the new voting.

How can I make a function that sends array of admins to voting contract? I can make two functions with admins count and get admin by index, but this might be gas expensive to perform a loop...

1 Answer 1

0

Try define the voting contract as follow:

contract voting is admingroup {
}

You may have used different names, but this ensures that the admingroup contract is kind of like a base contract which voting is built on. This will carry over the array. Just make sure you write the code on the same contract page using remix and first deploy the admin contract before deploying the voting contract.

I hope it helps

1
  • Thanks for the reply but I'm not sure how is this supposed to help me. You suggest to merge voting with admin group? No, it's impossible, there are many different admin groups and many different votings, both contracts are large, merging would make deployment out of gas.
    – Radek_pl
    Commented Jul 12, 2019 at 18:26

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.