# evm_addmod

Implements EVM ADDMOD: computes (a + b) mod n using the full mathematical sum, without UINT256 wraparound, and returns zero when n is zero. NULL input propagates to NULL.

Canonical HTML: <https://determica.com/docs/functions/evm_addmod>

- Kind: scalar function
- Category: [EVM utilities](/docs/category/evm-utilities.md)
- Tags: Types, EVM

Implements EVM ADDMOD: computes (a + b) mod n using the full mathematical sum, without UINT256 wraparound, and returns zero when n is zero. NULL input propagates to NULL.

## Overload 1: evm_addmod(UINT256, UINT256, UINT256)

```sql
evm_addmod(UINT256, UINT256, UINT256)
```

EVM ADDMOD over three UINT256 words using a 512-bit sum.

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `a` (UINT256; required; positional) — UINT256 addend.
- `b` (UINT256; required; positional) — UINT256 addend.
- `n` (UINT256; required; positional) — UINT256 modulus; zero returns zero.

### Returns

Modular sum

UINT256 residue in [0,n), zero for n=0, or NULL for NULL input.

- `result` (UINT256)

Modular sum. UINT256 residue in [0,n), zero for n=0, or NULL for NULL input.

### Examples

_Local SQL · Local_

```sql
SELECT evm_addmod(7::UINT256, 5::UINT256, 10::UINT256)::VARCHAR AS result;
-- => [{"result":"2"}]
```
