The Solidity Contract-Oriented Programming Language - By chatting here you agree to the https://github.com/ethereum/solidity/blob/develop/CODE_OF_CONDUCT.md
Hello everybody, I am very new in Solidity and also in JavaScript. I finished the CryptoZombies tutorial (maybe you know that) and now I am just playing around a bit to display some things via Javascript.
I have the following problem: I have an array where some parameters as "name" "age" etc are stored and a mapping where it is stored which array entry belongs to which user. So there are more than one entry per address possible.
My problem now is, if I want to display it and I use a "while"-pattern, the while pattern is finished before the results from the smart contract querys are there. And also the results from the smart contract array are not always available in the order requested. so an example:
according to the mapping array entry 0, 3 and 4 belong to some specific address.
so i implemented a while pattern and requested entrys 0, 3 and 4 of the array in the contract but results got in order 3, 0, 4. From MySQL and PHP what I learned several years ago the results are always presented in the order you wanted them. Any suggestions?
"Unreachable code."
warning with solc 0.8.9 even though the code is definitely reachable. I saw : ethereum/solidity#11522yarn && yarn compile
generate quite a few Unreachable code warnigns
Hey! Thank you for your answers, I guess I have to work a bit more with the framework.
But I have another solidity question. I don't know why the following is not working:
struct LotteryEntries {
string hash;
string userId;
}
LotterieEntries[][] public Entries;
function enterTicket() public {
Entries[0].push(LotterieEntries("Hallo","1"));
}
It always reverts. Why??
@ccolorado: They should both be the same, at least after optimization.
The easiest way to compare is writing two different contracts, both with a single function that does what you want to do. They call each of them and compare the costs. Make sure that the optimizer is turned on, otherwise, the comparison can be meaningless. Often users incorrectly writes two functions in the same contract and compares the gas, but this is incorrect because the order in which the function appear in the function dispatch can influence this.
Maybe https://www.npmjs.com/package/hardhat-gas-reporter can be useful in testing. Otherwise, something as simple as Remix should do.
constructor
function.
/// @notice Takes in the open interest and appllies Overlay's monetary policy
/// @dev The impact is a measure of the demand placed on the market over
/// @dev a rolling window.