Metamorphic Testing Relation Generator
Free to download on every platform. Comes pre-installed on BotFone, BotPad and BotFlip — with extra free apps included.
About this app
WHAT IT DOES
Metamorphic Testing Relation Generator analyzes smart contract ABIs, source code, and control flow graphs to produce metamorphic relations—algebraic properties that should hold across multiple executions of contract functions. It retrieves on-chain contract bytecode via eth_getCode and fetches verified source code and ABI from block explorer APIs to extract function signatures, state variable dependencies, and control flow structures. The tool identifies candidate metamorphic relations such as commutativity (f(a,b) == f(b,a)), associativity (f(f(a,b),c) == f(a,f(b,c))), distributivity (f(a,g(b,c)) == g(f(a,b),f(a,c))), identity (f(a,e) == a), and idempotence (f(f(a)) == f(a)). It maps these abstract relation templates to concrete contract functions by analyzing parameter types, state variable modifications, and return value structures. The output is a set of testable metamorphic relations that can be used to validate contract behavior without requiring a ground-truth oracle, enabling property-based testing even when expected outputs are unknown.
HOW TO USE
Connect your BGWallet to the target EVM chain. Paste the contract address you wish to analyze. Select the type of metamorphic relations you want to generate—commutative, associative, distributive, identity, or all types. Optionally supply a GitHub repository URL to pull existing test suites, property definitions, or metamorphic relation examples for context. The tool fetches the contract's bytecode, ABI, and source code, builds a control flow graph, and generates applicable metamorphic relations. Review the generated relations, adapt them to your specific testing framework, and integrate them into your test harness. Each relation is presented with a transformation rule and an equivalence property, along with explanatory comments to help you understand the semantic intent.
CONTROL FLOW AND STATE DEPENDENCY GRAPH ANALYSIS
The real technical mechanism is the control flow and state dependency graph analysis that drives relation discovery. The tool constructs a comprehensive dependency graph from the contract's bytecode and ABI, mapping each function's read and write access to state variables and their interdependencies. It then applies a set of algebraic pattern detectors to the graph: for commutative relations, it looks for functions that read two state variables or parameters symmetrically; for associative relations, it identifies functions that can be nested without changing the final state; for identity relations, it searches for functions that apply an operation and a corresponding inverse operation. The engine also uses a library of common smart contract patterns—ERC-20 transfers, token approvals, ownership transfers—to provide template-based relations when the ABI alone is insufficient. The generated relations are scored based on their semantic plausibility, with higher scores given to relations that involve complex state interactions or multiple functions. This approach automates what is traditionally a manual and error-prone process, reducing the effort required to implement metamorphic testing from days to minutes and improving test coverage by systematically enumerating algebraic properties that developers might otherwise overlook.
WHAT IT CANNOT SEE
This tool cannot generate metamorphic relations without access to contract bytecode or ABI. It is limited by your RPC provider's rate limits for bytecode retrieval, which may delay analysis on congested networks. It cannot generate meaningful relations for contracts with complex external dependencies or where equivalent transformations are not derivable from the ABI or source code—these contracts may require manual relation design. The generation relies on the completeness of the ABI and source code verification; missing or incomplete verification data will produce incomplete or incorrect relations. Generated relations are based on static analysis and may not capture all semantic equivalences or state-dependent invariants that only manifest during execution. The tool cannot prove the correctness or equivalence of generated metamorphic relations; all relations should be validated against contract behavior through testing. It may generate trivial or redundant relations for contracts with simple interfaces, requiring manual pruning. The tool does not execute the contract to validate the metamorphic relations; generated relations are not automatically verified against live contract behavior.
PLEASE NOTE
This tool works exclusively with EVM-compatible chains. It requires active internet connectivity to access block explorer APIs and RPC endpoints. Some block explorers may require API keys for high-volume bytecode retrieval. The generator is read-only and does not modify or deploy any code—it only produces metamorphic relation definitions. Always review and validate generated relations against your specific contract's logic and intended behavior before committing them to production test suites.