Smart Contract Basics
Learn the fundamentals of smart contracts on Tetreum Testnet and how to deploy your first contract.
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
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 blockchainconstructor()- Runs once when the contract is deployedsetMessage()- Function to update the messagegetMessage()- Function to read the current message
Essential tools for smart contract development on Tetreum:
Follow these steps to deploy your smart contract to Tetreum:
- 1
Write Your Contract
Create your smart contract using Solidity in Remix IDE or your preferred environment.
- 2
Compile the Contract
Compile your Solidity code to generate bytecode and ABI.
- 3
Connect to Tetreum
Configure your wallet and development environment to connect to Tetreum testnet.
- 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 SnippetsReady to Build?
Now that you understand the basics, explore our advanced documentation and start building on Tetreum.