Last active
August 29, 2015 14:24
-
-
Save resilience-me/2bd6d31c1352019ac22a to your computer and use it in GitHub Desktop.
resilience project ethereum-contract. for sketch of nodejs implementation, see https://gist.github.com/resilience-me/ed196ce279b083fb5182
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a first draft for an ethereum implementation of this: | |
# www.resilience.world/#!whitepaper/c21xm | |
# It's meant to be an introduction of the 'smart-wallet' concept | |
# A smart-wallet is a wallet with rules. They can be used for auto-debit, etc. | |
# Resilience Network | |
# msg.data[0] == destination | |
# msg.data[1] == amount | |
# msg.data[2] == editDividendRate | |
example_issuer = 0xef1622c663d5c4768b051b2879ea19b42f887d62 | |
# The contract stores the issuers dividendRate | |
# see http://forum.fractalfuture.net/t/voluntary-basic-incomes-in-a-reputation-economy/236/20 to learn more about dividendRates | |
dividendRate = "" | |
# The contract acts as a smart-wallet | |
if (msg.sender == example_issuer): | |
# It lets the issuer make transactions from it: | |
if (msg.data[2] == null): | |
mktx(msg.data[0], msg.data[1]) | |
# And it lets the issuer update the dividendRate | |
else | |
dividendRate = msg.data[2] | |
# The contract has Johan Nygren's Resilience protocol (http://www.resilience.world/#!whitepaper/) built in. | |
# Users send money to the contract-wallet instead of the issuers wallet. The contract acts as a bridge. | |
dividend_pathways = [] | |
// help me with the syntax here, I'll use javascript-ish examples, help me translate them: | |
// dividend pathway constructor: | |
function create_pathway(){ | |
// pseudocode: | |
// tx.sender | |
// tx.amount | |
// check if tx.sender has a dividend pathway at the current dividendRate | |
// pseudocode: | |
dividend_pathways.filter('tx.sender' && dividendRate).if(false): | |
var dividend_pathway = {address: tx.sender, dividendRate: dividendRate, amount: tx.amount} | |
dividend_pathways.push(dividend_pathway) | |
else // do update existing pathway | |
} | |
function swarm_redistribution(){ | |
// add this stuff, https://github.com/p2p-safety-net-co-op-dividend-scheme/server/blob/master/swarm_redistribution.js | |
} | |
on(tx): | |
create_pathway() | |
swarm_redistribution() | |
# The contract needs to talk to other contracts. That should be easy. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment