# Solidity smart contract deployment using REMIX IDE

## Deployment using REMIX IDE

1. Open Remix IDE using the below link, <https://remix.ethereum.org/#lang=en&optimize=false&runs=200&evmVersion=null&version=soljson-v0.8.18+commit.87f61d96.js>. The default workspace looks similar like below,

<figure><img src="https://809720161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPsAwLpyOeItHVo4Fslw%2Fuploads%2F9urX0q5MdwOOy84yqmIk%2FDefault-workspace.JPG?alt=media&#x26;token=efec5d4f-bdc2-4ea8-a942-2674633136c8" alt=""><figcaption><p>Default workspace</p></figcaption></figure>

2. A) Next step is to create a workspace, click on the **Workspace** option and select **create -> create workspace**. This will open a new tab to choose the type of workspace as required.

<figure><img src="https://809720161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPsAwLpyOeItHVo4Fslw%2Fuploads%2FvvRhHmuD0TnfXu0ue2HU%2Fworkspace-create-1.jpg?alt=media&#x26;token=af0b247f-50a2-430f-9cb4-4fc871978cf8" alt=""><figcaption><p>Create new workspace</p></figcaption></figure>

B) The new tab has various **Template** options to choose for the new workspace. The option selected here is **Open Zeppelin ->ERC20.** Open Zeppelin is the open source library/framework mainly used in the smart contract deployment for ethereum. It provides a set of audited and reusable contracts for the developers.

<figure><img src="https://809720161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPsAwLpyOeItHVo4Fslw%2Fuploads%2Fi00Q0ZopKdLDIpgURfDk%2Fworkspace-creation-2.jpg?alt=media&#x26;token=5b95164b-a2a2-4115-a580-dea25f172200" alt=""><figcaption><p>Choose Template for workspace</p></figcaption></figure>

C) Click on **OK**, the next page has some customizable template options for the new workspace. Choose the required options and click **OK** to create the workspace.

<figure><img src="https://809720161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPsAwLpyOeItHVo4Fslw%2Fuploads%2Fmh6ggI3xheIF72K7JmXA%2Fworkspace-creation-3.JPG?alt=media&#x26;token=973e6afc-ae0b-4be1-be87-9a868fc3acd5" alt=""><figcaption><p>Template customizable options</p></figcaption></figure>

{% hint style="info" %}
The template settings can be modified anytime after the workspace creation too.&#x20;
{% endhint %}

Now, the **Workspace** is created successfully.

D) The new workspace created will be similar to the below page and it has its own files and folders.

<figure><img src="https://809720161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPsAwLpyOeItHVo4Fslw%2Fuploads%2FpDMvArUN6dmk1MgNutqM%2FOpenziplin-workspace.JPG?alt=media&#x26;token=e3cbc376-c27a-4e3b-a10c-384e3bdbed89" alt=""><figcaption></figcaption></figure>

3. There is one more application called **MetaMask**, which is required to begin the smart contract deployment. If the user has an existing MetaMask wallet then it can be used or else the new account has to be created. The steps to deploy MetaMask is explained in the below section.

{% content-ref url="metamask-deployment" %}
[metamask-deployment](https://pao.peerplays.com/peerplays-2.0/solidity-smart-contracts/metamask-deployment)
{% endcontent-ref %}

4. Once the MetaMask configuration is completed, switch back to the REMIX IDE workspace to resume the steps.
5. Choose **Deploy & Run Transactions** tab from the left pane of the workspace. To select the **Environment** option, click on the drop-down menu to choose **Injected provider - MetaMask.**

<figure><img src="https://809720161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPsAwLpyOeItHVo4Fslw%2Fuploads%2FLk9P8RbY11pIlW9Mguzm%2FEnv-inject-provider.JPG?alt=media&#x26;token=e00ec222-491c-483a-a5ae-7d16f9e574bb" alt=""><figcaption></figcaption></figure>

6. A) Next, a new tab will prompt to connect with Metamask wallet. Choose the desired MetaMask account that has to be connected with the Remix IDE workspace.

<figure><img src="https://809720161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPsAwLpyOeItHVo4Fslw%2Fuploads%2FcLNrL4gnRSHqpgfcG00B%2Fconnect-with-metamask.JPG?alt=media&#x26;token=07cb4bc2-e90d-4829-a0a9-ebb5da3d98f6" alt=""><figcaption></figcaption></figure>

