Deploy a Contract in the MVM
Last updated
Last updated
We start with a fresh MetaMask installation from the Chrome or Firefox store. Download the extension and follow the "get started" guide. You need to create a wallet, set a password, and store your secret backup phrase (make sure to store these in a secure place). This will generate an Ethereum-compatible address:
From the βSettings -Networksβ dropdown menu select the RPC network. Name it as you like and add the new RPC URL and use the following parameters to connect to the EVM:
Testnet Deployment
New RPC URL: https://vm.mvs.org/testnet_rpc/
Chain ID: 43
Currency Symbol: ETP
Mainnet Deployment
New RPC URL: https://vm.mvs.org/mainnet_rpc/
Chain ID: 23
Currency Symbol: ETP
From Metamask select your new added Network:
Getting Started with Remix?
Now letβs fire up Remix to exercise some more advanced functionalities in MVM module. Launch Remix by navigating to https://remix.ethereum.org/. In the main screen, under Environments, select Solidity to configure Remix for Solidity development, then navigate to the File Explorers view:
We will create a new file to save the Solidity smart contract. Hit the + button under File Explorers and enter the name "MyToken.sol" (or whatever name you want) into the popup dialog.
Now let's paste the following smart contract into the editor tab that comes up: //begin codepragma solidity ^0.7.0;import 'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.2.0-solc-0.7/contracts/token/ERC20/ERC20.sol';// This ERC-20 contract mints the specified amount of tokens to the contract creator.contract MyToken is ERC20 { constructor(uint256 initialSupply) ERC20("MyToken", "MYTOK") public { _mint(msg.sender, initialSupply); }}//end codeCopy
This is a simple ERC-20 contract based on the current Open Zeppelin ERC-20 template. It creates MyToken with symbol MYTOK and mints the entirety of the initial supply to the creator of the contract. Once you have pasted the contract into the editor it should look like this. Now navigate to the compile sidebar option to press the βCompile MyToken.solβ button:
These are default settings but you can choose your version of Solidity.
Now we can deploy the contract by navigating to the Deployment sidebar option. You need to change the topmost βEnvironmentβ dropdown from βJavaScript VMβ to βInjected Web3β which tells Remix to use the MetaMask injected provider, which will point it to your RPC standalone node. As soon as you select this you will be prompted to allow Remix to connect to your MetaMask account:
Select from MetaMask the account to be used for deployment and then click next on Metamask button.
Press βNextβ in Metamask to allow Remix to access the selected account. Back on the Remix side, you should see the account to be used for deployment as the one that is managed by MetaMask. Next to the Deploy button, letβs specify an initial supply of 8M tokens. Since this contract uses the default of 18 decimals, the value to put in the box is 8000000000000000000000000:
Once you have entered this value hit the Deploy button. You will be prompted in MetaMask to confirm the contract deployment transaction:
After you press confirm and the deployment is complete, you will see the transaction listed in MetaMask and the contract will appear under Deployed Contracts in Remix.
Once the contract is deployed, you can interact with it from within Remix. Drill down on the contract under βDeployed Contracts.β Clicking on name, symbol, and totalSupply should return βMyToken,β βMYTOK,β and β8000000000000000000000000β respectively. If you copy the address from which you deployed the contract, and paste it into the balanceOf field, you should see the entirety of the balance of the ERC20 as belonging to that user. Also copy the contract addres by click the button next to the contract name and address.