# meta-web3

> Web3 wrapper for ERC721, 725, 735 and governance

Latest version **0.3.4** (published 2019-06-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install meta-web3
pnpm add meta-web3
yarn add meta-web3
bun add meta-web3
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.4 |
| Published | 2019-06-05 |
| First published | 2018-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 5 |
| Unpacked size | 227.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | hexoul |
| Maintainers | hexoul |
| Keywords | Ethereum, DApp, Web3 |

## Links

- npm: https://www.npmjs.com/package/meta-web3
- Repository: https://github.com/hexoul/meta-web3
- Homepage: https://github.com/hexoul/meta-web3#readme
- Issues: https://github.com/hexoul/meta-web3/issues
- npm.io page: https://npm.io/package/meta-web3

## Dependencies (5)

- [web3](https://npm.io/package/web3.md) ^1.0.0-beta.34
- [https](https://npm.io/package/https.md) ^1.0.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.3.0
- [underscore](https://npm.io/package/underscore.md) ^1.9.1
- [ethereumjs-util](https://npm.io/package/ethereumjs-util.md) ^6.0.0

## Recent versions

- 0.3.4 (latest) — 2019-06-05
- 0.3.3 — 2019-05-02
- 0.3.2 — 2019-04-10
- 0.3.1 — 2019-03-25
- 0.3.0 — 2019-03-22
- 0.2.1 — 2018-12-14
- 0.2.0 — 2018-12-10
- 0.1.2 — 2018-12-05
- 0.1.1 — 2018-12-05
- 0.1.0 — 2018-12-04

## README

# meta-web3

[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/hexoul/meta-web3/master/LICENSE)
[![NPM](https://img.shields.io/npm/v/meta-web3.svg)](https://www.npmjs.com/package/meta-web3)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

> Web3 wrapper for ERC721, 725, 735 and governance

## Install

```bash
npm i meta-web3
```

## Components

1. Registry
1. AttestationAgencyRegistry
1. Identity
1. IdentityManager
1. TopicRegistry
1. AchievementManager
1. BallotStorage
1. EnvStorage
1. Governance
1. Staking

## Usage

```jsx
import React, { Component } from 'react'

// Web3
import Web3 from 'web3';
import web3config from './web3-config.json'

// Contracts
import { constants, contracts, getContractsAddresses, initContracts, TopicRegistry } from 'meta-web3'

class Example extends Component {

  state = {
    initDone: false,
  };

  async init() {
    initContracts({
      web3: new Web3(new Web3.providers.HttpProvider(web3config.url)),
      branch: constants.branch.TESTNET,
      identity: web3config.identity,
      privkey: web3config.privkey,
    }).then(async () => {
      // All contracts are initialized
      this.result = {
        getLengthOfAchievements: await contracts.achievementManager.getLengthOfAchievements(),
        getAttestationAgencyNum: await contracts.aaRegistry.getAttestationAgencyNum(),
        getTotal: await contracts.topicRegistry.getTotal(),
      };
      this.setState({ initDone: true })
    });
  }

  async initDirectly() {
    // If you want to initialize each contract directly
    getContractsAddresses().then(async () => {
      let topicRegistry = new TopicRegistry()
      topicRegistry.init({
        web3: new Web3(new Web3.providers.HttpProvider(web3config.url)),
      }).then(async () => {
        let total = await topicRegistry.getTotal()
        console.log('total', total)
      });
    });
  }

  componentWillMount() {
    this.init();
  }

  render () {
    return (
      <div>
        {this.state.initDone &&
          Object.keys(this.result).map(k => <p key={k}>{k + ': ' + this.result[k]}</p>)
        }
      </div>
    )
  }
}
```

## Test

```
cd meta-web3
npm start
[Ctrl+C]
cd example
npm start
```

## Reference
- [ERC721 spec.](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md)
- [ERC725 spec.](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-725.md)
- [ERC735 spec.](https://github.com/ethereum/EIPs/issues/735)
- [ERC725-735 imp.](https://github.com/mirceapasoi/erc725-735)
- [OpenZeppelin imp.](https://github.com/OpenZeppelin/openzeppelin-solidity)

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