pragma solidity ^0.4.23; contract MultiSign { uint public nonce; uint public threshold; // 满足threshold个签名即可转账 mapping (address => bool) owners; // 共同拥有人 address[] public ownersArr; // 共同拥有人地址 modifier isManager{ require( owners[msg.sender] == true); _; } //充值事件 event DepositFunds(address from, uint amount); //转账事件 event TransferFunds(address to, uint amount); constructor(uint threshold_, address[] owners_) public { require(owners_.length <= 10 && threshold_ <= owners_.length && threshold_ != 0); for (uint i=0; i<owners_.length; i++) { require(owners_[i] != address(0x0) && owners[owners_[i]] == false); owners[owners_[i]] = true; } ownersArr = owners_; threshold = threshold_; } //转账 function executeTransfer(uint8[] sigV, bytes32[] sigR, bytes32[] sigS, address destination, uint value, bytes data) isManager public{ require(sigR.length == threshold); require(sigR.length == sigS.length && sigR.length == sigV.length); bytes32 txHash = keccak256(byte(0x19), byte(0), address(this), destination, value, data, nonce); bytes memory prefix = "x19Ethereum Signed Message: 32"; for (uint i = 0; i < threshold; i++) { bytes32 prefixedHash = keccak256(prefix, txHash); address recovered = ecrecover(prefixedHash, sigV[i], sigR[i], sigS[i]); require(recovered != address(0x0) && owners[recovered] == true); } require(address(destination).call.value(value)(data)); nonce = nonce + 1; emit TransferFunds(destination, value); } function balanceOf() public view returns(uint){ return address(this).balance; } //充值 function () public payable{ emit DepositFunds(msg.sender, msg.value); } }