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

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 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 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

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.

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.

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

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.

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.

This is how contracts are deployed on Ramestta!

Last updated