Remix
How to deploy an EVM contract to one of our networks: peaq/krest/agung using Remix.
1. Setup Remix IDE
Get the proper setup in the Remix IDE website. Please visit the link:
When you go to Remix for the first time please create a new workplace with a Basic template.
2. Add Network to Metamask
After you have created a basic template, smart contracts will be created for you. Before we can deploy them however, we need to make sure that the network where you have funds has been successfully added to MetaMask. It is possible to get $AGUNG from the peaq discord faucet, so it is recommended to follow the tutorial to get $AGUNG, and then transfer these funds to your Metamask as shown in Fund EVM Wallet.
Once you have successfully transferred tokens to your MetaMask wallet you are ready for the next step.
3. Compile Contract
For this particular walk-through, we will be deploying the auto-generated 1_Storage.sol that is created by Remix when you use a basic template. Please click on the blue button to compile the smart contract. Upon successful compilation there will be a green checkmark next to the compile sidebar.
4. Deploy Contract
Next we will deploy the contract. To do this select the Deploy and Run Transactions sidebar in Remix. Click on Injected Provider - MetaMask for the environment. You can ensure the network is correct by checking the chain id below this tab. This walk-through is deploying on agung, so the chain id of 9990 is correct. If you are deploying on krest/peaq you can look at the quick start page to see what chain id is expected.
Once you have confirmed the chain id you can click the orange deploy contract to trigger the transaction. A MetaMask popup will be appear where you are able to confirm the deployment of the storage contract. Make sure you have the native token in your wallet, or else the transaction will fail. Upon successfully deployment a transaction log will be sent to the Remix console where you can see transaction hash, block number, gas used, etc for that particular transaction.
5. Interacting with the Contract
After you deploy the contract, a user interface will be generated on the sidebar for you to interact with it to test functionality. For this particular example you can trigger a write transaction that will store and retrieve an integer on the blockchain. By clicking the orange store button a new transaction will be triggered on the network. Again, the user will need to sign the transaction by clicking the confirm popup from MetaMask. After proper execution you are then able to successfully retrieve the previously stored integer on chain.
Congrats! You have just deployed and interacted with an EVM Smart Contract on the agung test network using Remix!