
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
Take declares a parameter named count that the caller supplies when running the plug; it sets the bound the loops will run against.
2·Set
Total is initialized to 0, giving a running accumulator that later steps add into.
3·Set
Index is set to 0, creating a counter that the first loop will step through.
4·Predicate
A loop opens that keeps running while index is less than count, iterating over the entries the caller asked for.
5·Read map value
Inside the loop, the map value at index in the weights map is read from socket storage.
6·Calculate
That read weight is added to the current total using addition.
7·Set
Total is reassigned to the sum from the previous step, folding this weight into the running total.
8·Calculate
Index is incremented by adding 1 to it.
9·Set
The counter is updated to the incremented value, advancing to the next entry.
10·End block
This closes the first loop, which has now summed every weight into total.
11·Set
Before the second pass, index is reset to 0 to walk the same entries again.
12·Predicate
A second loop opens with the same condition, running while index is less than count.
13·Read map value
Again the weight at index is read from the weights map in socket storage.
14·Multiply then divide
The read weight is multiplied by 100 and divided by total, rounding down, producing that weight's percent share.
15·Set map value
The computed percent is written back into the weights map at index in socket storage, overwriting the raw weight.
16·Calculate
Index is incremented by 1.
17·Set
The counter takes the incremented value, moving to the next entry.
18·End block
This closes the second loop, after which every stored weight has been replaced by its percent of the total.
On other protocols · 1