Remix: Deploy EVM Smart Contract
Remix (opens new window) is an in-browser IDE for Solidity Smart Contracts. This guide will teach us how to deploy a contract to a running AIOZ Network through Remix and interact with it.
Set Up Development Environment
Connect Metamask to Deployed Account
Add AIOZ Network to Metamask
- Open the MetaMask extension on your browser (you may have to log in to your MetaMask account if you have not done so yet).
- Click on the top right circle and go to
Settings
>Networks
>Add Network
![Metamask_0](../../assets/aioznetwork/metamask_0.png)
![Metamask_1](../../assets/aioznetwork/metamask_1.png)
- To learn more how to add AIOZ Network in Metamask, please follow these articles:
Getting AIOZ Testnet from Faucet
- Access https://faucet-testnet.aioz.network (opens in a new tab)
- Enter wallet address to receive AIOZ Testnet Coin for Gas Fee to interact with AIOZ Blockchain Testnet
![Faucet Testnet](../../assets/aioznetwork/faucet_testnet.png)
Writing Smart Contract
Go to Remix (opens in a new tab). There are some contracts in the File Explorer. Add a new file under source code to HelloAIOZ.sol
below.
// SPDX-License-Identifier: Unlicense
// Specifies that the source code is for a version of Solidity greater than 0.6.8
pragma solidity ^0.6.8;
contract HelloAIOZ {
// The public variables, which can be accessible from outside a contract
string public status;
constructor(string memory initStatus) public {
// setting `status` to initial value
status = initStatus;
}
// A publicly accessible function to updates `status`
function update(string memory newStatus) public {
status = newStatus;
}
}
This is the most basic smart contract on Solidity. The smart contract stores the status
message and lets everyone on the blockchain read/update status
.
Compile Smart Contract
On the left-most bar, select the Solidity Compiler
and compile the contract.
When the compilation process is completed without any errors or warnings, the contract is valid and ready to deploy.
![Compile Remix](../../assets/aioznetwork/compile_remix.png)
Deploying Smart Contract
On the left-most bar, select Deploy & Run transactions
- Select the account to deploy
- Select compiled smart contract to deploy
![Deploy Remix](../../assets/aioznetwork/deploy_remix.png)
-
Enter initial value for
status
as parameter for contract initialized function -
Click
Deploy
>Confirm
Transaction on Metamask
![Deploy Remix_1](../../assets/aioznetwork/deploy_remix_1.png)
- Check Transaction Status from Remix Terminal
![Deploy Remix_2](../../assets/aioznetwork/deploy_remix_2.png)
in [AIOZ Blockchain Explorer](https://testnet.explorer.aioz.network)
Interact with Smart Contract
![Deploy Remix_4](../../assets/aioznetwork/deploy_remix_4.png)
You can interact with all deployed contracts in Remix, select deployed contract
- Click
status
variable to read public value stored on blockchain - Click
update
> Enter new value > Metamask confirmation