Skip to content

About

Sort an Ethereum ABI definition for easier comparison

Resources

Stars

0 stars

Watchers

4 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

eth-abi-sort

Sort an Ethereum ABI definition for easier comparison

Installation

npm install --global eth-abi-sort

Usage

Sort ABI files in place:

abi-sort abi.json

Or pipe an ABI into the command and redirect the output to a new file:

abi-sort < abi.json > sorted.json

It can also be used programatically:

const sortAbi = require("eth-sort-abi");
const abi = [
  // the ABI of a contract
];
const sortedAbi = sortAbi(abi);

How it works

The tool will place the events first, then the functions. Each group is sorted by signature, ascending. The signature is computed as "name(type,...)".

Motivation

When EVM contracts are compiled, the ABIs can be obtained. But the order of the descriptors inside the ABI and the order of the properties cannot be guaranteed. Depending on the contract code, compiler and versions used, the ABIs can be created with a different order.

To make comparisons easier, this tool can be used to deterministically sort ABIs.

License

MIT

About

Sort an Ethereum ABI definition for easier comparison

Resources

Stars

0 stars

Watchers

4 watching

Forks

Releases

Used by

Contributors

Languages