Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

reinitialise or reset all values in mapping in solidity

// example mapping:
mapping(address => uint256) investments;

// you have to have an list storing the addresses in order to iterate over the mapping
address [] investers;

// function to reset all values in the mapping to {value}
function resetBalance(uint256 value)public {
	// iterate over the array to iterate over the mapping and reset all to value
    for (uint i=0; i< investers.length ; i++) {
        investments[investers[i]] = value;
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: disable button without losing value 
Javascript :: how to get query data using javascript 
Javascript :: popover not working when next page datatable 
Javascript :: creat checkbox and append it to a list js 
Javascript :: angularjs component stackoverflow 
Javascript :: Change the content of ALL the p tags 
Javascript :: replacing value of arrayObj using map and spread operator 
Javascript :: parse thymeleaf variable onclick 
Javascript :: show hide pseudo element jquery 
Javascript :: Get cheapest price phone from an object in javascript 
Javascript :: for const 
Javascript :: javascript to reload django partial 
Javascript :: jQuery.datepicker is undefined 
Javascript :: js comment out 
Javascript :: jquery scroll to top of element 
Javascript :: linearSearch 
Javascript :: javascript check if valid url 
Javascript :: mongoose operand find method 
Javascript :: Access the list of valid values for an Enum field in a MongoDb Mongoose Schema 
Javascript :: Cache and return requests 
Javascript :: The app structure generator Express 
Javascript :: spread operator shorthand javascript 
Javascript :: how to get min value from array of objects in javascript 
Javascript :: compile regex script help online 
Javascript :: cant find variable idbindex react native 
Javascript :: implict type coercion in js 
Javascript :: loadash 
Javascript :: math library javascript 
Javascript :: Yup validation for objects and object shape 
Javascript :: typeorm class validator 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =