[Ethereum] Why do we need to specify constant in the return value solidity Referring to the constant below: function totalSupply() constant returns (uint256 totalSupply); Best Answer From Solidity docs: Functions can be declared constant in which case they promise not to modify the state. If a function doesn't modify the state of blockchain (simply getters), you should add constant to function definition. Related Solutions[Ethereum] API to “Read Contract Information” to fetch stats of an ICO Which version of web3 are you using? Here is a working example with web3@^1.0.0-beta.34 const Web3 = require('web3'); contractAddress = '0xe7775a6e9bcf904eb39da2b68c5efb4f9360e08c'; provider = 'https://mainnet.infura.io'; const contractAbiJSON = '';//... The JSON abi // Init const web3 = new Web3(new web3.providers.HttpProvider(provider)); const contract = new web3.eth.Contract(contractAbiJSON, contractAddress); contract.methods.totalSupply().call().then((totalSupply) => { console.log(totalSupply); }); [Ethereum] Overwriting of constant variables by inheritance: Why are parent variables only overwritten in functions of the child Well you say it yourself, you're not calling aString, but super.printMe(). Have a deeper explanation of superhere: The super keyword in Solidity gives access to the immediate parent contract from which the current contract is derived. You are explicitly calling the parent contract Hello, in which aString is 'Hello, world.' Look at the difference if in printMe2() you put: return super.aString; Related Topic[Ethereum] This contract does not implement all functions and thus cannot be created
Best Answer
From Solidity docs:
If a function doesn't modify the state of blockchain (simply getters), you should add
constant
to function definition.