Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

iterate loop over mapping in solidity

// 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]];
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: define value in js 
Javascript :: Convert array to string while preserving brackets 
Javascript :: Uncaught TypeError: Data.filter is not a function 
Javascript :: js object sort 
Javascript :: javascript print to pdf 
Javascript :: javascript array from string 
Javascript :: this in javascript 
Javascript :: how to add new line in jsx 
Javascript :: cypress test only one file 
Javascript :: mongoose remove data 
Javascript :: parsley validation checkbox 
Javascript :: Split string into words, without punctuation 
Javascript :: select id get option value jquery 
Javascript :: compare between two arrays javascript 
Javascript :: arrow functions in js 
Javascript :: change page javascript 
Javascript :: clear session on browser close javascript 
Javascript :: download datepicker js 
Javascript :: how to use the match function in javascript for regex 
Javascript :: for in javascript 
Javascript :: mongoose update subdocument by id 
Javascript :: yup validation based on another field value 
Javascript :: array destructuring 
Javascript :: string theory 
Javascript :: print string multiple times in javascript 
Javascript :: how to concatenate a string in javascript 
Javascript :: set embed color discord.js 
Javascript :: javascript error try catch 
Javascript :: mysql_real_escape_string for nodejs 
Javascript :: js array .filter 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =