Start now →

A .NET Dinosaur in Web3. Day 2

By Alena .NET Dinosaur · Published April 28, 2026 · 2 min read · Source: Web3 Tag
Web3
A .NET Dinosaur in Web3. Day 2

A .NET Dinosaur in Web3. Day 2

Alena .NET DinosaurAlena .NET Dinosaur2 min read·Just now

--

Press enter or click to view image in full size

A .NET Dinosaur in Web3. Day 2.

Yesterday’s dinosaur was accidentally a boy — fixing that took longer than writing the contract.
The pink dinosaur stays. 🦕💅
Now — actual logic.

Counter.sol (a little better than “Hello World”, right?)

The goal: write a simple Counter contract — increment, decrement, reset — with real access rules.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Counter {
uint256 public count;
address public owner;
constructor() {
owner = msg.sender;
count = 0;
}
function increment() public {
count += 1;
}
function decrement() public {
require(count > 0, "Already zero");
count -= 1;
}
function reset() public {
require(msg.sender == owner, "Only owner can reset!");
count = 0;
}
}

What Actually Clicked

In the .NET world we use HttpContext.User to know who's making a request. In Solidity it's msg.sender — the wallet address of whoever called the method. No login system, no JWT, no sessions. Just a cryptographically verified address. The contract knows exactly who you are… always.

The next thing — calling count to check the current value is free. Simple rule: no transaction, no gas. But I got a warning that almost everyone forgets about this — which makes it kind of dangerous for your budget. If you forget to switch from the REAL network to the TEST network, all those transactions will cost you actual money.

Day 2 Score: 10/10

Everything is mapping cleanly to .NET concepts. msg.sender = HttpContext.User. require() = guard clauses. uint256 = unsigned int. The mental model is familiar, the syntax is new.

Tomorrow I want something with real-world application — not a toy example, but a contract that actually does something useful.

Day 3 incoming. 🚀

Following along? I’m documenting every day of this journey. Drop a comment or follow for Day 3.

This article was originally published on Web3 Tag and is republished here under RSS syndication for informational purposes. All rights and intellectual property remain with the original author. If you are the author and wish to have this article removed, please contact us at [email protected].

NexaPay — Accept Card Payments, Receive Crypto

No KYC · Instant Settlement · Visa, Mastercard, Apple Pay, Google Pay

Get Started →