pragma
– Specifies compiler version or enables experimental features.import
– Imports other Solidity files.contract
– Defines a new contract.library
– Defines a reusable library without storage.interface
– Defines an interface with function declarations but no implementations.
bool
– Boolean type (true
orfalse
).uint
– Unsigned integer (e.g.,uint8
,uint256
).int
– Signed integer (e.g.,int8
,int256
).address
– Holds an Ethereum address (20 bytes).bytes
– Dynamically sized byte array.bytes1
tobytes32
– Fixed-size byte arrays.string
– UTF-8 encoded text.mapping
– Key-value store (mapping(keyType => valueType)
).struct
– Custom data structure.enum
– Enumeration type.
function
– Defines a function.modifier
– Alters function behavior.constructor
– Special function executed once at deployment.receive
– Handles incoming Ether with empty calldata.fallback
– Executes when receiving unknown data.
public
– Accessible from anywhere.private
– Accessible only within the contract.internal
– Accessible within the contract and derived contracts.external
– Callable from other contracts but not internally.
view
– Does not modify the state.pure
– Neither reads nor modifies the state.payable
– Allows receiving Ether.
new
– Creates a new contract instance.delete
– Resets a variable to its default value.this
– Refers to the current contract instance.selfdestruct
– Destroys the contract and sends Ether to an address.
if
,else
– Conditional statements.for
,while
,do
– Loop constructs.break
– Exits a loop.continue
– Skips the current loop iteration.return
– Exits a function with a value.try
,catch
– Handles external contract call failures.
storage
– Permanent storage.memory
– Temporary storage during function execution.calldata
– Non-modifiable function argument storage.
require
– Checks a condition and reverts if false.assert
– Used for internal error detection.revert
– Aborts execution and reverts changes.
event
– Declares an event for logging.emit
– Triggers an event.
is
– Indicates contract inheritance.super
– Calls a function from a parent contract.abstract
– Defines an abstract contract.override
– Overrides a function in a derived contract.virtual
– Allows a function to be overridden.
constant
– Declares an immutable variable.immutable
– Variable value is set at deployment and read-only afterward.anonymous
– Used withevent
to remove indexed event signature from logs.indexed
– Marks event parameters as indexable.assembly
– Enables inline Yul (low-level assembly language).