Objectives
By the end of this lesson you should be able to:- Deploy and test the Storage.sol demo contract in Remix
Deploy the Storage Contract
Deploying a contract is easy, but remember that if the contract doesn’t compile, the deploy button will instead deploy the last good compiled version of your contract. Verify that you see a green checkmark on the icon for the Compiler contract on the left side of the editor, then select the Deploy & Run Transactions plugin.
If you’ve already deployed any contracts, press the trash can button to the right of the Deployed Contracts label. Then, press the orange button to deploy the Storage contract.
Contract Addresses
After your contract deploys, it will appear in the Deployed contracts section as STORAGE AT followed by an address. Addresses are used for both contracts and wallets in EVM-compatible blockchains and serve a similar purpose to an IP address. You can copy the address to see what it looks like. It’s 20 characters of hexadecimal, similar to0xd8b934580fcE35a11B58C6D73aDeE468a2833fa8.
The address is what you will use to find your contract with tools such as Etherscan, or to connect to it with a front end.
However, when you deploy using the Remix VM simulation, it will only exist in your browser.
Deployments and Test Accounts
The result of any transactions, including deployments, will appear in the Remix terminal. Click the chevron next to the blue Debug button to expand the log.Interacting with the Contract
Click the chevron to expand your contract in the Deployed Contracts section of the left panel. You’ll see two buttons, one for eachpublic function in the Storage contract. Notice how the Store button also has a field to pass a uint256, matching the parameter for uint256 num.
number variable was instantiated without a value, what do you think the return will be?
Go ahead and click – the result will appear below the button as:
uint256 of 0. Were you expecting undefined or an error?
Unlike many languages, variables in Solidity have a default value if not assigned. For uint and int, that value is 0.
You can also review the results of your transaction in the console.