resilience.me
  • Home
  • FAQ
  • On Indiegogo
  • News
    • Resilience protocol
    • Epiphany, march 11 2015
    • resilience-smart-wallet, June 26 2015
  • #DApp
  • Memes
  • Learn
    • How to Hack Resilience
    • My Resilience
    • My pitch in the Ethereum forum
    • A sample scenario
    • Introduction to my system
  • Story
    • Note on Profit
    • My pitch to BitNation
    • Letter: Mimetic Networks & Ecosystems of Ideas
    • My interview with CoinDesk
    • My brother explains my system
    • A brief story of Basicincome.co
    • Letter: The Singularity and P2P-Dividends
  • Videos
  • Code
    • Client >
      • resilience_me.js
      • declare_tax.js
    • Server >
      • server.js
      • swarm_redistribution.js
  • Theory
    • SKETCH: RESILIENCE protocol
    • Whitepaper: Transaction Tax
    • Whitepaper: Technologically Enhanced Basic Income
    • Introduction: The Incentive Layer
    • Basicincome.co - A Peer-to-peer Basic Income Network
    • Whitepaper: Decentralised TaxRate Governance
    • Basicincome.co - Incentive-Based Decentralized Safety Nets
  • Graph
  • Twitter
  • Client

How to Create the Resilience Protocol on Ethereum
with smart-contracts


Don't panic, it's much simpler than it looks. Contracts are divided into two parts. The first section, entitled init, is code that initializes the contract, its default parameters during instantiation if you will. That initialisation code gets run only once when the contract is created, and never again. 
Picture
init:
  # *** An Ethereum smart contract to create and update dividend pathways"
  # First, store buyer's ethereum address:
  contract.storage["BUYER"] = 0x6af26739b9ffef8aa2985252e5357fde
  # Then, store buyer's dividendRate
  contract.storage["BUYER_DIVIDENDRATE"] = msg.data[0]
  # Then, store seller's ethereum address:
  contract.storage["SELLER"] = 0xfeab802c014588f08bfee2741086c375
  # Then, create dividend pathway
  contract.storage["DIVIDEND_PATHWAY"] = msg.value
code:
  # If the account recieves dividends:
  if tx.origin == "BUYER":
    # ... then decrease the dividend pathway
    contract.storage["DIVIDEND_PATHWAY"] = (contract.storage["DIVIDEND_PATHWAY"] - msg.value)

The second part of the contract is the contract code itself, the stuff that will live forever on the Ethereum network, immutable, and backed by millions of nodes insuring it returns the expected results every time. In our case, it's a simple function that checks that the dividend pathway facilitates a dividend, and that decreases the dividend pathway with the amount that was received. 

Picture