Linux command
solcjs 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Compile contract
solcjs [contract.sol]
Output binary
solcjs --bin [contract.sol]
Output ABI
solcjs --abi [contract.sol]
Both binary and ABI
solcjs --bin --abi [contract.sol]
Custom output directory
solcjs --bin -o [build] [contract.sol]
Optimize code
solcjs --bin --optimize [contract.sol]
说明
solcjs is a JavaScript/WebAssembly implementation of the Solidity compiler, installable via npm. It compiles Solidity smart contracts into EVM bytecode and ABI (Application Binary Interface) definitions needed for deploying and interacting with contracts on Ethereum and compatible blockchains. The compiler produces bytecode (--bin) for deployment and ABI JSON (--abi) that describes the contract's functions and events for client interaction. The optimizer reduces bytecode size and gas costs when enabled. solcjs provides the same core compilation functionality as the native solc compiler but runs in Node.js environments, making it easy to integrate into JavaScript-based development workflows and build tools like Truffle and Hardhat. It is somewhat slower than the native compiler and may lack some advanced features.
参数
- --bin
- Output bytecode.
- --abi
- Output ABI JSON.
- --optimize
- Enable optimizer.
- -o _DIR_
- Output directory.
- --base-path _DIR_
- Base path for imports.
- --include-path _DIR_
- Include path.
FAQ
What is the solcjs command used for?
solcjs is a JavaScript/WebAssembly implementation of the Solidity compiler, installable via npm. It compiles Solidity smart contracts into EVM bytecode and ABI (Application Binary Interface) definitions needed for deploying and interacting with contracts on Ethereum and compatible blockchains. The compiler produces bytecode (--bin) for deployment and ABI JSON (--abi) that describes the contract's functions and events for client interaction. The optimizer reduces bytecode size and gas costs when enabled. solcjs provides the same core compilation functionality as the native solc compiler but runs in Node.js environments, making it easy to integrate into JavaScript-based development workflows and build tools like Truffle and Hardhat. It is somewhat slower than the native compiler and may lack some advanced features.
How do I run a basic solcjs example?
Run `solcjs [contract.sol]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --bin do in solcjs?
Output bytecode.