B) Click on **Next** to see the below screen and provide permission for the REMIX IDE to view the wallet details. Finally, click on **Connect** to complete the environment setup.

<figure><img src="https://809720161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPsAwLpyOeItHVo4Fslw%2Fuploads%2F9YgiHpVsiOO2p2cERVRx%2Fconnect-with-metamask-connect.JPG?alt=media&#x26;token=fb28dfe6-cab6-4460-9725-028125f19066" alt=""><figcaption></figcaption></figure>

C) Now, the MetaMask wallet is connected with the REMIX IDE. After successful connection, the Metamask wallet address will be populated in the setup details. Also, the wallet and its balance will be visible from the IDE.&#x20;

<figure><img src="https://809720161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPsAwLpyOeItHVo4Fslw%2Fuploads%2F1ZkkvYPzqOlBINqhma1i%2FRemix-metamask-connected.JPG?alt=media&#x26;token=923ee797-f5fd-4d4f-b6d4-6aeb874964cb" alt=""><figcaption></figcaption></figure>

7. Switch to OpenZeppelin workspace to begin with the smart contract deployment. From the list of folders, select **contracts** and click on **MyToken.sol** which has the default configuration.

<figure><img src="https://809720161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPsAwLpyOeItHVo4Fslw%2Fuploads%2FiaZi8qc7ajBIa7G9jTQg%2Fwork-space-token.JPG?alt=media&#x26;token=d960886d-3769-468f-ad6f-e832617968ba" alt=""><figcaption></figcaption></figure>

8. The contract should be modified based on the requirements. The boiler plate for **MyToken.sol** is given below:

{% code overflow="wrap" %}

````solidity
```remix-solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    constructor() ERC20("TEST_PPY_2.0", "TEST") 
    {
    _mint(msg.sender, 1000000000000000000000);
    }
}
```
````

{% endcode %}

The given example is used to mint 1000 token and based on user option the value can be modified.

{% hint style="info" %}
The token value must be followed by 18 Zero's. Because, the default setting for Ethereum minting is the values must be followed by "0"  up to 18 decimal counts.
{% endhint %}

The contract is modified and it is ready to be deployed. Click on **CTRL+S** to complete the compilation, only then the updates will be reflected.

One more option to compile is, choose **Solidity Compiler** option and select compile **MyToken.sol** button to finish compilation.

<figure><img src="https://809720161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPsAwLpyOeItHVo4Fslw%2Fuploads%2FZ7pjfr9DCadcMuR7Z6oS%2Fcompile-tokens.JPG?alt=media&#x26;token=3cff7926-a18d-4daa-a179-7ea7ca68af89" alt=""><figcaption></figcaption></figure>

9. Next, add the contract script in the Environment value and contract deployment is one step away!

A) Switch to **Deploy & Run Environment** option, choose **MyToken - contract/MyToken.sol** option from the drop down list.

<figure><img src="https://809720161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPsAwLpyOeItHVo4Fslw%2Fuploads%2FfQnpZqyQCjwGbrS2MGy7%2Ftoken-addition.jpg?alt=media&#x26;token=4a7b7367-0d85-4740-a17b-106686c71c67" alt=""><figcaption></figcaption></figure>

B) Click on **Deploy**, the MetaMask window will be prompted to complete the transaction. Click on **confirm** to finish the contract deployment.&#x20;

<figure><img src="https://809720161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPsAwLpyOeItHVo4Fslw%2Fuploads%2F3HQESm3eh7Vwedwzar1c%2Fdeploying-prompted.JPG?alt=media&#x26;token=f06af9b2-00fa-4c4d-9188-de833cb7b290" alt=""><figcaption></figcaption></figure>

10. After confirmation, the deployment process begins and finally the contract deployment will be completed. The contract address is generated and click on copy icon to have a copy of address for verification.

<figure><img src="https://809720161-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPPsAwLpyOeItHVo4Fslw%2Fuploads%2FSORUlXP22koCdQhkN0yO%2Fcontract-deployed.JPG?alt=media&#x26;token=9e65b28c-c3d5-46e5-9205-da3fb40ba568" alt=""><figcaption></figcaption></figure>

The contract address will be similar to the below format:

````
// contract address example
```remix-solidity
0xde1aF1323bD6d092a9199d8f050A9806bcb57530
```
````

Solidity smart contract deployment using REMIX IDE is successful! ✅
