Created
December 21, 2017 14:28
-
-
Save blueplanet/95527a3ba130b49cd8e45284fcef6d34 to your computer and use it in GitHub Desktop.
イーサリアムのスマートコントラクト、ビットコインのような複数署名できる? ref: https://qiita.com/blueplanet/items/1d81302f35e426e81485
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.17; | |
contract MultiVoteTransfer { | |
address[] voterAddresses; | |
mapping(address => bool) votes; | |
bool public transfered; | |
modifier onlyVoter() { | |
bool isVoter = false; | |
for (uint i = 0; i < voterAddresses.length; i++) { | |
if (voterAddresses[i] == msg.sender) { | |
isVoter = true; | |
} | |
} | |
require(isVoter); | |
_; | |
} | |
function MultiVoteTransfer(address[] _voterAddresses) public { | |
voterAddresses = _voterAddresses; | |
transfered = false; | |
} | |
function sign() public onlyVoter returns (bool) { | |
votes[msg.sender] = true; | |
bool allVoted = true; | |
for (uint i = 0; i < voterAddresses.length; i++) { | |
if (votes[voterAddresses[i]] == false) { | |
allVoted = false; | |
} | |
} | |
if (allVoted == true) { | |
// 送金処理とか | |
transfered = true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment