# abi2schema

> solidity abit to json schema

Latest version **0.2.2** (published 2021-01-17) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2021-01-17 |
| First published | 2021-01-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 28.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | see contributors |
| Maintainers | sambacha |
| Keywords | solidity, abi, json, schema, ethereum, erc20 |

## Links

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

## Dependencies (1)

- [merge](https://npm.io/package/merge.md) ^2.1.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.2.2 (latest) — 2021-01-17
- 0.2.1 — 2021-01-17
- 0.1.1 — 2021-01-17

## README

# abi2schema

> fork from source [https://www.npmjs.com/package/solidity-json-schema](https://www.npmjs.com/package/solidity-json-schema)

Convert Solidity ABI into a JSON schema.

## Usage

```JavaScript
const convert = require('abi2schema');

const abi = require('./PathToTruffleArtifact.json').abi;

const all = convert(abi);

const schema1 = convert(abi, {
  type: 'constructor',
  for: 'inputs',
  as: 'object'
});

// {
//   "type": "object",
//   "required": ["tokenName", "maxAmount"],
//   "properties": {
//     "tokenName": {
//       "type": "string"
//     },
//     "maxAmount": {
//       "type": "integer"
//     }
//   }
// }

const schema2 = convert(abi, {
  name: 'fiatMaximum',
  for: 'outputs',
  as: 'array'
});

// {
//   "type": "object",
//   "required": ["tokenName", "maxAmount"],
//   "properties": {
//     "tokenName": {
//       "type": "string"
//     },
//     "maxAmount": {
//       "type": "integer"
//     }
//   }
// }
```

## Known Issues

- Does not de-references imported contracts
- Not found returns undefined

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