Skip to content

Instantly share code, notes, and snippets.

@elenadimitrova
Last active July 13, 2017 08:46
Show Gist options
  • Save elenadimitrova/be21ee95b8ee480086b72dd4712a4763 to your computer and use it in GitHub Desktop.
Save elenadimitrova/be21ee95b8ee480086b72dd4712a4763 to your computer and use it in GitHub Desktop.
import "EternalStorage.sol";
library ProposalsLibrary {
function getProposalCount(address _storageContract) constant returns(uint256)
{
return EternalStorage(_storageContract).getUIntValue(sha3("ProposalCount"));
}
function addProposal(address _storageContract, bytes32 _name)
{
var idx = getProposalCount(_storageContract);
EternalStorage(_storageContract).setBytes32Value(sha3("proposal_name", idx), _name);
EternalStorage(_storageContract).setUIntValue(sha3("proposal_eth", idx), 0);
EternalStorage(_storageContract).setUIntValue(sha3("ProposalCount"), idx + 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment