Coder Social home page Coder Social logo

eosyield's Introduction

EOS Yield Contract

This contract demostrates how an EOS contract can be made immutable in a given period of time, without losing mutability forever. Such a mechanism guarantees immutability when trustlessness is necessary, with code changes possible with prior notice to users.

The intent of this contract is explained in this reddit post.

Powered by EOS Yield

The following dApps feature implementation of the Temporary Immutability pattern proposed by this contract:

  • Final Noob: A decentralized EOS game.

  • DeltaDex: A fully on-chain decentralized exchange.

Clone and Compile

To clone the repository and compile the contract into binary:

$ git clone https://github.com/xJonathanLEI/eosyield.git
$ cd eosyield
$ eosiocpp -o eosyield.wast eosyield.cpp
$ eosiocpp -g eosyield.abi eosyield.cpp

Three files: eosyield.wast, eosyield.wasm and eosyield.abi will be generated after compilation succeeds.

Contract Setup

To test the contract, first set up a contract account, say yield:

$ cleos system newaccount --buy-ram "1000.0000 SYS" --stake-net "100.0000 SYS" --stake-cpu "100.0000 SYS" eosio yield YOUR_PUBLIC_KEY;

Publish the contract:

$ cleos set contract yield /path/to/contract/folder;

Give account owner permission to eosio.code permission so that the contract itself can modify its own permission settings:

$ cleos set account permission yield owner '{"threshold": 1,"keys": [{"key": "YOUR_PUBLIC_KEY","weight": 1}],"accounts": [{"permission":{"actor":"yield","permission":"eosio.code"},"weight":1}]}' -p yield@owner;

Set the owner to be your account (jonathan here):

$ cleos push action yield setowner '["jonathan"]' -p yield@owner;

To yield control on the contract:

$ cleos push action yield yieldcontrol '[60]' -p jonathan;

If you check permission now, you would see the contract code would be the sole owner of itself:

$ cleos get account yield;

Check the yield info from database:

$ cleos get table yield yield yieldinfo;

To extend the yield period:

$ cleos push action yield extend '[120]' -p jonathan;

To regain control after the expiration is reached:

$ cleos push action yield regain '' -p jonathan;

License

This EOS contract is licensed under the MIT license.

eosyield's People

Contributors

xjonathanlei avatar

Watchers

moxi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.