I have a basic contract which I run in remix. I'm using it to test different random algorithms. Unfortunately, when I have an array of 300-400 addresses and I run the 'selectParticipant' function, it takes a while to load (mining transaction) then it simply crashes. No message, it just refreshes everything, deletes my code and sends me back to ballot.sol
pragma solidity ^0.4.17;
contract TestingRandom{
address public theCreator;
address[] public participants;
uint public Secretkey1;
string public Secretkey2;
constructor() public {theCreator = msg.sender;}
function enterArray() public payable{
if (msg.value == 1 ether){
participants.push(msg.sender);}
else {if(msg.value == 2 ether){
for(int i; i<150; i++)
participants.push(msg.sender);
}}}
function key1(uint anInput) public {
Secretkey1 = anInput; }
function key2(string anInput) public {
Secretkey2 = anInput;}
function randomizer() public view returns (uint){
return uint(keccak256(abi.encodePacked(Secretkey1, Secretkey2, participants)));}
function selectParticipant() public {
randomizer() % participants.length;
participants = new address[](0);
}
}
Instructions on how to use:
1) Deploy the contract. Select gas 4000000 instead of 3000000
2) Select Value 2 ETH and call enterArray function (will place this address 150 times in the array)
3) Repeat step 2 for 3-4 times to have 450-600 entries in the array
4) Select an integer for key1 and a string for key2
5) Call 'selectParticipant' function. Remix will crash for script running too long and you will lose everything, including the code.
IMPORTANT: Everything works fine if you input less than 20-50 addresses in the array.
I have a basic contract which I run in remix. I'm using it to test different random algorithms. Unfortunately, when I have an array of 300-400 addresses and I run the 'selectParticipant' function, it takes a while to load (mining transaction) then it simply crashes. No message, it just refreshes everything, deletes my code and sends me back to ballot.sol
Instructions on how to use: 1) Deploy the contract. Select gas 4000000 instead of 3000000 2) Select Value 2 ETH and call enterArray function (will place this address 150 times in the array) 3) Repeat step 2 for 3-4 times to have 450-600 entries in the array 4) Select an integer for key1 and a string for key2 5) Call 'selectParticipant' function. Remix will crash for script running too long and you will lose everything, including the code.
IMPORTANT: Everything works fine if you input less than 20-50 addresses in the array.