# metahubjs

> metahub javascript sdk

Latest version **1.1.9** (published 2024-11-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install metahubjs
pnpm add metahubjs
yarn add metahubjs
bun add metahubjs
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.9 |
| Published | 2024-11-01 |
| First published | 2022-04-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | metahub |
| Maintainers | metahubwallet |
| Keywords | metahub, wallet, eos, eosjs |

## Links

- npm: https://www.npmjs.com/package/metahubjs
- Repository: https://github.com/metahubwallet/metahubjs
- Homepage: https://github.com/metahubwallet/metahubjs#readme
- Issues: https://github.com/metahubwallet/metahubjs/issues
- npm.io page: https://npm.io/package/metahubjs

## Dependencies (1)

- [rollup-plugin-esbuild-minify](https://npm.io/package/rollup-plugin-esbuild-minify.md) ^1.1.2

## Recent versions

- 1.1.9 (latest) — 2024-11-01
- 1.1.8 — 2023-09-18
- 1.1.7 — 2023-09-08
- 1.1.6 — 2023-09-07
- 1.1.5 — 2023-08-31
- 1.1.4 — 2023-08-31
- 1.1.3 — 2023-08-31
- 1.1.2 — 2023-08-31
- 1.1.1 — 2023-08-31
- 1.1.0 — 2023-08-31
- 1.0.0 — 2022-04-02

## README

# metahubjs

Javascript API for integration metahub wallet.  

[View Example](https://github.com/metahubwallet/metahubjs-example)

## Installation

`npm install metahubjs`

or

`yarn add metahubjs`

## Basic Usage

```javascript
const metahubjs = require('metahubjs');
const { Api, JsonRpc } = require('eosjs');

const appName = 'Your App Name';
const chainId = 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906';
const rpcUrl = 'https://eos.greymass.com';
const network = { chainId };

// connect
const connected = await metahubjs.connect(appName, { network });
if (!connected) {
    throw new Error('no metahub');
}

const rpc = new JsonRpc(rpcUrl, { fetch });
const api = metahubjs.eos(network, Api, { rpc });
// get logined accounts
let accounts = [];
if (metahubjs.identity) {
    accounts = metahubjs.identity.accounts;
}

// login
const identity = await metahubjs.login();
// if success, will response
{
    "accounts": [
        "authority": "active"
        "blockchain": "eos"
        "chainId": "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906"
        "isHardware": false
        "name": "metahubpower"
        "publicKey": "EOS8gFtMZP2WVqs2Z3812dNBWWLmNt2cuHzjfBPZAWk2KoG6fEq1x"
    ]
}

// logout all accounts
await metahubjs.logout();

// logout single account
await metahubjs.logout({account: 'metahubpower'});

// sign text
await metahubjs.getArbitrarySignature(account.publicKey, 'test text');

// transact
const result = await api.transact({
        actions: [{
            account: 'eosio.token',
            name: 'transfer',
            authorization: [{
                actor: 'useraaaaaaaa',
                permission: 'active',
            }],
            data: {
                from: 'useraaaaaaaa',
                to: 'useraaaaaaab',
                quantity: '0.0001 EOS',
                memo: '',
            },
        }] 
    }, {
        blocksBehind: 3,
        expireSeconds: 30,
    }
);

// For more api usage, please refer to https://github.com/EOSIO/eosjs

```

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