Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@augmint/js

Package Overview
Dependencies
Maintainers
4
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@augmint/js

Augmint Javascript Library

  • 0.3.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

Augmint

Augmint - Stable Digital Tokens - Javascript Library (WIP)

Build Status Discord license Greenkeeper badge

Decentralised stable cryptocurrency on Ethereum

Concept

Decentralized stablecoins targeted to fiat currencies built on Ethereum.

The first Augmint token is AEUR.

1 AEUR ≈ 1 EUR.

  • Buy and sell AEUR for ETH or EUR.
  • Get a loan in AEUR by depositing ETH.
  • Lock AEUR to earn a premium.

Try it: https://www.augmint.org

Manifesto

White Paper

augmint-js lib

This lib is heavily under construction. Anything can happen.

Install

yarn add @augmint/js

or

npm install @augmint/js

Example use

import { Augmint } from "@augmint/js";

let web3;

// Modern dapp browsers...
if (window.ethereum) {
  web3 = new Web3(window.ethereum);
  await window.ethereum.enable();
} else if (typeof window.web3 !== "undefined") {
  // Legacy dapp browsers...
  web3 = new Web3(window.web3.currentProvider);
} else {
   // no web3... augmint-js still can be used via Infura websocket connection
}

let connectionConfig;
if (web3) {
  // For connection via injected provider:
  connectionConfig = {
    givenProvider: web3.currentProvider,
    // We assume that injected Metamask/Trustwallet/Metacoin etc. provider takes care of reconnections
    ETHEREUM_CONNECTION_CHECK_INTERVAL: 0
  };
} else {
  // For connection via Infura (not passing givenProvider)
  connectionConfig = {
    PROVIDER_URL: "wss://rinkbey.infura.io/ws/v3/", // or wss://mainnet.infura.io/ws/v3/ or  ws://localhost:8545
    PROVIDER_TYPE: "websocket",
    INFURA_PROJECT_ID: "" // this should come from env.local or hosting env setting
  };
}

const augmint = await Augmint.create(connectionConfig);

// To catch errors you need to use txHash / confirmation / receipt getters:
try {

const tx = augmint.rates.setRate(CCY, rate)
  // optionally you can sign with a privatekey
  // .sign(privatekey, {from: "0x06012c8cf97BEaD5deAe237070F9587f8E7A266d"} )
  //
  // or send it if provider like MetaMask manages the signature for the given sender address
  .send([{ from: "0x06012c8cf97BEaD5deAe237070F9587f8E7A266d" }]) // {from: 0x..} only needed if it's not signed
  .onceTxHash( txHash => {.. })
  .onceReceipt( receipt => { ...})
  .onConfirmation( confirmationNumber => {...}
  .onceReceiptConfirmed(5, receipt => {...})
  .onceTxRevert( (error, receipt) => { ....});


  const txHash = await tx.getTxHash();

  // receipt as soon as we got it (even with 0 confirmation):
  const txReceipt = await tx.getReceipt();

  // receipt after x confirmation:
  const confirmedReceipt = await tx.getConfirmedReceipt(12);

} catch (error) {
  // .send / sign throwing or rejecting with sending errors but not when tx reverts!
  // Also, you need to take care of timeouts. E.g. use Augmint.utils.promiseTimeout()
 }

 // receipt you need to check for receipt.status if tx was Reverted or not.
if (confirmedReceipt.status) {
  // all good
} else {
  // this tx was reverted
}

Specs: test/Transaction.test.js

More examples

Web3.js event style

Deprecated and discouraged but kept for backward compatibility with web3js style events:

tx.on[ce]("transactionHash" | "receipt" | "confirmation" | "error");
// This way it can be easily plugged into dapps which are handling web3js tx objects:
//   augmint-js Transaction object can be a drop in as an almost direct replacement of webjs transactioObject

Specs: test/Transaction.web3jsStyle.test.js

Construct a transaction with Transaction class

It's likely not needed for ordinary augmint-js use

 const web3TxObject = rates.instance.methods.setRate(CCY, 100)
 // you can set the gaslimit here or later at send() too
 const augmintRatesTx = new Transaction(ethereumConnection, web3TxObject, { gasLimit: 200000 } );
 augmintRatesTx.send(...).onTxHash(...)  // or sign().send() etc.

augmint-cli

For local development: launch a docker container with test augmint contracts in ganache

$ yarn augmint-cli  # NB: if you are running from within the augmin-js repo then: ./scripts/augmint-cli.sh

augmint-cli : start / stop augmint contracts. Docker image: augmint/contracts:vx.x.x

    Usage: /usr/local/bin/augmint-cli ganache {start | stop | run}
      start: tries to start container named ganache . If fails then runs (downloads, creates and starts) the container from augmint/contracts:vx.x.x
      stop: plain docker stop augmint/contracts:vx.x.x (doesn't check if exists)
      run: stops and removes the ganache container if exists. then runs it

Also recreates the container if it exists but image is not as expected (ie. there was a version upgrade)

Publish NPM package

bump the version property in the package.json release a new version as usual

  • merge staging into master
  • create a release in github with the vX.X.X tag on master

before npm publish, you need to build the library:

  • checkout the master(!) branch
  • yarn clean
  • yarn build npm publish from master branch. test it with --dry-run

Contributions

Augmint is an open and transparent project.

We are looking for great minds to extend our core team. Contributions in any area is much appreciated: development, testing, UX&UI design, legal, marketing, spreading the word etc.

Code of Conduct

Get in touch

Authors

See team on www.augmint.org

Decentlabs The project was born at DECENT Labs

Concept, initial version

Licence

This project is licensed under the GNU Affero General Public License v3.0 license - see the LICENSE file for details.

Keywords

FAQs

Package last updated on 17 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc