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
| Name | Type | Description |
|---|---|---|
token | address | The token address |
enabled | bool | Whether the token is enabled for payments |
tokenDecimals | uint8 | The token's decimal places (e.g., 18 for most tokens, 6 for USDC) |
minAmount | uint256 | Minimum amount per transaction (0 = no minimum) |
maxAmount | uint256 | Maximum 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
| Name | Type | Description |
|---|---|---|
token | address | The token address |
Returns
| Name | Type | Description |
|---|---|---|
enabled | bool | Whether the token is enabled |
tokenDecimals | uint8 | The token's decimal places |
minAmount | uint256 | Minimum amount per transaction |
maxAmount | uint256 | Maximum amount per transaction |
kind | uint8 | Token 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;
}