Complete the code to declare a constant value for the token name.
contract Token {
string public constant [1] = "MyToken";
}Constants in blockchain smart contracts are usually named in uppercase letters with underscores.
Complete the code to declare an immutable variable for the contract owner address.
contract Ownership {
address public immutable [1];
constructor(address _owner) {
[1] = _owner;
}
}Immutable variables are usually named in camelCase and set once during contract deployment.
Fix the error in the code by choosing the correct keyword to declare a constant.
contract Example {
uint256 public [1] VALUE = 1000;
}immutable instead of constant for fixed values.var or let.The keyword constant is used to declare compile-time constants in smart contracts.
Fill both blanks to declare an immutable uint variable and assign it in the constructor.
contract Config {
uint256 public [1] [2];
constructor(uint256 _value) {
[2] = _value;
}
}immutable keyword.The variable name must be the same in declaration and assignment. The keyword immutable is missing and should be added before the variable name.
Fill all three blanks to declare a constant string, an immutable address, and assign the immutable in the constructor.
contract Demo {
string public constant [1] = "DemoToken";
address public immutable [2];
constructor(address _admin) {
[3] = _admin;
}
}The constant string is named TOKEN_NAME. The immutable address variable is admin, which is assigned in the constructor.