▶️Write and compile the smart contract
Go to the contracts folder and open the
.sol
file (smart contract).
We renamed it to Hello_swtr.sol

Paste the smart contract into your
Hello_swtr.sol
file.
Currently, only support Solidity compilers up to 0.8.19
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;
//This contract is only intended for testing purposes
contract Swisstronik {
string private message;
/**
* @dev Constructor is used to set the initial message for the contract
* @param _message the message to associate with the message variable.
*/
constructor(string memory _message) payable{
message = _message;
}
/**
* @dev setMessage() updates the stored message in the contract
* @param _message the new message to replace the existing one
*/
function setMessage(string memory _message) public {
message = _message;
}
/**
* @dev getMessage() retrieves the currently stored message in the contract
* @return The message associated with the contract
*/
function getMessage() public view returns(string memory){
return message;
}
}
Compile the contract
To compile the smart contract, run npx hardhat compile
in your terminal (if you are using VSCode, you can open a new terminal with Ctrl + Shift + ` )
After successful compilation:
You should get the message Compiled 1 Solidity file successfully in your terminal
A new artifacts folder should be created

Now you are ready to deploy this contract on Swisstronik! 🚀
Last updated
Was this helpful?