Docs
Linting rules

S009: prefer-grams

Replaces the standard library's `ton()` alias with `grams()`.

Available since: Acton 1.2

Metadata

  • Code: S009
  • Rule: prefer-grams
  • Status: Stable since v1.2.0
  • Quick fix: sometimes available

What it does

Replaces the standard library's ton() alias with grams().

Why is this bad?

ton() is the old name of grams(). The replacement preserves the amount.

Behavior notes

This rule reports standard-library calls when the standard library provides grams. It leaves user-defined functions and older standard libraries without grams unchanged. If a local binding shadows grams, the rule reports a warning without an automatic fix. E003 does not report the same call when this rule reports it.

Example

const amount = ton("0.1");
S009: prefer `grams()` over `ton()`

Use instead:

const amount = grams("0.1");
Source code

Last updated on

On this page