Hot answers tagged

2

The first push consumes 41129 gas That'll be 21,000 gas for the transaction base fee, and 20,000 gas for using the storage associated with the array for the first time. (Plus 129 gas - unsure about this, but probably unimportant.) while the second one only consumes 26129 That'll be 21,000 gas for the transaction base fee, and 5,000 gas for updating the ...


1

You can try this code : pragma solidity ^0.8.0; contract Agent { struct Agent { uint idAgent; address direction; uint[] preferences; } Agent[] agents; uint256 public numAgents; mapping(address=>bool) _isRegistered; /// @notice Registra a un nuevo agente a la subasta /// @param _preferences preferencias del agente function regAgent(uint[] ...


1

In your example. You may create another map to record the init price, the key is unint256 key = tokenID/50, the value is the init price. Then the size of the map changes from 5000 to 100. mapping (uint256 => uint256) public initPrice; initPrice[tokenID / 50] = "the token's init Price xxxxxxx" But it seems a bad idea and hard to updata.


Only top voted, non community-wiki answers of a minimum length are eligible