npmjs_solc-helper
v2.0.0
Published
Solidity compiler helper utilities — version management, pragma extraction, bytecode hashing, and ABI method signatures
Maintainers
Readme
solc-helper
Solidity compiler helper utilities. Provides compiler version management, pragma extraction, bytecode hashing, and ABI method signature extraction.
Installation
npm install solc-helperQuick Start
const { getLatestVersion, extractPragma, bytecodeHash, extractMethodSignatures } = require('solc-helper');
// Get latest Solidity version
console.log(getLatestVersion()); // 0.8.27
// Extract pragma from source code
const source = 'pragma solidity ^0.8.0;\ncontract Test {}';
console.log(extractPragma(source)); // 0.8.0
// Hash a bytecode
const hash = bytecodeHash('0x6080604052348015600f57600080fd5b50...');
console.log(hash);
// Extract method signatures from ABI
const abi = [
{ type: 'function', name: 'transfer', inputs: [{ type: 'address' }, { type: 'uint256' }], stateMutability: 'nonpayable' }
];
console.log(extractMethodSignatures(abi));
// => [{ name: 'transfer', signature: 'transfer(address,uint256)', stateMutability: 'nonpayable' }]API Reference
getLatestVersion()
Returns the latest supported Solidity compiler version.
getAvailableVersions()
Returns all supported Solidity compiler versions.
supportsVersion(version)
Checks if a given Solidity version is supported.
extractPragma(source)
Extracts the pragma version directive from Solidity source code.
bytecodeHash(bytecode)
Computes the SHA-256 hash of contract bytecode.
extractMethodSignatures(abi)
Extracts function signatures from a contract ABI.
License
MIT
