# tribute-utils

> Utility to interact with the rDAI smart-contracts.

Latest version **0.0.6** (published 2019-11-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install tribute-utils
pnpm add tribute-utils
yarn add tribute-utils
bun add tribute-utils
```

## Health

**Score 5/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2019-11-10 |
| First published | 2019-11-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 170.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Tribute |
| Maintainers | pi0neerpat |
| Keywords | rdai, defi, ethereum, interest, rtoken |

## Links

- npm: https://www.npmjs.com/package/tribute-utils
- Repository: https://github.com/Send-Tribute/tribute-utils
- Homepage: https://github.com/Send-Tribute/tribute-utils#readme
- Issues: https://github.com/Send-Tribute/tribute-utils/issues
- npm.io page: https://npm.io/package/tribute-utils

## Dependencies (5)

- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [ethers](https://npm.io/package/ethers.md) ^4.0.39
- [truffle](https://npm.io/package/truffle.md) ^5.0.44
- [bignumber.js](https://npm.io/package/bignumber.js.md) github:frozeman/bignumber.js-nolookahead
- [babel-polyfill](https://npm.io/package/babel-polyfill.md) ^6.26.0

## Recent versions

- 0.0.6 (latest) — 2019-11-10
- 0.0.8 (beta) — 2019-11-13
- 0.0.3 (next) — 2019-11-04
- 0.0.7 — 2019-11-13
- 0.0.5 — 2019-11-08
- 0.0.4 — 2019-11-04
- 0.0.1 — 2019-11-03

## README

# 🏺 Tribute-Utils

[![npm package](https://img.shields.io/npm/v/tribute-utils)](https://www.npmjs.com/package/tribute-utils)
[![Build Status](https://travis-ci.org/Send-Tribute/tribute-utils.svg?branch=master)](https://travis-ci.org/Send-Tribute/tribute-utils)
[![Maintainability](https://api.codeclimate.com/v1/badges/7cc0d71f7bd6e6b9c1ed/maintainability)](https://codeclimate.com/github/Send-Tribute/tribute-utils/maintainability)
[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/Send-Tribute/tribute-utils.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Send-Tribute/tribute-utils/context:javascript)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FSend-Tribute%2Ftribute-utils.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FSend-Tribute%2Ftribute-utils?ref=badge_shield)
![](https://img.shields.io/github/license/send-tribute/tribute-utils)

A utility to interact with the rDAI contracts.

## Usage

`tribute.getInfo()`

```js
{
  allocations: [array],
  balance: [number],
  unallocated_balance: [number],
  unclaimed_balance: [number]
}
```

...

## Example

```js
import React, { useState } from 'react';
import Tribute from 'tribute-utils';
import { ethers } from 'ethers';
import { CONTRACTS } from '../../helpers/constants';
import DAIabi from '../../../contracts/dai';
import rDAIabi from '../../../contracts/rDai';

export default function UserAccount() {
  const [state, setState] = useState();

    // 1. enable metamask
    if (window.ethereum) {
      let address = await window.ethereum.enable();
      try {
        if (
          typeof window.ethereum !== 'undefined' ||
          typeof window.web3 !== 'undefined'
        ) {
          let walletProvider = new ethers.providers.Web3Provider(
            window.web3.currentProvider
          );
          // connect to contracts on the network
          const rDAIContract = new ethers.Contract(
            CONTRACTS.rtoken.kovan,
            rDAIabi,
            walletProvider
          );
          const DAIContract = new ethers.Contract(
            CONTRACTS.dai.kovan,
            DAIabi,
            walletProvider
          );
          // create the Tribute object
          const tribute = new Tribute(
            DAIContract,
            rDAIContract,
            walletProvider,
            address
          );
          const userDetails = await tribute.getInfo();
          console.log(userDetails);
          setState(state => {
            return setState(
              ...state,
              { tribute },
              { userDetails },
            );
          });
        }
      } catch (error) {
        console.log('Web3 Loading Error: ', error.message);
      }
    }
  }
  return (
    <div>
      {JSON.stringify(userDetails)}
    </div>
  );
}
```

## License

[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSend-Tribute%2Ftribute-utils.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FSend-Tribute%2Ftribute-utils?ref=badge_large)

---
_Source: https://npm.io/package/tribute-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
