Decentralised stable cryptocurrency on Ethereum
Decentralized stablecoins targeted to fiat currencies built on Ethereum.
The first Augmint token is AEUR.
1 AEUR ≈ 1 EUR.
Try it: https://www.augmint.org
This lib is heavily under construction. Anything can happen.
yarn add @augmint/js
or
npm install @augmint/js
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
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
Transaction
classIt'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.
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)
bump the version property in the package.json release a new version as usual
before npm publish, you need to build the library:
yarn clean
yarn build
npm publish from master branch. test it with --dry-runAugmint 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.
See team on www.augmint.org
The project was born at DECENT Labs
This project is licensed under the GNU Affero General Public License v3.0 license - see the LICENSE file for details.
Generated using TypeDoc