This week began with gas optimization techniques in Solidity, followed by an exploration of oracle systems and hands-on work with Chainlink’s Verifiable Random Function (VRF) and other tools.
To reduce transaction costs, we learned several key strategies:
Using uint256/int256 over smaller types (EVM wordsize optimization).
Minimizing storage writes by caching variables in memory.
Packing variables into fewer storage slots (struct packing).
Using external visibility for functions when possible.
Leveraging events over storage for non-critical data.
Example: Struct Packing & Storage Savings
Other optimizations:
calldata over memory for function parameters.
Loop bounds caching: Store array.length outside loops.
Early reverts: Check conditions before heavy operations.
Oracles are bridges between blockchains and external data (e.g., APIs, weather data). They enable smart contracts to interact with off-chain information securely.
we focused on chainlink as our oracle for the class,
Chainlink is the most widely used decentralized oracle network. It provides:
Tamper-proof data via multiple node operators.
Modular services like VRF, Automation, and Data Feeds.
Problem: Blockchains are deterministic; randomness is hard.
Solution: Chainlink VRF provides provably fair randomness with:
On-chain verification: Uses cryptographic proofs.
User-paid requests: Requires LINK tokens for requests.
Example: Requesting Randomness
Thats a bried summary for the week and im excited on the grounds covered so far and what the future holds.