Questions tagged [immutable]

The immutable keyword can be used on state variables which causes them to be read-only, but assignable in the constructor. The value will be stored directly in the code.

Filter by
Sorted by
Tagged with
0 votes
1 answer
20 views

How the language is created? (Fundamental question rather than solidity)

I am curious about how 'immutable' and 'constant' commands enable users not to change after the declaration. Should I compile it into assembly language to know that? How the language is created?
Wonjae Choi's user avatar
2 votes
1 answer
126 views

Do immutable variables influence the contract bytecode?

Suppose you have a contract like this: pragma solidity >=0.8.19; contract Bar { uint256 public immutable value; constructor(uint256 value_) { value = value_; } } Will Bar ...
Paul Razvan Berg's user avatar
0 votes
2 answers
57 views

Enhancing testability of contracts with immutable state variables

I have been encountering challenges when testing contracts that utilize immutable state variables. As we know, immutable variables are assigned only once during contract deployment and cannot be ...
Ahmed Ihsan Tawfeeq's user avatar
1 vote
1 answer
642 views

Are immutable variables part of the contract storage?

Suppose that you define an immutable variable like this: contract Contract { uint256 public immutable foo; uint256 public bar; constructor() { foo = 50; } Will bar be the ...
Paul Razvan Berg's user avatar
1 vote
2 answers
263 views

Store string as immutable

I want to deploy an nft contract and i want to enter URI in constructor: string immutable i_uri; constructor(string memory name, string memory symbol, string memory uri) ERC721(name,symbol) { ...
Alireza's user avatar
  • 350
0 votes
0 answers
10 views

Sent etherium from Stake to my immutable wallet. Didn't get anything

I sent around 0.04 ETH to my etherium wallet, (which is connected with my email). I didn't receive anything in my wallet and now I'm wondering if I could get it. I'm new to crypto and don't really ...
Ray's user avatar
  • 1
0 votes
1 answer
67 views

Spotting Admin keys

Doing some research on a few different Ethereum contracts. Is there a good way to tell if a contract has admin keys to invalidate tokens in a wallet or change the code after deployment? Basically I ...
uncommon's user avatar
2 votes
2 answers
429 views

Solidity immutable equivalent in huff

In the huff language, I am able to specify a constant variable with the constant keyword. (huff docs) #define constant NUM = 0x420 #define constant HELLO_WORLD = 0x48656c6c6f2c20576f726c6421 #define ...
Patrick Collins's user avatar
1 vote
1 answer
319 views

Why can immutable state variable not be initialised inside an if else statement?

I would like to initialise an immutable state variable inside an if else statement as follows: contract Simple { bool immutable isNatural; constructor(uint number) { if (number != 0) { ...
MShakeG's user avatar
  • 1,613
1 vote
0 answers
42 views

does solidity compiler convert to immutable implicitly?

I was wondering if the solidity compiler automatically sets a state variable to immutable if it is never modified? example contract MyContract { uint256 myNumber; constructor(uint256 _myNumber){ ...
Rachid Boudjelida's user avatar
2 votes
1 answer
391 views

Why are functions that access immutable variables not pure?

My understanding is that immutable variables are basically equivalent to constant variables however the former is initialised in the constructor whereas the later at declaration, however both are ...
MShakeG's user avatar
  • 1,613
4 votes
1 answer
2k views

Is it possible to have an immutable or constant struct?

Is it possible to have a struct that is or has fields that are constant or immutable? // struct with constant or immutable fields: struct MyStruct { uint constant number; int immutable integer; } ...
MShakeG's user avatar
  • 1,613
2 votes
1 answer
2k views

Is the gas cost for constant and immutable about equal?

According to this question the Solidity 0.5.0 Compiler cannot compute a constant state variable that invokes a function, however I'm also experiencing this issue on Solidity 0.8.10 using the ...
MShakeG's user avatar
  • 1,613
1 vote
0 answers
42 views

How Ethereum NFT Protect Artist Work ( How NFT IMMUTABILITY works on BLOCKCHAIN)?

Hi Guys let discuss how NFT Immutable works on ethereum blockchain I'm new to nft, just created my first one with opensea:) as in image1. My question https://i.stack.imgur.com/ZgxB5.jpg Is my art ...
Diamond codes's user avatar
0 votes
1 answer
83 views

How to verify that a smart contract was deployed by us?

I would like a method called from Solidity to either verify the hash of an entire smart contract's code, or read some immutable EVM property that contracts expose that say who deployed them, e.g. a ...
Gregory Magarshak's user avatar
1 vote
1 answer
120 views

Cannot reproduce Etherscan verified compilation for 0.6.6 contract

I'm trying to reproduce the following contract compilation on Etherscan: https://etherscan.io/address/0x7a250d5630b4cf539739df2c5dacb4c659f2488d#code. Runtime bytecode on-chain I can get the runtime ...
Peteris's user avatar
  • 1,005
0 votes
1 answer
75 views

Is Ethereum blockchain really temper proof or immutable?

Suppose there is a user A which transfers some ethers to user B through a proper transaction. So is it possible to alter the transaction. Something like going back to the block which contains the ...
krritik's user avatar
  • 43
2 votes
1 answer
730 views

What is the best way to store data/information while writing smartcontract?

Smart contracts are immutable. Unless we're 100% sure that our smart-contract is fully functional without any exception we never want to push that in the main net. That's why we have public test net. ...
NinjaMAN's user avatar
  • 419
0 votes
1 answer
281 views

Is it feasible to write a DApp that targets multiple blockchains

This question does not target Ethereum specifically, but I hope you can help me out! If my questions are too specific, I apologize in advance. I'm trying to utilize Blockchain's immutable + provable ...
mkV's user avatar
  • 3
31 votes
3 answers
10k views

What is the difference between the constant and immutable keywords in Solidity?

What is the difference between the constant and immutable keywords in Solidity and how do I use them?
Shane Fontaine's user avatar
24 votes
2 answers
16k views

What is the immutable keyword in Solidity?

What is the immutable keyword in Solidity and how do I use it?
Shane Fontaine's user avatar