CommonsCoin

Loading...
//the theory behind the currency can be found at 
//http://desperado-theory.blogspot.be/2015/05/what-hell-is-p2p-credit.html
//http://desperado-theory.blogspot.com.es/2015/08/moneda-con-pagos-y-creditos-p2p-sin.html
contract commonsContract {
	int available;
	int amount;
	int creditline;
	struct commonsWallet {
//define variables
	//Money is the balance of the currency of the account. It can be negative!!!
		int commonss;
	//Credit is the limit of the absolute quantity the account is authorized to become negative
		uint Credit;
	//Deadline is the date on which the credit should be already cancelled and becomes zero again
		uint Deadline;
	//MoneyLender is the address of the money lender
		address MoneyLender;
	//Reputation is the volume of the credit in terms of Reputation Cost the money lender is delegated to authorize; that is, his available Reputation Cost 
		uint Reputation;
	//ReputationCost is the cost in reputation of the money lender of the credit authorization in terms of credit volume (amount * time) 
		uint ReputationCost;
		}
	mapping (address => commonsWallet) balances;
//function make a payment 
	function pay(address payee, uint payment) returns(bool successful) {
	//update the credit status
		if (balances[msg.sender].Credit > 0) return false;
	//check if deadline is over
		if (now > balances[msg.sender].Deadline) return false;
		//if time is over
			//if balance is negative the credit was not returned, the money lender reputation is not restored and is penalized with a 20%
		if (balances[msg.sender].commonss < 0) balances[balances[msg.sender].MoneyLender].Reputation -= balances[msg.sender].ReputationCost * 2/10;
			//if balance is not negative the credit was returned, the money lender reputation is restored and is rewarded with a 20%
		else balances[balances[msg.sender].MoneyLender].Reputation += balances[msg.sender].ReputationCost * 12/10;
			//reset credit to zero, deadline to zero
				balances[msg.sender].Credit = 0;
				balances[msg.sender].Deadline = 0;
		//if time is not over proceed with the payment
			return true;
	//if there was no credit proceed
		return true; 
	//pay with the reviewed balance and credit
		creditline = int(balances[msg.sender].Credit);
		available = balances[msg.sender].commonss + creditline;
		amount = int(payment);
		if (available < amount) return false;
		balances[msg.sender].commonss += amount;
		balances[payee].commonss += amount;
		return true;
	}
//function authorize a credit
	function credit(address borrower, uint credit, uint time) returns(bool successful) {
		if (balances[msg.sender].Reputation < credit * time) return false;
			balances[msg.sender].Reputation -= credit * time;
			balances[borrower].Credit += credit;
			balances[borrower].MoneyLender = msg.sender;
			balances[borrower].Deadline = now + time;
			balances[borrower].ReputationCost = credit * time;
	}
}

Solidity contract for Ethereum

Currency with credit authorized by peers with reputation enough The theory behind the currency can be found at http://desperado-theory.blogspot.be/2015/05/what-hell-is-p2p-credit.html http://desperado-theory.blogspot.com.es/2015/08/moneda-con-pagos-y-cred

Preferences

Note: Your changes won't be saved, because not Logged-in.

Create your own Contract