Create, compile and publish your first smart contract
How do I make these distributed web3 concepts functional?
Last updated
How do I make these distributed web3 concepts functional?
Last updated
First, if we navigate back to our Workspace in Remix, we will see some folders already there for us. Click and expand the Contracts folder. This folder will already have a couple of demo Solidity files, denoted by the .sol extension, already present in the directory. We are going to right click and add a new file called Register.sol
A new file will open on the right potion of the screen. This section of the IDE is where you are able to paste the following code which creates a smart contract called "Register".
Like we said previously, Solidity is the human readable instructions that we want to execute. In order to to get the smart contract into a machine readable format, we need to first compile the code. We perform this by selecting the compile tab. You will see that the compiler version is already selected to the correct one because our code specifies that it needs to be compiled using the second line of the file you copied.
You will see a green checkmark on the compile tab icon once the code has been successfully compiled.
Now that we have the code we wrote in our human readable language in the machine readable format, we can deploy it to a test network. To do this, we navigate to the Deploy & Run transactions tab.
Now you are ready to "deploy" (put) your smart contract on the blockchain. All you need to do is press Deploy. You will be presented with a MetaMask Pop-up with the similar details to those found when we sent LINK between our accounts.
This window is displaying that, in order to deploy the contract to the blockchain, we must pay a gas fee. This fee is what is paid to the miners to keep the chain secure, and transfer the blockchain from one state to the next. Once the Confirm button is selected, you will see the phrase Creation of Register pending in the log output portion of the remix IDE. You will get an update in the log portion of the Remix IDE when the contract creation transaction has been fully mined to the block that the contract deployment transaction has been recorded in. You will also get a link to view that transaction and block in Etherscan.
If we return to the Deploy & Run Transaction tab on the left side of the IDE, we will see that we now have another dropdown named REGISTER AT <Contract Address>. This is a UI element that is given to us so we can interact with the deployed Register contract using a convenient graphical interface. We will explain how to using this UI to interact with our Register contract in the next section.
To become more familiar with the Solidity programming language and syntax feel free to visit the resources below for more help.