Deploy Smart Contract

Now you are ready to develop & deploy smart contract on MEVerse. We have used Truffle as an example, as it is the most widely used tool.

Create Project Directory

First, create a directory to store the source code

$ mkdir meverse-test
$ cd meverse-test

Initialize Truffle

To deploy contract, initialize Truffle

$ truffle init

Write simple solidity contract

Create MEVerseGreeter.sol at meverse-test/contracts directory

$ cd contracts
$ touch MEVerseGreeter.sol
$ vi MEVerseGreeter.sol

Write following code in MEVerseGreeter.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.5.6;
contract Mortal {
    /* Define Variable owner of the type address */
    address payable owner;
    /* This function is executed at initialization and sets the owner of the contract */
    constructor () public { owner = msg.sender; }
    /* Function to recover the funds on the contract */
    function kill() public payable { if (msg.sender == owner) selfdestruct(owner); }
}

contract MEVerseGreeter is Mortal {
    /* Define variable greeting of the type string */
    string greeting;
    /* This runs when the contract is executed */
    constructor (string memory _greeting) public {
        greeting = _greeting;
    }
    /* Main function */
    function greet() public view returns (string memory) {
        return greeting;
    }
}

Modify Migration Script

Deploy contract with hdwallet-provider. Install the library first.

  • you can also deploy contracts written via Truffle's Dashboard, please refer to the Dashboard for more details.

Use Truffle Dashboard : https://trufflesuite.com/docs/truffle/how-to/use-the-truffle-dashboard/

Modify MEVerse Testnet network information at truffle-config.js

Deploy Smart Contract with Truffle

Last updated