Math

The math node performs arithmetic on two values. It shares the same shape as the compare node: two inputs, an operator dropdown, and a single output. The difference is that Math produces a number instead of a true/false result.

Operators

OperatorWhat It DoesExample
AddAdds two values50 + 25 = 75
SubtractSubtracts the second from the first50 - 25 = 25
MultiplyMultiplies two values50 * 25 = 1250
DivideDivides the first by the second50 / 25 = 2
ModuloReturns the remainder after division50 % 25 = 0
PowerRaises the first value to the power of the second2 ** 10 = 1024

Data Only

Like compare, the math node has no triangle connectors. It only computes a value. Wire its output circle into any field that accepts a number: a function parameter, a transfer amount, a variable assignment, or even another math node.

Try It Yourself

Task 1 of 2 Calculate a Result

Use the Math node to add two numbers together.

1 Type Value A
2 Type Value B
3 Done!
Type 50 in the Value A field.
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

Unchecked Mode

The math node has an Unchecked toggle. When enabled, Solidity skips its built-in overflow and underflow protection. This saves a small amount of gas but means results can silently wrap around if they exceed the type’s range. Leave this off unless you’re sure the values can’t overflow.

The AND, OR, and NOT nodes follow the same data-only pattern as math and compare: two inputs (or one for NOT), no triangle connectors, and a single output circle. See the Control Flow page for details.

What You Learned

  • Math nodes compute a result from two values and an operator
  • They are data-only nodes with no execution triangles
  • Wire the output circle into any field that needs a number
  • The Unchecked toggle skips overflow protection (advanced, use with care)
  • Logic gates (AND, OR, NOT) follow the same data-only pattern