
Ethereum Virtual Machine · Acts onchain
Assigns a value to a named variable that later steps reference. The value is echoed into a slot bound to the name. Reassignment is by reference, never by name: coil the earlier variable's name input into this action's name slot to write the same slot, so a variable initialized before an if/else and reassigned in each branch carries the branch's value forward. Two Sets that merely type the same name literal are two independent slots; the name is a label, not an identity. Reach for it to give a computed amount or address a stable handle, or to merge results from divergent branches into one value the rest of the plug consumes.
Raw Weights to Percents



1·Take
A caller parameter named count is declared here, its value supplied at execution time to bound both loops below.
2·Set
Seeding the accumulator, total is set to 0 before any weight is summed.
3·Set
Setting index to 0 establishes the counter for the first pass over the weight slots.
4·Predicate
A loop opens that runs while index stays less than count, iterating once per weight slot.
5·Read map value
Inside the loop, the weights map in socket storage is read at the current index, returning the raw weight stored at that position.
6·Calculate
Arithmetic adds that read weight to the running total.
7·Set
Reassigning total to that sum folds this slot's weight into the accumulator.
8·Calculate
Advancing the counter, index is added to 1.
9·Set
The incremented result is written back into index for the next pass.
10·End block
Closing the loop block returns control to the condition until index reaches count.
11·Set
Resetting index to 0 restarts the counter for the second pass.
12·Predicate
A loop opens again while index stays less than count, iterating once per slot to rewrite each weight.
13·Read map value
Inside this pass, the weights map is read at the current index, returning that slot's raw weight.
14·Multiply then divide
Multiplying the raw weight by 100 then dividing by total, rounding down, converts it into a percentage of the summed total.
15·Set map value
Writing that percentage back into the weights map at index in socket storage overwrites the raw weight with its percent share.
16·Calculate
Bumping the counter, index is added to 1.
17·Set
That incremented result is written back into index for the next pass.
18·End block
Closing the loop block completes the second pass over the weight set.
On other protocols · 1