Here are my declarations and code:

struct Key
    bytes32 blindedKey;
    uint deposit;
    address player;
    bool revealed;
mapping(address => Key[]) public keys;

function seating(bytes32 _blindedKey)
    //each player gives hash verifies key later
        blindedKey: _blindedKey,
        deposit: msg.value,
        player: msg.sender,
        revealed: false

The function seating has more to it as well. I am trying now to call a specific entry from another function. I'd like it to be, for example, the second msg.sender's address (player). So I am trying something like keys[2].player which is seemingly wrong but might give an example of what I am looking for.

Typically I pull the information up like this: var key = keys[msg.sender][0];

And can use: key.player but how do I specify the 2nd key.player etc.


  • I deleted this because I realized there might be different solutions but I think I actually need help. the keys[msg.sender].push(Key is a relic from the blind auction example, but I leave it in because it may become useful as the contract evolves. It allows for the same player to make multiple entries-it's purpose was to allow each player to input false entries with the real ones. I will have each player only able to make 1 entry, and so there should be an array of sorts mapping their keys to positions in Key[] but I only get errors when I try things like Key[i]
    – JTicker12
    Commented Mar 12, 2016 at 21:40
  • Also I think I might be able to use and array here and I'm not sure what is better. I can create an array that anytime a player successfully enters a choice through keys I can push an entry into the array. This just means I'll have update the array in other functions in case a player leaves the game. Not confident on the syntax but ill play around with it.
    – JTicker12
    Commented Mar 12, 2016 at 22:20

1 Answer 1

var key = Key(_blindedKey, msg.value, msg.sender, false);
keys[msg.sender] = key;

You can also save some space by not keeping msg.sender in Key as it is already the map key.

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.