📜  在solidity中迭代循环映射 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:04:06.739000             🧑  作者: Mango

代码示例1
// Answer 1
// initialise a counter and an mapping in addition to the mapping you intend to iterate over
uint counter; // you should initialize this to 0 in the constructor

// the value in the countToAddress mapping points to the key in the next mapping
mapping (uint => address) private countToAddress;

// intend to iterate over the addressToValue mapping:
mapping (address => uint) private addressToValue;

function iterateOverAddressToValue() public {

  uint currentValue;
  for (uint i=0; i < counter; i++) {
    currentValue = addressToValue[countToAddress[i]];
  }
}