{"_id":"@bcoders.gr/abi-toolkit","_rev":"3-d22a6a7acd0b81a3d26f08710ed3e8a7","name":"@bcoders.gr/abi-toolkit","dist-tags":{"latest":"2.2.0"},"versions":{"2.1.0":{"name":"@bcoders.gr/abi-toolkit","version":"2.1.0","keywords":["ethereum","abi","encoding","decoding","smart-contracts","web3","uniswap","erc20","defi","blockchain","solidity","informer","token-trader","pair-details","reserves"],"author":{"name":"bcoders.gr"},"license":"MIT","_id":"@bcoders.gr/abi-toolkit@2.1.0","maintainers":[{"name":"pagovitsa","email":"pagovitsa@gmail.com"},{"name":"badjunior91","email":"badjunior91@gmail.com"}],"homepage":"https://github.com/pagovitsa/abi-toolkit#readme","bugs":{"url":"https://github.com/pagovitsa/abi-toolkit/issues"},"dist":{"shasum":"d3243f39ea299152a133c9bca4c5ebdda3103673","tarball":"https://registry.npmjs.org/@bcoders.gr/abi-toolkit/-/abi-toolkit-2.1.0.tgz","fileCount":20,"integrity":"sha512-x5EmrYFoFSWGZ/e1miEdxvqP7eDaMOAZA7sI9cX6hhkoEIzVKP3szJZ29v8GQFFRrCZsa1fO6ViLwlNY0XIDJg==","signatures":[{"sig":"MEQCIBBkNSuzDtAGeRbPNhKTxyTb7DKq+s7TSxSVMneGbeinAiBtvplCjqlwuNQ4jn2SrEdC7W0FgiqYodIm06CVK5tWoQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":116574},"main":"index.js","type":"module","engines":{"node":">=16.0.0"},"gitHead":"2a517826632a8150b67d5c1602170842023fcbd3","scripts":{"test":"node test/index.test.js","example":"node examples/index.js"},"_npmUser":{"name":"pagovitsa","actor":{"name":"pagovitsa","type":"user","email":"pagovitsa@gmail.com"},"email":"pagovitsa@gmail.com"},"repository":{"url":"git+https://github.com/pagovitsa/abi-toolkit.git","type":"git"},"_npmVersion":"10.9.2","description":"Comprehensive Ethereum ABI toolkit combining high-performance encoding/decoding with production-ready contract interaction utilities","directories":{},"_nodeVersion":"22.17.0","dependencies":{"js-sha3":"^0.9.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/abi-toolkit_2.1.0_1750973768865_0.5085595714760347","host":"s3://npm-registry-packages-npm-production"}},"2.1.1":{"name":"@bcoders.gr/abi-toolkit","version":"2.1.1","keywords":["ethereum","abi","encoding","decoding","smart-contracts","web3","uniswap","erc20","defi","blockchain","solidity","informer","token-trader","pair-details","reserves"],"author":{"name":"bcoders.gr"},"license":"MIT","_id":"@bcoders.gr/abi-toolkit@2.1.1","maintainers":[{"name":"pagovitsa","email":"pagovitsa@gmail.com"},{"name":"badjunior91","email":"badjunior91@gmail.com"}],"homepage":"https://github.com/pagovitsa/abi-toolkit#readme","bugs":{"url":"https://github.com/pagovitsa/abi-toolkit/issues"},"dist":{"shasum":"3555dec69fddb66850eda3ff48185b7a14428754","tarball":"https://registry.npmjs.org/@bcoders.gr/abi-toolkit/-/abi-toolkit-2.1.1.tgz","fileCount":20,"integrity":"sha512-VwEF1siB7mkOZdswLBI4zkyqWtZ6BZZK0GIWCGx37q/4WzyTrPi4+5AyQzTRPWLE9zPQpSEs0nWwREhB3uHvwg==","signatures":[{"sig":"MEUCIQCsFMPIkVkFazYPZJUc5PQwlVBZr0vG8VFOoPQzokT2yQIgek4EaFGlMYJ/hrFY/sadL1kgzEQ+nT0mvzLsljzq1M4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":120828},"main":"index.js","type":"module","engines":{"node":">=16.0.0"},"gitHead":"973d4ed3da1d786df36e9fba634b4bf291eddbd3","scripts":{"test":"node test/index.test.js","example":"node examples/index.js"},"_npmUser":{"name":"pagovitsa","actor":{"name":"pagovitsa","type":"user","email":"pagovitsa@gmail.com"},"email":"pagovitsa@gmail.com"},"repository":{"url":"git+https://github.com/pagovitsa/abi-toolkit.git","type":"git"},"_npmVersion":"10.9.2","description":"Comprehensive Ethereum ABI toolkit combining high-performance encoding/decoding with production-ready contract interaction utilities","directories":{},"_nodeVersion":"22.17.0","dependencies":{"js-sha3":"^0.9.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/abi-toolkit_2.1.1_1750974779259_0.9764751205599351","host":"s3://npm-registry-packages-npm-production"}},"2.2.0":{"name":"@bcoders.gr/abi-toolkit","version":"2.2.0","description":"Comprehensive Ethereum ABI toolkit combining high-performance encoding/decoding with production-ready contract interaction utilities","main":"index.js","type":"module","scripts":{"test":"node test/comprehensive-tests.js","test:integration":"node test/integration-test.js","test:performance":"node test/performance-test.js","test:log-decoder":"node test/log-decoder-fix-test.js","example":"node examples/index.js"},"keywords":["ethereum","abi","encoding","decoding","smart-contracts","web3","uniswap","erc20","defi","blockchain","solidity","informer","token-trader","pair-details","reserves"],"author":{"name":"bcoders.gr"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/pagovitsa/abi-toolkit.git"},"engines":{"node":">=16.0.0"},"dependencies":{"js-sha3":"^0.9.3"},"publishConfig":{"access":"public"},"_id":"@bcoders.gr/abi-toolkit@2.2.0","gitHead":"b3afaf0ea4635155e5b393d00e2f43ef31737139","bugs":{"url":"https://github.com/pagovitsa/abi-toolkit/issues"},"homepage":"https://github.com/pagovitsa/abi-toolkit#readme","_nodeVersion":"22.17.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-/cAC3FptkzXYjz79lrAIVWKS8hVX7SQ9caNnaBBL0k/hvGX8AgtjcEKJr2FaX7dofXPtfVkTcSrh7ampaIieOg==","shasum":"529eda8dd1a0cef5754a1b534c7e07b237698883","tarball":"https://registry.npmjs.org/@bcoders.gr/abi-toolkit/-/abi-toolkit-2.2.0.tgz","fileCount":21,"unpackedSize":125769,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBvtcNNJ7dPprBXIZPp5db9YDK5xo+y3dRBmbxbya2RoAiEAytv8JcsGC6oo75O445sMWRYUN+BsPaHhmcFbGLsF/KU="}]},"_npmUser":{"name":"pagovitsa","email":"pagovitsa@gmail.com","actor":{"name":"pagovitsa","email":"pagovitsa@gmail.com","type":"user"}},"directories":{},"maintainers":[{"name":"pagovitsa","email":"pagovitsa@gmail.com"},{"name":"badjunior91","email":"badjunior91@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/abi-toolkit_2.2.0_1751643148478_0.918101716936889"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-26T21:36:08.774Z","modified":"2025-07-04T15:32:28.888Z","2.1.0":"2025-06-26T21:36:09.035Z","2.1.1":"2025-06-26T21:52:59.438Z","2.2.0":"2025-07-04T15:32:28.671Z"},"bugs":{"url":"https://github.com/pagovitsa/abi-toolkit/issues"},"author":{"name":"bcoders.gr"},"license":"MIT","homepage":"https://github.com/pagovitsa/abi-toolkit#readme","keywords":["ethereum","abi","encoding","decoding","smart-contracts","web3","uniswap","erc20","defi","blockchain","solidity","informer","token-trader","pair-details","reserves"],"repository":{"type":"git","url":"git+https://github.com/pagovitsa/abi-toolkit.git"},"description":"Comprehensive Ethereum ABI toolkit combining high-performance encoding/decoding with production-ready contract interaction utilities","maintainers":[{"name":"pagovitsa","email":"pagovitsa@gmail.com"},{"name":"badjunior91","email":"badjunior91@gmail.com"}],"readme":"# ABI Toolkit\n\nA comprehensive, production-ready Ethereum ABI toolkit for smart contract interactions. This lightweight toolkit provides high-performance encoding/decoding capabilities along with extensive utilities for DeFi protocols, without heavy dependencies like ethers.js.\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n- [Architecture](#architecture)\n- [Core Modules](#core-modules)\n- [Common Modules](#common-modules)\n- [Utilities](#utilities)\n- [Usage Examples](#usage-examples)\n- [API Reference](#api-reference)\n- [Performance](#performance)\n- [Security](#security)\n- [Testing](#testing)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n- **Lightweight & Fast**\n  - No heavy dependencies (no ethers.js required)\n  - Only 18.7 kB package size\n  - Uses efficient js-sha3 for cryptographic operations\n  - Optimized for minimal memory footprint\n\n- **High-Performance ABI Encoding/Decoding**\n  - Fast encoding and decoding operations\n  - Support for all Solidity types\n  - Batch operation support\n  - Caching for improved performance\n\n- **Comprehensive Protocol Support**\n  - ERC20 token interactions\n  - Uniswap V2 integration (Factory, Pair, Router)\n  - Custom protocol support via extensible architecture\n\n- **Advanced Features**\n  - Fee-on-transfer token handling\n  - Gas optimization utilities\n  - Comprehensive input validation\n  - Event log decoding\n  - Function selector utilities\n\n- **Production-Ready**\n  - Extensive test coverage\n  - Error handling and validation\n  - TypeScript-friendly\n  - Well-documented API\n\n## Installation\n\n```bash\nnpm install @bcoders.gr/abi-toolkit\n```\n\n**Why choose this toolkit?**\n- ✅ Lightweight: Only 18.7 kB vs 1MB+ with ethers.js\n- ✅ Zero ethers dependency - uses efficient js-sha3 instead\n- ✅ Same functionality, better performance\n- ✅ Drop-in replacement for ethers-based ABI operations\n\nRequires Node.js >= 16.0.0\n\n## Architecture\n\nThe toolkit is organized into three main layers:\n\n1. **Core Layer**\n   - ABICodec: Main encoding/decoding engine\n   - Encoder: Low-level ABI encoding\n   - Decoder: Low-level ABI decoding\n   - Selector Utils: Function signature handling\n\n2. **Common Modules Layer**\n   - Protocol-specific implementations\n   - Standardized interfaces\n   - Reusable components\n\n3. **Utility Layer**\n   - Helper functions\n   - Validation utilities\n   - Log handling\n\n## Core Modules\n\n### ABICodec\n\nThe primary interface for encoding and decoding Ethereum contract calls.\n\n```javascript\nimport { ABICodec } from '@bcoders.gr/abi-toolkit';\n\nconst codec = new ABICodec(contractABI);\n\n// Encode function call\nconst encoded = codec.encodeFunction('transfer', ['0x123...', '1000000000']);\n\n// Decode function result\nconst decoded = codec.decodeFunctionResult('balanceOf', '0x000....');\n```\n\n### Encoder/Decoder\n\nLow-level encoding and decoding utilities.\n\n```javascript\nimport { Encoder, Decoder } from '@bcoders.gr/abi-toolkit';\n\n// Encode parameters\nconst encoded = Encoder.encodeParameters(['address', 'uint256'], ['0x123...', '1000']);\n\n// Decode parameters\nconst decoded = Decoder.decodeParameters(['string', 'bool'], '0x...');\n```\n\n## Common Modules\n\n### ERC20\n\nUtilities for ERC20 token interactions.\n\n```javascript\nimport { erc20 } from '@bcoders.gr/abi-toolkit';\n\n// Generate transfer call data\nconst transferData = erc20.transfer(recipientAddress, amount);\n\n// Generate approve call data\nconst approveData = erc20.approve(spenderAddress, amount);\n\n// Get token balance\nconst balanceData = erc20.balanceOf(accountAddress);\n```\n\n### Uniswap V2\n\nComplete Uniswap V2 protocol support.\n\n```javascript\nimport { uniswapV2 } from '@bcoders.gr/abi-toolkit';\n\n// Factory interactions\nconst createPairData = uniswapV2.factory.createPair(token0, token1);\nconst getPairData = uniswapV2.factory.getPair(token0, token1);\n\n// Router interactions\nconst swapData = uniswapV2.router.swapExactTokensForTokens(\n  amountIn,\n  amountOutMin,\n  path,\n  to,\n  deadline\n);\n\n// Pair interactions\nconst reservesData = uniswapV2.pair.getReserves();\n```\n\n### Informer\n\nContract state information utilities.\n\n```javascript\nimport { informer } from '@bcoders.gr/abi-toolkit';\n\n// Get contract owner\nconst ownerData = informer.getOwner(contractAddress);\n\n// Decode owner response\nconst owner = informer.decode.owner(responseData);\n```\n\n### TokenTrader\n\nAdvanced token trading utilities.\n\n```javascript\nimport { tokenTrader } from '@bcoders.gr/abi-toolkit';\n\n// Generate trade data\nconst tradeData = tokenTrader.btwr(\n  fromAddress,\n  pairAddress,\n  amountIn,\n  amountOutMin,\n  deadline,\n  flag\n);\n```\n\n## Utilities\n\n### Log Decoder\n\nHigh-performance event log decoder with pre-optimized common events and custom ABI support.\n\n```javascript\nimport { \n  decodeLogs, \n  decodeTransferLogs, \n  decodeMintLogs,\n  decodePairCreatedLogs,\n  addCustomABI,\n  getEventSignature,\n  LogDecoder \n} from '@bcoders.gr/abi-toolkit';\n\n// Decode all common events at once\nconst decodedLogs = decodeLogs(txReceipts);\nconsole.log(decodedLogs.transfers);    // ERC20 Transfer events\nconsole.log(decodedLogs.mints);        // Uniswap V2 Mint events\nconsole.log(decodedLogs.pairCreated);  // Uniswap V2 PairCreated events\nconsole.log(decodedLogs.custom);       // Custom ABI decoded events\n\n// Decode specific event types\nconst transfers = decodeTransferLogs(txReceipts);\nconst mints = decodeMintLogs(txReceipts);\nconst pairCreated = decodePairCreatedLogs(txReceipts);\n\n// Add custom ABI for decoding\naddCustomABI(customABI, 'CustomContract');\n\n// Get event signature for filtering\nconst transferSig = getEventSignature('TRANSFER');\n\n// Advanced usage with LogDecoder class\nconst decoder = new LogDecoder();\ndecoder.addABI(customABI, 'MyContract');\nconst results = decoder.decodeLogs(receipts);\n```\n\n**Features:**\n- Pre-optimized common event signatures (Transfer, Mint, PairCreated)\n- Manual optimization for Transfer events (fastest decoding)\n- Support for multiple input formats (single receipt, array of receipts, array of logs)\n- Custom ABI support for any contract events\n- Automatic event categorization\n- Comprehensive metadata preservation (blockNumber, txHash, logIndex, etc.)\n\n### Selector Utils\n\nFunction selector utilities.\n\n```javascript\nimport { selectorUtils } from '@bcoders.gr/abi-toolkit';\n\n// Generate function selector\nconst selector = selectorUtils.getFunctionSelectorFromSignature('transfer(address,uint256)');\n\n// Validate selector\nconst isValid = selectorUtils.validateFunctionSelector('0xa9059cbb');\n```\n\n## Performance\n\nThe toolkit is optimized for performance and size:\n\n- **Package Size**: Only 18.7 kB (vs 1MB+ with ethers.js)\n- **Dependencies**: Just js-sha3 for cryptographic operations\n- **Memory**: Minimal allocation and efficient buffer handling\n- **Speed**: Optimized encoding/decoding algorithms with caching\n\nBenchmarks show:\n- Function encoding: ~50,000 ops/sec\n- Parameter decoding: ~40,000 ops/sec\n- Log decoding: ~30,000 ops/sec (with manual Transfer optimization: ~100,000 ops/sec)\n- Package install time: 90% faster than ethers-based alternatives\n\n**Log Decoder Optimizations:**\n- Pre-computed event signatures for instant recognition\n- Manual decoding for Transfer events (3x faster than codec)\n- Codec caching for repeated event types\n- Efficient batch processing for multiple receipts\n- Zero-allocation address parsing for indexed parameters\n\n## Security\n\nSecurity best practices implemented:\n\n- Input validation for all parameters\n- Safe buffer handling\n- Protection against integer overflow\n- Proper error handling\n- No unsafe type coercion\n\n## Testing\n\nComprehensive test suite covering:\n\n```bash\n# Run all tests\nnpm test\n\n# Run specific test suite\nnode test/integration-test.js\nnode test/performance-test.js\nnode test/edge-cases-test.js\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n### Development Setup\n\n```bash\ngit clone https://github.com/yourusername/abi-toolkit.git\ncd abi-toolkit\nnpm install\nnpm test\n```\n\n## License\n\nMIT License - see the [LICENSE](LICENSE) file for details.\n\n---\n\nFor more information, bug reports, or feature requests, please visit the [GitHub repository](https://github.com/pagovitsa/abi-toolkit).\n","readmeFilename":"README.md"}