Skip to content

Instantly share code, notes, and snippets.

@eddieoz
Forked from anonymous/Assinatura1
Last active November 24, 2015 22:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddieoz/a88dafcec73ba0e2dd73 to your computer and use it in GitHub Desktop.
Save eddieoz/a88dafcec73ba0e2dd73 to your computer and use it in GitHub Desktop.
Created using soleditor: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://chriseth.github.io/browser-solidity?gist=
/*
Contract Manual:
Begin with document name (hash) and signers:
var _docHash = "abcd-1234" ;
var _signers = ["0xdcdb59990a6115b062a3a98f985a21170fa11588","0x7855d719c027691a0e79300209ff532547f68afa"];
Start contract sending 900000000000000000 weis per signer to the contract.address
eth.sendTransaction({from: eth.accounts[1], to: assinatura.address, value: 18000000000000000, gas:1000000})
Signing:
Send 1 Finney to the address Contract
eth.sendTransaction({from: eth.accounts[3], to: assinatura.address, value: web3.toWei(1,"finney")})
You can create any function
to change this contract, like allowing specific rules for the issuance,
destruction and freezing of any assets. This contract is intended for
educational purposes, you are fully responsible for compliance with
present or future regulations of finance, communications and the
universal rights of digital beings.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org>
*/
contract Assinatura {
//uint storedData;
Document public document;
Token public token;
Funder[] public funders;
uint public amountRaised;
uint256 public fundingGoal;
address public chairperson;
address public ownAddress;
mapping(address => bool) public canSign;
mapping(address => bool) public signed;
event Transfer(address indexed from, address indexed to, uint256 value);
event FundTransfer(address backer, uint amount, bool isContribution);
struct Document {
string docHash;
address[] signers;
bool signed;
}
struct Token {
string name;
string symbol;
uint8 decimals;
}
struct Funder {
address addr;
//uint amount;
}
function () {
var _sender = msg.sender;
var _canSign = canSign[msg.sender];
// Check if the signer has privileges to sign
if (canSign[msg.sender] ) {
signed[msg.sender] = true;
//uint amount = msg.value;
//amountRaised += amount;
//funders[funders.length++] = Funder({addr: _sender, amount: amount});
funders[funders.length++] = Funder({addr: _sender});
if(executeDoc()) document.signed = true;
}
// Give rights to sign and funds signers with necessary Finney to send 1 Finney back
if (_sender == chairperson ){
for (uint i=0; i < document.signers.length; ++i){
canSign[document.signers[i]] = true;
document.signers[i].send(9000000000000000);
}
}
}
function Assinatura( string _docHash, address[] _signers ) {
address sender = msg.sender;
chairperson = sender;
ownAddress = this;
document.docHash = _docHash;
document.signers = _signers;
document.signed = false;
fundingGoal = _signers.length;
// Token use
token.name = _docHash;
token.symbol = "My";
token.decimals = 0;
}
// Check if the document is signed from all signers
function executeDoc() constant returns (bool ret){
if (funders.length < document.signers.length) return false;
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment