npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ambrosus

v0.2.20

Published

Smart contracts building Amber protocol.

Downloads

222

Readme

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.