EVM reads and writes in 32-byte (256-bit) slots. Variables smaller than 32 bytes that are declared consecutively share a slot, reducing SSTORE operations. A new SSTORE costs 20,000 gas; packing avoids additional slot allocations.
What to verify: Consecutive variables of the same or smaller combined size (≤32 bytes) are grouped together. Place uint128 next to uint128, not separated by a uint256.
Custom errors are encoded as 4-byte selectors, whereas revert strings store the full string in contract bytecode and in memory at runtime. Custom errors save gas on both deployment (smaller bytecode) and execution (cheaper encoding).
Solidity 스마트 계약을 위한 가스 최적화 패턴. 계약 배포 비용, 런타임 가스 사용량 또는 스토리지 효율성을 최적화할 때 사용합니다. 스토리지 패킹, 사용자 정의 오류, 불변 변수, 호출 데이터 최적화, 루프 패턴, 어셈블리 사용 및 Solady 가스 최적화 대안을 다룹니다. 가스 최적화, 스토리지 레이아웃, 배포 비용 절감 또는 EVM 효율성과 관련된 작업을 트리거합니다. 출처: whackur/solidity-agent-toolkit.