abi2schema

0.2.2 • Public • Published

abi2schema

fork from source https://www.npmjs.com/package/solidity-json-schema

Convert Solidity ABI into a JSON schema.

Usage

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

Package Sidebar

Install

npm i abi2schema

Weekly Downloads

0

Version

0.2.2

License

MIT

Unpacked Size

28.8 kB

Total Files

13

Last publish

Collaborators

  • sambacha