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
2 answers
30 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 ...
1 vote
1 answer
100 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 ...
1 vote
2 answers
37 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) { ...
  • 290
0 votes
0 answers
8 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 ...
  • 1
0 votes
1 answer
20 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 ...
0 votes
2 answers
192 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 ...
1 vote
1 answer
163 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) { ...
  • 523
1 vote
0 answers
31 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){ ...
2 votes
1 answer
260 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 ...
  • 523
2 votes
1 answer
973 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; } ...
  • 523
1 vote
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 ...
  • 523
1 vote
0 answers
38 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://imgur.com/a/KX6TRgi Is my art piece on ...
0 votes
1 answer
69 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 ...
1 vote
1 answer
92 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 ...
  • 935
0 votes
1 answer
65 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 ...
  • 43
2 votes
1 answer
551 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. ...
  • 379
0 votes
1 answer
265 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 ...
  • 3
28 votes
3 answers
9k 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?
20 votes
2 answers
14k views

What is the immutable keyword in Solidity?

What is the immutable keyword in Solidity and how do I use it?