Smart contracts are programs deployed on-chain
Ethereum lets developers deploy programs to the blockchain. A program has its own address, can store state, and responds to requests under the rules in its code. When a transaction calls a contract, Ethereum nodes apply the same execution rules and check the result and the updated state.
Imagine an on-chain attendance app. A participant sends a check-in transaction, and the contract checks whether that address has already checked in today. If the conditions are met, the contract records the check-in. It can read only the information its code can access. If it needs to know what happened at an event in the physical world, it also needs a reliable data source.
How ETH, gas, and fees relate
ETH is Ethereum’s native asset. Gas measures the computing resources an operation consumes. The transaction fee typically depends on the gas used and the effective price per unit of gas, and is paid in ETH. More complex transactions generally use more gas. Network demand also affects fees.
Suppose a transaction attempts to check in an address that has already checked in. After the transaction is included in a block, the contract call may revert and leave the attendance record unchanged. The resources used to execute it still incur a fee.
How tokens track balances and allowances
Ethereum supports many token contracts. ERC-20 is a common interface standard for operations such as checking balances, transferring tokens, and approving an allowance. When you receive an ERC-20 token, its contract updates the token balance assigned to your address.
Some apps ask you to approve a token allowance before you can perform a later action. This approval gives a specific address an allowance to spend your tokens. Spending within that allowance may require no separate signature from you. Review the network, spender address, token, and allowance in the wallet prompt.
Which permissions matter when using a contract?
Contracts follow their code, which can contain bugs or give an administrator powers to upgrade the program, pause operations, or change settings. Check the rules the current code enforces, who can change those rules, and whether the program depends on off-chain data or other contracts.