peaq
Search…
How to deploy an EVM compatible Smart Contract on Agung (peaq Testnet)

Pre-requisites?

1. A Polkadot js wallet on Agung network. 2. An Ethereum wallet (Metamask) on Agung network. 2. An account on Discord.com 3. Joined the channel #agung-faucet 4. Get AGNG tokens using the Faucet bot in our discord channel. (You will need them later to pay for gas) 5. Choose a Development Environment like Remix
Overview
The Agung network implements a full featured Ethereum Virtual Machine (EVM), allowing you to use Solidity as a programming language to create smart contracts, or to port any existing Ethereum smart contract without changes.

Write a simple Solidity smart contract

Lets use a simple ERC-20 standard fungible token creation, using Open Zeppelin libraries.
1
// SPDX-License-Identifier: MIT
2
pragma solidity ^0.8.2;
3
4
import "@openzeppelin/[email protected]/token/ERC20/ERC20.sol";
5
import "@openzeppelin/[email protected]/token/ERC20/extensions/ERC20Burnable.sol";
6
import "@openzeppelin/[email protected]/access/Ownable.sol";
7
import "@openzeppelin/[email protected]/token/ERC20/extensions/draft-ERC20Permit.sol";
8
9
contract Token is ERC20, ERC20Burnable, Ownable, ERC20Permit {
10
constructor() ERC20("Token", "TOKE") ERC20Permit("Token") {
11
_mint(msg.sender, 50 * 10 ** decimals());
12
}
13
14
function mint(address to, uint256 amount) public onlyOwner {
15
_mint(to, amount);
16
}
17
}
18
Copied!

Use Remix

Use Remix by navigating to https://remix.ethereum.org/. Under Environments, select Solidity to configure Remix for Solidity development:
Then navigate to the File Explorers view, create a new file, and paste the example code above.
In the left menu, navigate to the "Solidity Compiler" item. Leave the compiler version to default one and language to Solidity.
Press Compile <Token.sol> button
Now the contract is compiled. Only left to deploy to Agung network. Navigate to the "Deploy & Run Transactions" item.
Go to your Metamask Chrome extension, and make sure you have already added and selected Agung Network. If you dont, go to step #2 of this topic From the "Enviroment" dropdown, select Injected Web3. Remix will use the selected network, in this case, Agung network. Select the contract to deploy in the "Contract" dropdown.
Press Deploy button. Metamask will require you to sign the transaction and pay for fees. (If you dont have AGNG tokens, please go to the top and get through the pre-requisites to get some from our Faucet Bot on the Discord Channel)
Press "Confirm" button, return automatically to Remix IDE and your compiled Smart Contract should be on its way to be executed and stored in the blockchain.
You can interact with your Smart Contract directly from Remix, in the same "Deploy & Run Transactions" section, under the reference "Deployed contracts".