# Deploy smart contracts

Now that you know what Ramestta is, let's deploy a contract.

1. **Setting up MetaMask with Ramestta.**
2. **Obtaining test RAMA.**

For the smart contract to be deployed and interact with, you will need some test BONE tokens.

Copy your Metamask address and paste it into the address field of the faucet, and click on submit.\
The faucet will send you 0.1 test RAMA.\
\
You can find the faucet link by clicking here.

**coming soon**

### Writing the contract <a href="#deploying-the-contract" id="deploying-the-contract"></a>

Make a new solidity file using REMIX Ethereum, for example.

Your new Solidity script should contain the following code:

Contract writing

```
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.0 <0.7.0;
contract SimpleStorage {
    uint storedData;
    function set(uint x) public {
        storedData = x;
    }
    function get() public view returns (uint) {
        return storedData;
    }
}
```

* Line 1: Specifying [SPDX license](https://spdx.org/licenses/) type, which is an addition after Solidity ^0.6.8. \
  Whenever the source code of a smart contract is made available to the public, these licenses can help resolve/avoid copyright issues. If you do not wish to specify any license type, you can use a special license [UNLICENSED](https://spdx.org/licenses/Unlicense.html) or simply skip the whole comment (it won’t result in an error, just a warning).
* Line 2: On the second line, we are declaring which Solidity compiler we want to use. For instance, we are targeting any version between ≥ 0.4.0 and <0.8.0.
* Line 3: You declare your contract here and name it as **SimpleStorage**.
* Line 4: Declaring a uint (Unsigned Integer) variable named **storedData.** This variable will be used to store data.
* Line 5-7: Next, you will add a **set** function, using which you will change the value of your variable **storeData**. The **set** function accepts a parameter **x** whose value you are placing into **storeData**. In addition, the function is marked as public which means that the function can be called outside the scope of this function and by other contracts.
* Line 8-10: You will add a **get** function to retrieve the value of **storeData** variable. This function is marked as view, which tells the Solidity compiler that this is a read-only function.\
  Other than that, the **get** function also has returns (uint), which means that the function will return a uint value.

### Deploying the contract <a href="#deploying-the-contract" id="deploying-the-contract"></a>

Click on the Solidity logo from the left menu and click on compile. After successful compilation, a green tick will appear on the Solidity logo.

<figure><img src="https://3495787697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iD8qFVyjPp1N1FbL3AL%2Fuploads%2F11YOpvLIfVj8qUwlpwir%2FScreenshot%202024-01-16%20at%2011.33.04%20AM.png?alt=media&#x26;token=6ea6644a-c5a2-4b59-af49-8359f4a17c52" alt=""><figcaption></figcaption></figure>

Now, click on the option from the left menu to deploy the complied contract and select Injected Web3 as the environment. Below the environment, the name and chainid of your network will appear. Make sure you have the correct contract name selected under the contract option. Once you have checked everything, click on "Deploy" and accept the transaction from the MetaMask pop-up window.

<figure><img src="https://3495787697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iD8qFVyjPp1N1FbL3AL%2Fuploads%2FYW5xS7JgZOZAIaeslKK9%2FScreenshot%202024-01-16%20at%2011.41.04%20AM.png?alt=media&#x26;token=89d217d3-9195-4195-9169-c0ef02de22d2" alt=""><figcaption></figcaption></figure>

Once the contract deployment transaction is approved, the deployed contract will appear under the "Deployed Contracts" section.

<figure><img src="https://3495787697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iD8qFVyjPp1N1FbL3AL%2Fuploads%2FclUbP5z8CgrwmurB9N8c%2FScreenshot%202024-01-16%20at%2011.46.21%20AM.png?alt=media&#x26;token=4140a5b8-a8bd-429b-8a21-c37932a7dffc" alt=""><figcaption></figcaption></figure>

Expand the deployed contract and click on "get". It will return the value of **storedData**, which is currently zero since you have not input any number yet.

<figure><img src="https://3495787697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iD8qFVyjPp1N1FbL3AL%2Fuploads%2FgWKyxnJ3YNOl0ExbEfyG%2FScreenshot%202024-01-16%20at%2011.48.31%20AM.png?alt=media&#x26;token=5e5b25f7-fa8d-49d3-9c89-0e31c4644523" alt=""><figcaption></figcaption></figure>

To input a value, enter a number in the field near the set button, click on "set" and approve the transaction from the MetaMask pop-up. Once the transaction is approved, the value of **storedData** will be the input number. To verify this, click on "get", and the previously input value will be printed.

<figure><img src="https://3495787697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iD8qFVyjPp1N1FbL3AL%2Fuploads%2FFjRLcmOe5FwJ0a8rNRwN%2FScreenshot%202024-01-16%20at%2011.49.12%20AM.png?alt=media&#x26;token=2a175696-a7ff-49ed-9792-891dda86d2e4" alt=""><figcaption></figcaption></figure>

This is how contracts are deployed on Ramestta!
