Coder Social home page Coder Social logo

frankhillard / advisor-cameligo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ligolang/advisor-cameligo

0.0 1.0 0.0 367 KB

Exemple of an advisor contract in CameLIGO

License: MIT License

Makefile 15.61% Shell 0.99% JavaScript 31.07% TypeScript 11.89% LigoLANG 40.45%

advisor-cameligo's Introduction

ligo lambdas & on-chain views

This repository is meant to illustrate the communication between contracts (with on-chain views) and lambda pattern which allows to modify a contract already deployed. It deals with implementing, deploying and interacting with Tezos smart contracts.

The Fund and its advisor (i.e. "L'indice et le conseiller")

The indice contract represents a fund value and the advisor contract gives an advice on investing on this fund.

Transaction workflow

Since Hangzhou protocol, on-chain views have been introduced which replace the callback pattern to retrieve a storage of another contract.

The advisor contract can be invoked to request the fund value from the indice contract (via an on-chain view). The indice contract receives the view request and sends back the requested value. When advisor contract receives the fund value it can apply the "algorithm" to check it is worth investing ! This algorithm relies on a single indice value.

The resulting advice is stored in the storage (in result field).

Lambda pattern

The real business logic of the advisor smart contract lies in the lambda function which is defined in the storage. The storage is vowed to be modified so as for the business logic (lambda).

So an entrypoint ChangeAlgorithm is provided to modify the algorithm that computes the worth of investment.

Content

This directory illustrates the new on-chain views style and contains 2 implementations:

  • cameligo: for smart contracts implementation in cameligo and ligo command lines for simulating all entrypoints
  • jsligo: for smart contracts implementation in JSligo and ligo command lines for simulating all entrypoints

Pre-requisites

You may need to install the following tools:

  • node & npm
  • typescript compiler - npm install typescript --save-dev
  • docker

Compiling / testing / deploying

This repository provides a Makefile for compiling and testing smart contracts. One can type make to display all available rules. The make all command will clean all produced smart contracts, then compile smart contracts and then launch tests.

The make compile command triggers the compilation of smart contracts (advisor and indice).

The make test command launches tests oon compiled smart contracts (advisor and indice).

The make deploy command deploys smart contracts (depending on .env file information).

advisor-cameligo's People

Contributors

oteku avatar

Watchers

 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.