feat: ARC-20/ARC-22 token interface detection on Program#61
Merged
Conversation
Program.is_arc20() / Program.is_arc22() classify a parsed .aleo program against the IARC20 / IARC22 token interfaces by exact signature matching: required records (Token, ComplianceRecord) with open entries, required functions (own-program future outputs, structural MerkleProof matching for local or imported structs), and the seven shared view functions via snarkVM's first-class view declarations. Ported from the wasm SDK to keep semantics identical across SDKs. Also fixes get_function_inputs reporting the program name instead of the struct name as struct_id for imported (external) structs — Locator::name() returns the program name; resource() is the struct name. Test vectors: the deployed testnet test_arc20_eth.aleo (ARC-20 pass), the Leo-compiled compliant_token_template.aleo (ARC-22 pass, external MerkleProof), the deployed test_usdcx_stablecoin.aleo (near-miss: IARC22 signatures but no views), plus synthetic minimal programs for mutation tests.
pip install --find-links dist aleo-sdk also consults PyPI. While the branch version outversioned PyPI this always resolved locally, but now that 0.2.2 is published the same version exists in both sources and pip breaks the tie by wheel-tag preference: on linux the local manylinux_2_38 tag outranks PyPI's manylinux_2_28, but on macOS and Windows the tags are identical and pip picks the PyPI wheel — so the test jobs silently exercised the released binary instead of the one just built from the branch (the ARC-20/22 failures on this PR). Install every locally built wheel by explicit path so the artifact under test is always the one that was just built.
Roee-87
self-requested a review
July 23, 2026 21:44
Roee-87
approved these changes
Jul 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
Program.is_arc20()andProgram.is_arc22(), classifying a parsed.aleoprogram against the ARC-20 (IARC20) and ARC-22 (IARC22) token interfaces. Ported from the wasm SDK's implementation so both SDKs classify programs identically.Detection is exact signature matching, not name presence — the two standards share every function name and differ only in signatures:
..):Token(ownerprivate +amount: u128), plusComplianceRecordfor ARC-22.Finaloutputs must be the program's own future.[MerkleProof; 2u32]inputs matched structurally — the struct may be local (shape checked) or imported from a freeze-list program (name-only).balance_of,allowance,supply,max_supply,decimals,name,symbol) via snarkVM's first-classviewdeclarations.is_arc22covers the token interface only, not IARC22Freezelist (separate registry program).Bug fix
While porting, found that
get_function_inputsreported the program name instead of the struct name asstruct_idfor imported (external) structs — snarkVM'sLocator::name()returns the program name;resource()is the struct name. Fixed with a regression test.Test vectors
test_arc20_eth.aleo(deployed testnet)compliant_token_template.aleo(Leo-compiled, imports MerkleProof from freezelist.aleo)test_usdcx_stablecoin.aleo(deployed testnet near-miss: IARC22 signatures, no views)arc20_token.aleo/arc22_token.aleo(synthetic, for mutation tests)Plus mutation tests: wrong amount type, missing function/view, wrong view signature, foreign futures, public record owner, wrong record name, wrong MerkleProof shape, missing ComplianceRecord.
Testing
cargo check+cargo fmt --checkclean