Replies: 2 comments
-
|
🧠 Why the Error Happens An immutable variable in Solidity is not stored in contract storage.
🛠 Correct Usage Example `// SPDX-License-Identifier: MIT contract FeeManager { }` 💡 Why It Must Be Set in Constructor Bytecode is fixed at deploy time So assigning inside a normal function is the same as trying to rewrite deployed bytecode — which is impossible. |
Beta Was this translation helpful? Give feedback.
-
|
Ohh that's a great approach for solving this problem |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Immutable variable error in Hardhat — am I assigning it wrong?
I declared an immutable variable in Solidity, but Hardhat throws TypeError: Cannot write to immutable variable when I assign it inside a function. I thought immutables can be set later.
Am I misunderstanding how immutables are supposed to be assigned?
Beta Was this translation helpful? Give feedback.
All reactions