Compiling a smart contract involves using the contract's source code to generate its bytecode and the contract ApplicationBinary Interface (ABI). The Ethereum Virtual Machine (EVM) executes the bytecode to understand and execute the smart contract. Meanwhile, other smart contracts use the ABI to understand how to interact with the deployed contracts on the Hedera network.
Compiling Solidity
The compiler for the Solidity programming language is solc (Solidity Compiler). You can use the compiler directly or embedded in IDEs like Remix IDE or tools like Hardhat and Truffle.
Smart Contract Bytecode
Bytecode is the machine-readable language that the EVM uses to execute smart contracts. The compiler analyzes the code, checks for syntax errors, enforces language-specific rules, and generates the corresponding bytecode.
Example:
This is the example bytecode output, produced in hexadecimal format, when the HelloHedera smart contract source code is compiled.
The ABI is a JSON (JavaScript Object Notation) file that represents the interface definition for the smart contract. It specifies function signatures, input parameters, return types, and other relevant details of the contract's interface. The ABI helps developers understand how to interact with the smart contract in their distributed applications.
Example:
This is the example ABI output produced when the HelloHedera smart contract is compiled.