Deploying a Smart Contract

Here we will deploy a Solidity smart contract on the Milkomeda A1 rollup. In this example, we will use Remix to deploy the contract. You can access Remix by visiting the following link: Remix IDE

First, create the solidity smart contract file. Inside the Remix window, click the "Contracts" folder in the left panel, then click the "New File" button in the central panel.

Now you will be prompted to enter a filename for a new Solidity smart contract. The filename is arbitrary, but for the purposes of this example we will be deploying an ERC-20 smart contract so we will name the file "Test_ERC20.sol". Type the filename and press Enter. The cursor should move to the edit panel where you can input your Solidity code. Enter the following:

pragma solidity ^0.7.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0-solc-0.7/contracts/token/ERC20/ERC20.sol";

contract Token is ERC20 {

    constructor () ERC20("Token", "TKN") {
        _mint(msg.sender, 1000000 * (10 ** uint256(decimals())));
    }
}

Next, click the "Solidity compiler" icon on the left side of the screen, choose a compiler version (for this example we will use 0.7.6+commit.7338295f), and then click "Compile Test_ERC20.sol", as shown.

Click the "Deploy and run transactions" icon on the left, and from the "Environment" pulldown select "Injected Web3", as shown. This will bring up the MetaMask screen where you will need to click "Next" and then "Connect" to connect your C1 wallet with Remix.

With your MetaMask wallet now connected, click the "Deploy" button to deploy the smart contract to the Milkomeda A1 Rollup.

Confirm the transaction in MetaMask.

You should now see the following under "Deployed Contracts" on the left side of the Remix IDE screen.

You can copy the address of the ERC20 smart contract and use it in Metamask to add your recently created tokens. Click on Import tokens and then paste the contract address.

Finally, click on Add Custom Token and you should be able to see your tokens! Now you are able to transfer them and interact with smart contracts.

Last updated