Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 879 Bytes

README.md

File metadata and controls

25 lines (19 loc) · 879 Bytes

fast-abi

Encodes and decodes abi data, fast.

Fork of 0xProject/fast-abi, with a few changes that make it more of a drop-in replacement for the ethers.js encoder/decoder:

  • Deserialize int32/uint32 to number type instead of BigNumber
  • Use BigNumber from ethers.js for serializing/deserializing
  • Doesn't include source code in the distributed binaries

Usage

const RUST_ENCODER = new FastABI(ABI as MethodAbi[]);
const callData = RUST_ENCODER.encodeInput('sampleSellsFromUniswapV2', [...values]);
// 0x.....

// Decode the output of a method call
const output = RUST_ENCODER.decodeOutput('sampleSellsFromUniswapV2', callData);
// {
//   router: '0x6b175474e89094c44da98b954eedeac495271d0f',
//   path: [ '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' ],
//   takerTokenAmounts: [ 1, 2, 3 ]
// }