Simple systems administrating IUO contracts can be easily realized on the top of Ethereum. Let we say that accounts can issue new IOU-s that are administrated as credit and debit balance. Someone can issue an IOU to any particular account, but nobody can issue an IOU in the name of somebody else. There is a further external role for optimizing the IOU graph, for the first run optimizing only means reducing the difference of credit and debit balance for a certain node. The role can be at the moment anybody and for the activity there is an extra reward token as an incentive mechanism. A simple code is shown in the following example.
contract SimpleIOUWithOptimization {
mapping(address => uint) creditBalances;
mapping(address => uint) debitBalances;
mapping(address => uint) rewardBalances;
function issueCredit(address _to, uint _value) {
creditBalances[msg.sender] += _value;
creditBalances[_to] += _value;
}
function optimizeAccount(address _account){
if((debitBalances[_account] - creditBalances[_account]) >= 0) {
rewardBalances[msg.sender]+= debitBalances[_account] -
creditBalances[_account];
creditBalances[_account] = 0;
debitBalances[_account] -= debitBalances[_account] -
creditBalances[_account];
}
else{
rewardBalances[msg.sender] += creditBalances[_account] -
debitBalances[_account];
debitBalances[_account] = 0;
creditBalances[_account] -= creditBalances[_account] -
debitBalances[_account];
}
}
}
Certainly in this use case, the optimization could be executed right at the credit issunance, however in more complicated scenarios this might be not the option.