A-Z of building dApps on ICE — Part 2: Smart Contracts

What you will learn

What are Smart Contracts?

How Smart Contracts work ?

Benefits of smart contracts

pragma solidity >=0.4.16 <=0.8.12;contract Greeter {  string greetMsg = “Hello there!”;  function setGreetMsg(string memory _greetMsg) public {
greetMsg = _greetMsg;
function greet() public view returns (string memory) {
return greetMsg;
// SPDX-License-Identifier: GPL-3.0pragma solidity >=0.4.16 <=0.8.12;contract MyToken {
address public admin;
mapping (address => uint256) balances;
event Transfer(address from, address to, uint256 amount);
event Mint(address to, uint256 amount);
constructor() {
admin = msg.sender;
function balanceOf(address account) public view returns (uint256) {
return balances[account];
function mintTo(address recipient, uint256 amount) public {
require(msg.sender == admin, "Unauthorized");
balances[recipient] += amount;
emit Mint(recipient, amount);
function transfer(address recipient, uint256 amount) public {
require(amount < balances[msg.sender], "Insufficient balance");
balances[msg.sender] -= amount;
balances[recipient] += amount;
emit Transfer(msg.sender, recipient, amount);

This example is inspired from SubCurrency contract example on the Solidity docs.

Create a new Workspace
Compile smart contract
Deploying smart contract




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store