Create MEVerseGreeter.sol in meverse-test/contracts directory.
$ cd contracts
$ touch MEVerseGreeter.sol
$ vi MEVerseGreeter.sol
Write the 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;
}
}
5. Modify Migration Script
Deploy contract with hdwallet-provider. Install the library first.
$ npm install @truffle/hdwallet-provider
you can also deploy contracts written via Truffle's Dashboard, please refer to the Dashboard for more details.