
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
Declaring count as a named parameter, this leaves the number of weight entries for the caller to supply at execution time.
2·Set
Seeding the accumulator, total is set to 0 before any weight is summed.
3·Set
Setting index to 0 establishes the loop counter that starts at the first entry.
4·Predicate
A for loop opens, running while index stays less than count, iterating once per entry.
5·Read map value
Inside the loop, the weights map in socket storage is read at the current index, returning that entry's stored weight.
6·Calculate
Arithmetic adds the weight just read to the running total.
7·Set
Reassigning total to that sum folds this entry'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 prepares the counter for the second pass.
12·Predicate
A second for loop opens, running again while index stays less than count.
13·Read map value
Reading the weights map in socket storage at the current index returns that entry's stored weight once more.
14·Multiply then divide
Taking that weight times 100 divided by total, rounded down, computes the entry's percent share of the summed total.
15·Set map value
Writing that percent back into the weights map at the current index overwrites the raw weight with its computed share.
16·Calculate
Bumping the counter, index is added to 1.
17·Set
The incremented result is written back into index for the next pass.
18·End block
Closing the second loop block completes the composed transaction.
On other protocols · 1