Join our community of builders on

Telegram!Telegram

Contracts for Sui 1.x

OpenZeppelin Contracts for Sui v1.x ships three core packages:

  • openzeppelin_math for deterministic integer arithmetic, configurable rounding, and decimal scaling.
  • openzeppelin_fp_math for 9-decimal fixed-point arithmetic (UD30x9, SD29x9) backed by u128.
  • openzeppelin_access for ownership-transfer wrappers around privileged key + store objects.

Quickstart

Prerequisites

  • Sui CLI installed.
  • MVR CLI installed.
  • A new or existing Move package.

1. Create a Move Package

sui move new my_sui_app
cd my_sui_app

2. Add OpenZeppelin Dependencies from MVR

mvr add @openzeppelin-move/access
mvr add @openzeppelin-move/integer-math
mvr add @openzeppelin-move/fixed-point-math

You only need the dependencies your app actually uses — add what you need and drop the others.

3. Verify Move.toml

mvr add updates Move.toml automatically. With all three installed it should include:

[dependencies]
openzeppelin_access = { r.mvr = "@openzeppelin-move/access" }
openzeppelin_math = { r.mvr = "@openzeppelin-move/integer-math" }
openzeppelin_fp_math = { r.mvr = "@openzeppelin-move/fixed-point-math" }

4. Add a Minimal Module

Create sources/quickstart.move:

module my_sui_app::quickstart;

use openzeppelin_math::rounding;
use openzeppelin_math::u64::{mul_div, sqrt};

// === Functions ===

public fun quote_with_fee(amount: u64): u64 {
    // 2.5% fee, rounded to nearest.
    let quoted = mul_div(amount, 1025u64, 1000u64, rounding::nearest());
    quoted.destroy_some()
}

public fun sqrt_floor(value: u64): u64 {
    sqrt(value, rounding::down())
}

5. Build and Test

sui move build
sui move test

Picking a package

  • Need integer arithmetic with safe overflow and explicit rounding? Use Integer Math.
  • Need fractional values — prices, fees, rates, signed deltas? Use Fixed-Point Math.
  • Need controlled transfer of admin/treasury/upgrade capabilities? Use Access.

The packages compose. A typical protocol module imports openzeppelin_math for share math, openzeppelin_fp_math for rate and fee math, and openzeppelin_access for the admin capability that governs both.

Next Steps