Documentation/Smart Contract Basics
Intermediate

Smart Contract Basics

Learn the fundamentals of smart contracts on Tetreum Testnet and how to deploy your first contract.

What are Smart Contracts?

Smart contracts are self-executing contracts with the terms of the agreement directly written into code. They run on the Tetreum blockchain and automatically execute when predetermined conditions are met.

Key Features:

  • Trustless execution - no intermediaries needed
  • Immutable - cannot be changed once deployed
  • Transparent - code is publicly verifiable
  • Cost-effective - reduces transaction costs
Your First Smart Contract

Here's a simple "Hello World" smart contract written in Solidity:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract HelloWorld {
    string public message;
    
    constructor() {
        message = "Hello, Tetreum!";
    }
    
    function setMessage(string memory newMessage) public {
        message = newMessage;
    }
    
    function getMessage() public view returns (string memory) {
        return message;
    }
}

Contract Breakdown:

  • string public message - Stores a message on the blockchain
  • constructor() - Runs once when the contract is deployed
  • setMessage() - Function to update the message
  • getMessage() - Function to read the current message
Development Tools

Essential tools for smart contract development on Tetreum:

Remix IDE

Browser-based IDE for writing and testing smart contracts

Open Remix

Hardhat

Professional development environment for smart contracts

Learn Hardhat
!
Contract Deployment Process

Follow these steps to deploy your smart contract to Tetreum:

  1. 1

    Write Your Contract

    Create your smart contract using Solidity in Remix IDE or your preferred environment.

  2. 2

    Compile the Contract

    Compile your Solidity code to generate bytecode and ABI.

  3. 3

    Connect to Tetreum

    Configure your wallet and development environment to connect to Tetreum testnet.

  4. 4

    Deploy and Verify

    Deploy your contract and verify the source code for transparency.

Explore More Examples

Check out our Smart Contract Code Snippet Library for more examples and advanced patterns.

Browse Code Snippets

Ready to Build?

Now that you understand the basics, explore our advanced documentation and start building on Tetreum.