Giter Site home page Giter Site logo

ambrosus-node-contracts's Introduction

Build Status

Ambrosus protocol

This repository contains smart contracts constituting Ambrosus protocol, in particular:

  • Smart contracts constituting Ambrosus protocol
  • Amber - ERC20 Token representing powering Ambrosus protocol
  • ICO Contribution contract

Installation and use

To add ambrosus to your project:

npm i -S ambrosus

And import to module in your application:

import ambrosus from 'ambrosus'

Architecture:

Ambrosus architecture consists of 3 main layers:

  • dependencies - to run properly Amborsus requires Ethereum and IPFS
  • smart contracts - building blocks of Ambrosus protocol
  • javascript library - that allows to create and operate Ambrosus contracts and objects

Architecture overview

All 3 parts are stored in this repository. Following is a description of 3 layers introduced above.

Smart Contracts

Smart contracts are the core of ambrosus protocol. The system of contracts is written in Solidity and compiled to EVM (Ethereum Virtual Machine). Contracts are combined together to co-operate and create services around quality assurance in food and pharma supply chains. They are abstract building blocks for different applications.

There are some basic abstractions in the protocol, including:

  • Measurements - a contract abstraction used to store measurements - a basic unit of a history of an item in supply chain
  • Requirements - a basic way to describe expectations about product in supply chain
  • Validator - a way to check if given product's history (list of measurements) meets specific validation rules (e.g. meet requirements)
  • Agreement - represents agreement between Parties, with specific rules considering product in supply chain

In a top of those abstractions are build implementations for specific use cases. They are more concrete building blocks. Examples are:

  • MeasurementsOnChain - allows measurements devices to store measurements on the Ethereum blockchain, note: this might very inefficient and therefore one should for production purposes use the following contract.
  • MeasurementsOffChain - allows measurements devices to store measurements off the blockchain, in this case on the IPFS. Measurements can be later verified using this contract on their origin (e.g. if they come from authorized devices) and completeness (if any thing is missing)
  • Range requirements - allow expressing expectations in future or past measurements

In the top of that we build more complete solutions per use case e.g.:

  • Market - a marketplace for buying and selling food. Suppliers can create profiles using their Ethereum wallets. Buyer can sellers can make agreements directly on the market.
  • DeliveryAgreement - allows parties to make a delivery agreement in the form of contract on Ethereum. Agreement uses building blocks like Requirements to define the quality standard of food agreed upon. Measurements to store information delivered by measurement devices along the way. The agreement can use escrow, so the money for the supplier is automatically released if all conditions from the agreement are met. On the other hand, the buyer can reimburse if delivered food did not meet quality standard agreed upon.

Ambrosus.js

Ambrosus comes with a javascript library that makes using protocol easy and straight forward. Eg. to create a new offer on the market on can use following code:

    let exampleOffer = {
        name: 'Tune',
        origin: 'Japan',
        category: 'Fish',
        packageWeight: 100,
        pricePerUnit: 100,
        pricePerPackage: 100,
        imageHash: 'QmWWQSuPMS6aXCbZKpEjPHPUZN2NjB3YrhJTHsV4X3vb2t', //Image hash on IPFS
        seller: ..., // Seller wallet address 
        measurementsAddress: ..., // Measurements contract address
        requirementsAddress: ..., // Requirements contract address
        validatorAddress: ..., // Validator contract address
    };

And to put in on the market:

    offerRepo = new OfferRepository(OfferContract);
    marketRepo = new MarketRepository(MarketContract);
    market = ...;
    await offerRepo.save(market.getAddress(), exampleOffer);

Or to create a new market:

    await marketRepo.create(accounts[0]);

Below is an example architecture overview for two apps build in top of Ambrosus protocol.

Example architecture overview

Detailed documentation coming soon.

Contribution

  1. Clone repository

    git clone [email protected]:ambrosus/Ambrosus.git
    cd Ambrosus
    
  2. Install global dependencies, such as Truffle (requires NodeJS 5.0+) and Testrpc, then install local dependencies:

    npm install
    
  3. Before running tests make sure testrpc is up:

    testrpc
    
  4. Running tests

    truffle test
    

Acknowledgements

Contribution and token contracts have been influenced by the work of MelonPort and by Condition-Orientated Programming approach.

ambrosus-node-contracts's People

Contributors

andrewar2 avatar barrutko avatar danihodovic avatar feedkeek avatar h-pavel avatar krzysztof-jelski avatar marekkirejczyk avatar mike-s-mike avatar seagiv avatar spherefoundry avatar tolikheha avatar v-0-0 avatar valar999 avatar vanruch avatar vitalii427 avatar vpowler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ambrosus-node-contracts's Issues

Some Useful Tools

LABEL: Feedback

I attended ETH San Francisco and took note of some new tools you might find useful in your development. I suggest you at least take a look at them. Even if you might already be aware of some similar tools, a couple of them are entirely new (1st implementation of the concept).

Real time debugger: https://devpost.com/software/0xd3bu6

Contract Analytics: https://devpost.com/software/contractiq

Another gas profiler: https://devpost.com/software/solidity-profiler

Keep up the great work!

Incorrect value of Storage Limit for Omega masternode in the contract config

uint constant public ATLAS3_STORAGE_LIMIT = 1000000;

There is incorrect value for Omega storage limit (ATLAS3_STORAGE_LIMIT). Now we have situation when storage limit for 2 Omega nodes equals to the storage limit of 5 Sigma nodes - it's incorrect. As Angel described previously in AMA:

  • 1 Sigma (30K) should have more limit storage then 3 Zetas (30K) - its CORRECT in the config now

  • 2 Omega nodes (150K) should have more limit storage then 5 Sigmas (150K) - its INCORRECT in the config now

Developers, please fix that issue.

Pools files

$ yarn task onboard
yarn run v1.22.10
$ node -r babel-register src/tasks/run.js onboard
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module './contracts/PoolsNodesManager.json'

This files shouldn't be used or empty file have to be generated in advance.

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.