Skip to main content

TokenRegistry

Inherits: Ownable2Step, ITokenRegistry

Title: TokenRegistry

Per-token policy registry for allowlisted execution constraints.

Stores token policies including:

  • enabled: whether the token is allowed for payments
  • decimals: token decimal places (for display/formatting)
  • minPerTx: minimum amount per transaction (0 = no minimum)
  • maxPerTx: maximum amount per transaction (0 = no maximum)
  • kind: token classification (0 = standard, 1+ = future types)

State Variables​

_policies​

mapping(address => TokenPolicy) private _policies

Functions​

constructor​

constructor() Ownable(msg.sender);

isEnabled​

function isEnabled(address token) external view override returns (bool);

maxPerTx​

function maxPerTx(address token) external view override returns (uint256);

minPerTx​

function minPerTx(address token) external view override returns (uint256);

decimals​

function decimals(address token) external view override returns (uint8);

setTokenPolicy​

Sets the full policy for a token.

function setTokenPolicy(
address token,
bool enabled,
uint8 tokenDecimals,
uint256 minAmount,
uint256 maxAmount
)
external
onlyOwner;

Parameters

NameTypeDescription
tokenaddressThe token address
enabledboolWhether the token is enabled for payments
tokenDecimalsuint8The token's decimal places (e.g., 18 for most tokens, 6 for USDC)
minAmountuint256Minimum amount per transaction (0 = no minimum)
maxAmountuint256Maximum amount per transaction (0 = no maximum)

setTokenKind​

function setTokenKind(address token, uint8 kind) external onlyOwner;

getTokenPolicy​

Returns the full policy for a token.

function getTokenPolicy(address token)
external
view
returns (
bool enabled,
uint8 tokenDecimals,
uint256 minAmount,
uint256 maxAmount,
uint8 kind
);

Parameters

NameTypeDescription
tokenaddressThe token address

Returns

NameTypeDescription
enabledboolWhether the token is enabled
tokenDecimalsuint8The token's decimal places
minAmountuint256Minimum amount per transaction
maxAmountuint256Maximum amount per transaction
kinduint8Token classification

Events​

TokenPolicyUpdated​

event TokenPolicyUpdated(
address indexed token, bool enabled, uint8 decimals, uint256 minPerTx, uint256 maxPerTx
);

Errors​

InvalidToken​

error InvalidToken();

InvalidPolicyBounds​

error InvalidPolicyBounds();

Structs​

TokenPolicy​

UNSUPPORTED TOKEN TYPES The following token behaviours are NOT supported by the amser protocol and must not be registered or used in subscription plans:

  • Fee-on-transfer tokens: Permit2 transferFrom uses nominal amounts. Recipients would receive less than the plan price, causing accounting drift and merchant underpayment.
  • Rebasing tokens: Balances change between registration and execution, breaking amount assumptions throughout the billing flow. Supported: Standard ERC20 tokens. Recommended: USDC, USDT, DAI, WETH. If adding a new token, verify it does not implement transfer hooks, balance rebasing, or fee deduction mechanisms.
struct TokenPolicy {
bool enabled;
uint8 decimals;
uint8 kind;
uint256 maxPerTx;
uint256 minPerTx;
}