# mythxjs

> Mythxjs is a library for the MythX smart contract security analysis platform.

Latest version **1.3.13** (published 2022-01-24) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.3.13 |
| Published | 2022-01-24 |
| First published | 2019-05-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 1.2 MB |
| Known vulnerabilities | 0 (+26 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 29 |
| Author | Mirko Garozzo |
| Maintainers | joaosantos15, mirkog, mythx_team |
| Keywords | MythX, Smart Contract, Ethereum, Blockchain, Security |

## Links

- npm: https://www.npmjs.com/package/mythxjs
- Repository: https://github.com/ConsenSys/mythxjs
- Issues: https://github.com/ConsenSys/mythxjs/issues
- npm.io page: https://npm.io/package/mythxjs

## Dependencies (3)

- [axios](https://npm.io/package/axios.md) ^0.25.0
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.5.1
- [chai-as-promised](https://npm.io/package/chai-as-promised.md) ^7.1.1

## Recent versions

- 1.3.13 (latest) — 2022-01-24
- 1.4.0 — 2020-08-07
- 1.3.12 — 2020-04-28
- 1.3.11 — 2020-01-21
- 1.3.10 — 2020-01-20
- 1.3.9 — 2019-12-02
- 1.3.8 — 2019-11-22
- 1.3.7 — 2019-11-19
- 1.3.6 — 2019-10-25
- 1.3.5 — 2019-09-05
- 1.3.3 — 2019-08-14
- 1.3.2 — 2019-08-14
- 1.3.1 — 2019-07-17
- 1.3.0 — 2019-07-15
- 1.2.0 — 2019-07-12
- … 12 more at https://npm.io/package/mythxjs/versions

## README

# MythX JS Library

[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

MythXJS is a Javascript based library for the [Mythx](https://mythx.io/) smart contract security analysis platform.

The library works out of the box on Node and modern browsers.

## Installation

```
npm install mythxjs
```

## Example

Creating a new instance of the library using ES6 modules and pass in a config object

```typescript
import { Client } from 'mythxjs'

const mythx = new Client({
  username: '<your registered MythX email or EthAddress>',
  apiKey: '<your mythx API key. see https://docs.mythx.io/#using-your-account for help>'
});
```

Submitting an analysis using bytecode only

```typescript
const bytecode = '0xfe'
await mythx.submitBytecode(bytecode)
```

Getting a list of detected issues

```typescript
await mythx.getDetectedIssues('1111-2222-3333-4444')
```

### Logging in with MetaMask
In order to keep MythXJS as lean as possible we do not handle MetaMask integration ourself. Instead we provide two methods: getChallenge() and loginWithSignature() and leave the user handle the MetaMask integration the way they better prefer on their front end. This also lets the user work with their preffered version of `web3`.

Example using react app and `web3@1.0.0-beta.37`:
```typescript
const handleSignMessage = (account, data) => {
    try {
        return new Promise((resolve) => {
            const {value} = data.message
            if (!account) {
              console.error('no-account')
            }
              const params = [account, JSON.stringify(data)]
              web3.currentProvider.send(
                        { method: 'eth_signTypedData_v3', params, from: account },
                        (err, result) => {
                          if (err || result.error) {
                            console.error('Error with handling signature.', err)
                          }
                          resolve(value + '.' + result.result)
                        }
                    )
            }).catch((error) => {
              console.error(error)
            })
    } catch(err) {
        console.error(err)
    }
}

const loginWithMM = async () => {
    const accounts = await web3.eth.getAccounts();
    const account = accounts[0]

    const data = await mythx.getChallenge(account.toLowerCase())
    
    handleSignMessage(account, data).then(
        async (message) => {
            // Returns set of tokens
            const result = await mythx.loginWithSignature(message)
        }
    ).catch(err => console.error(err))
}
```


## Documentation
For a complete list of functionality available on the library please check our [docs](https://consensys.github.io/mythxjs/classes/_apiservices_clientservice_.clientservice.html)

## Contributing

Please read [CONTRIBUTING.md](https://github.com/ConsenSys/mythxjs/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.

## Versioning

For the versions available, see [the tags on this repository](https://github.com/ConsenSys/mythxjs/tags).

## Projects using MythxJS

-   [MythX for VSCode](https://marketplace.visualstudio.com/items?itemName=mirkogarozzo.mythxvsc)
-   [truffle security](https://github.com/ConsenSys/truffle-security)
-   [remix-mythx-plugin](https://github.com/aquiladev/remix-mythx-plugin)

## See also

-   [openapi spec](https://api.mythx.io/v1/openapi) for details of the MythX API.
-   [MythX Developer and User Guide](https://docs.mythx.io/) for more information
-   [MythX Discord channel](https://discord.gg/kktn8Wt) to join the MythX community.

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