Coder Social home page Coder Social logo

liquid-staking-sc's Introduction

Delegator Smart Contract

The delegator smart contract is our showcase for executing other smart contracts on-chain.

It consists in total of 4 different smart contract:

  • Delegator (root): Delegates calls either to the Adder or Subber smart contract
  • Adder: Increases a value in the Accumulator smart contract
  • Subber: Decreases a value in the Accumulator smart contract
  • Accumulator: Owns a simple i32 value that can be incremented or decremented

In order to test this bundle of smart contracts you need to execute the following steps.

You can upload the contracts using our Contracts UI. If you want to test it locally, our substrate-contracts-node is an easy way to get a local smart contract chain running.

  1. Compile all contracts using the ./build-all.sh script. You will receive the respective .contract bundles for all the smart contracts in the target/ink/ folder:

    • target/ink/delegator.contract
    • target/ink/adder/adder.contract
    • target/ink/subber/subber.contract
    • target/ink/accumulator/accumulator.contract
  2. Upload the .contract bundle of Accumulator, Adder and Subber to the chain.

  3. Note down the respective code hashes of the uploaded contracts. You can copy the contract hashes from the page of uploaded contracts:
    Code Hashes Overview

  4. Instantiate the Delegator smart contract given all of the code hashes and a starting value. Make sure the endowment is big enough (if you're using our substrate-contracts-node it's 1000000). The Delegator smart contract will take over the work of instantiating the other smart contracts for you.

  5. Now you are able to run the operations provided by the Delegator smart contract. Namely delegate to delegate the call to either the Adder or the Subber to either increase or decrease the value stored in the Accumulator smart contract respectively and switch to switch the currently delegated-to smart contract. The initial delegated-to smart contract is the Adder.


    Note:
    Depending on your Substrate version you might encounter a bug with the pre-filled gas estimation of the UI and get the error ExtrinsicFailed: OutOfGas. As a workaround set the maximum allowed gas manually (e.g. to 5000).

liquid-staking-sc's People

Contributors

snowmead avatar

Watchers

 avatar

Forkers

fruitbox12

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.