Hexncoin

💱 DeFi & Tokens

Smart Contracts

Programs that run on-chain and power everything after money.

6 min read

Code that is the agreement

A smart contract is a program stored on the blockchain. When someone calls it, every node runs the same code and agrees on the result. There's no server that could go offline and no operator who could change the rules on a whim.

Because the code is public and runs deterministically, you can read exactly what a contract will do before you use it. 'Code is law' captures both the power and the danger: bugs execute just as faithfully as intended features.

Gas: paying for computation

Running contract code isn't free. Each operation costs gas, and you pay the total in the chain's native token. Gas both compensates validators and stops anyone from clogging the network with infinite loops.

When the network is busy, gas prices rise - the same transaction can cost cents one hour and dollars the next.

Check your understanding

2 questions from this lesson, with the correct answer already marked.

1. What is a smart contract?

  • A legal PDF stored on-chain
  • A program deployed on-chain that runs exactly as written when called
  • A type of wallet
  • An insurance policy

It's code on the blockchain that executes deterministically for everyone who calls it, no middleman required.

2. What is gas?

  • A stablecoin
  • The fee paid for the network to process your transaction
  • A staking reward
  • A type of NFT

Gas is the fee that pays for the computation and storage your transaction uses.