Zeppelin OS - another step towards secure smart contracts

    Ethereum is now one of the most popular platforms for creating decentralized applications, which is actively developing. One of the innovations of Zeppelin we will try today with our own hands. And for those who are in the "tank", Zeppelin is a company that develops and verifies the security of smart contracts. The smart contract library OpenZeppelin is their most famous product. 



    It turned out that the development tools for Solidity are still evolving, sometimes not allowing developers to use the full power of smart contract technology. For example, the limitation is “standard libraries”, since each time an existing code is reloaded onto the network, which leads to an increase in the cost of “deploying” code and the number of potential errors. All this leads to significant limitations in creating large and multifunctional decentralized applications.


    What is zeppelin OS?




    Zeppelin OS is an open source platform consisting of tools and services over EVM, designed to develop and manage decentralized applications. 


    The Zeppelin team identified the four most important components, some of which are already implemented and available for use.


    • Zeppelin OS Kernel is a community-updated “core” platform. It consists of a set of libraries in the blockchain, which developers can connect to their projects. The pioneer was OpenZeppelin, which is already available for use. 
    • Zeppelin OS Scheduler will allow contracts to request an asynchronous execution of a function, and will also enable any participant to pay for gas expenses, receiving a reward for this.
    • Zeppelin OS Marketplace is an important component of the interaction between contracts and applications, a kind of App Store / Google Play for the blockchain. Allows you to use other services to create more complex applications.
    • Zeppelin OS off-chain tools - a set of tools for working and analyzing decentralized applications.

    Time to try it yourself!


    I really wanted to start working with Zeppelin OS, write the first contract and update it. Check whether everything is in fact and not deceived by the developers.


    Therefore, leaving the device updated storage and proxies for future articles, we move on to the already implemented functionality.


    All Zeppelin OS documentation can be found here . First you need to install zos: 


    $ npm install --global zos

    Now create a project directory and everything you need for it:


    $ mkdir zostest && cd zostest
    $ npm init
    $ zos init zostest

    After that, all the necessary configuration files will be created, so now you can proceed to writing contracts. As a test contract, let's write a small "variable repository":


    pragma solidity 0.4.24;
    import"zos-lib/contracts/migrations/Migratable.sol";
    contract SimpleStorage is Migratable {
        uint storedData;
        functioninitialize(uint256 _x) isInitializer("SimpleStorage", "0") public{
            storedData = _x;
        }
        functionget() publicconstantreturns (uint) {
            return storedData;
        }
    }

    Compile and add our contract:


    $ zos add SimpleStorage



    We start a test network (in a separate terminal):


    $ npx ganache-cli --port 9545

    Push into our local network, while creating a new configuration file zos.local.json:


    $ zos push --network local



    Things are going well, it remains to create our renewable contract, simultaneously launching initialize()with argument 88 for our “repository”:


    $ zos create SimpleStorage --init initialize --args 88 --network local



    Now let's try to add the function of increasing the variable in the “storage”, for example, the following:


    pragma solidity 0.4.24;
    import"zos-lib/contracts/migrations/Migratable.sol";
    contract SimpleStorage is Migratable {
        uint storedData;
        functioninitialize(uint256 _x) isInitializer("SimpleStorage", "0") public{
            storedData = _x;
        }
        functionincrementStorage(uint256 _x) public{
            storedData += _x;
        }
        functionget() publicconstantreturns (uint) {
            return storedData;
        }
    }

    After that, you need to update the contract on the network:


    $ zos push --network local



    $ zos update SimpleStorage --network local



    Now you can see what happened. To do this, use truffle console:


    $ npx truffle console --network=local
    truffle(local)> sS = SimpleStorage.at(<proxy-address>)

    And <proxy-address> you can look in zos.local.json the corresponding column, and check that there we have in the "repository" and whether we can increase the variable:




    Everything works great, there are many opportunities for testing contracts. I would say that Zeppelin OS can be used as a development tool for sure. 


    What have we done?


    We have verified that using Zeppelin OS you can deploy, update, compile and test contracts. It seems to be a great tool for those who like to work with the command line, and from Remix in the browser shudders. Plus, we can recommend starting acquaintance with Solidity and smart contracts with this project.


    Also popular now: