The immutable keyword is used for variables that act very similar to constants, however they can be initialized with a constructor.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
contract exampleOfImmutable {
// usually constant variables are capitalized
address public immutable THE_ADDRESS;
string public immutable MY_DOMAIN;
constructor(string memory _name) {
THE_ADDRESS = msg.sender;
MY_DOMAIN = _name;
}
}
After these immutable variables are created and changed during deployment, they can never be changed again. The purpose of this is to prevent vulnerabilities from editing an important variable, while allowing the developer to edit the variable upon deployment (unlike Constants).