The internals of smart contract deployment
Remix makes the deployment of contracts a breeze; however, it performs a lot of steps behind the scenes. It is always useful to understand the process of deploying contracts to have finer control over the deployment process.
The first step is the compilation of contracts. The compilation is done using the Solidity compiler. The next chapter will show you how to download and compile a contract using the Solidity compiler.
The compiler generates the following two major artifacts:
- The Application Binary Interface (ABI) definition
- Contracts bytecode
Think of the ABI as an interface consisting of all external and public function declarations along with their parameters and return types. The ABI defines the contract, and any caller wanting to invoke any contract function can use the ABI to do so.
The bytecode represents the low-level instruction set for the contract, and it is deployed in the Ethereum ecosystem. The bytecode is required during deployment, and the ABI is needed for invoking functions in a contract.
A new instance of a contract is created using the ABI definition.
Deploying a contract itself is a transaction. A transaction is created for deploying the contract on Ethereum. The bytecode and ABI are necessary inputs for deploying a contract.
As any transaction execution costs gas in Ethereum, an appropriate quantity of gas should be supplied while deploying the contract. As and when the transaction is mined, the contract will be available for interaction through the contract address.
Using the newly generated address, callers can invoke functions within the contract.