Skip to content

Instantly share code, notes, and snippets.


Created Jul 18, 2016
What would you like to do?
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at
A joint account multisig wallet. Highly simplified only for learning purpose.
If you are looking for a strong multisig wallet contract for production, visit
contract JointAccount {
//Create 2 joint owners of the account.
address accountWindows = 0xa1dC3Cf881DbCc9B167D590545F023Ad050907B8;
address accountUbuntu = 0x6E22dc2F17962dcE7f8e6c5D12654403A0395821;
struct Transaction{
address to; //address to which ethers will be withdrawn
uint value; //Amount of ethers to be withdrawn
bytes data; //some data that you would like to send
bool confirmedByWindows; //Confirmation by 1st owner
bool confirmedByUbuntu; //Confirmation by 2nd owner
mapping (bytes32 => Transaction) pendingTransactions; //This is where we will keep the list of our pending Transactions
//Create some events to notify you of the activities. You will be able to see them in mist wallet
event RequireConfirmtion(bytes32 pendingTransactionHash, address to, uint256 value, bytes data);
event ConfirmedTransaction(bytes32 pendingTransactionHash, address to, uint256 value, bytes data);
event TransactionConfirmationFailed(bytes32 pendingTransactionHash, address to, uint256 value, bytes data);
//Withdraw ethers
function withdraw(address _to, uint256 _value, bytes _data) returns (bytes32 _withdrawalHash){
_withdrawalHash = sha3(, block.number);
if(pendingTransactions[_withdrawalHash].to == 0) {
pendingTransactions[_withdrawalHash].to = _to;
pendingTransactions[_withdrawalHash].value = _value;
pendingTransactions[_withdrawalHash].data = _data;
//The owner who starts the transaction confirms it for himself
if(msg.sender == accountWindows) {
pendingTransactions[_withdrawalHash].confirmedByWindows = true;
} else if(msg.sender == accountUbuntu) {
pendingTransactions[_withdrawalHash].confirmedByUbuntu = true;
RequireConfirmtion(_withdrawalHash, _to, _value, _data);
function confirmWithdrawal(bytes32 _confirmationHash) returns(bool confirmation) {
Transaction tr = pendingTransactions[_confirmationHash];
if(msg.sender == accountUbuntu) {
tr.confirmedByUbuntu = true;
} else if(msg.sender == accountWindows) {
tr.confirmedByWindows = true;
//check if confirmed by both the owners
if(tr.confirmedByUbuntu && tr.confirmedByWindows) {
bool withdrawal =; //Send the ethers
if(withdrawal) {
ConfirmedTransaction(_confirmationHash,, tr.value,;
delete pendingTransactions[_confirmationHash]; //Free up the storage on EVM
} else {
TransactionConfirmationFailed(_confirmationHash,, tr.value,;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.