Skip to content
No description, website, or topics provided.
TypeScript Other
Branch: master
Clone or download
Latest commit fd3c95f Sep 5, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Added npm run build to CI Jun 15, 2019
docs MythXJS fixed main service docs Jun 17, 2019
src MythXJS fixed token refresh issue Sep 5, 2019
.editorconfig Initial commit for setting up TypeScript library Mar 25, 2019
.eslintrc.js MythxJS removed unused dependencies May 17, 2019
.gitignore MythXJS committed autogenerated docs Jun 17, 2019
.prettierrc.js
CONTRIBUTING.md Initial commit for setting up TypeScript library Mar 25, 2019
LICENSE Initial commit for setting up TypeScript library Mar 25, 2019
Makefile
README.md Fixed spacing readme Aug 14, 2019
code-of-conduct.md Initial commit for setting up TypeScript library Mar 25, 2019
index.ts
package-lock.json 1.3.5 Sep 5, 2019
package.json
tsconfig.json Minor changes for toolName and typescript config May 24, 2019

README.md

MythX JS Library

styled with prettier

MythXJS is a Javascript based library for the Mythx 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

import { Client } from 'mythxjs'

const mythx = new Client('0x0000000000000000000000000000000000000000', 'trial', 'testTool');

Performing a login request

// Logs in and returns an object containing access and refresh token
const tokens = await mythx.login()

Submitting an analysis using bytecode only

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

Getting a list of detected issues

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:

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)
            console.log(result, 'ress')
        }
    ).catch(err => console.error(err))
}

Documentation

For a complete list of functionality available on the library please check our docs

Contributing

Please read 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.

Projects using MythxJS

See also

You can’t perform that action at this time.