Smart Contract Mocking
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
Smart Contract Mocking is a developer tool that generates mock contract implementations from ABIs. Enter a contract name, paste the contract's ABI (JSON array), optionally define initial state variables, and select a behavior mode (Default, Simple, or Dynamic). The tool generates a mock class with function stubs that simulate the contract's behavior — Simple mode returns predictable values (42 for integers, true for booleans), Dynamic mode increments counters on each call, and Default mode provides empty stubs. This is essential for developers testing smart contract interactions, building frontends without a deployed contract, simulating contract behavior, or creating test fixtures for unit testing.
HOW TO USE
Connect your wallet using the BGWallet bridge (MetaMask or any Web3 wallet). Enter the contract name — this will be used as the mock class name. Paste the contract's ABI as a JSON array in the text area — the ABI defines the functions that will be mocked. Optionally, define initial state variables as a JSON object (e.g., {"balances": {"0x...": 1000}}). Select the mock behavior: Default (empty stubs), Simple (returns predictable values like 42, true, or zero addresses), or Dynamic (returns incrementing counters on each call). Click "Generate mock" to produce the mock implementation. Results display the contract name, generation status, detected functions, a preview of the mock code, the full mock code, the state variables, and the selected behavior. You can copy the mock code for use in your tests or development environment.
TECHNICAL MECHANISM
The tool parses the provided ABI to extract function definitions, including function names, input parameters, and output types. It then generates a JavaScript/TypeScript class with the contract name. For each function, it generates a method stub with the appropriate parameters. The behavior is determined by the selected mode: Simple mode returns deterministic values based on the output type (uint/int → 42, bool → true, address → zero address, others → null). Dynamic mode maintains per-function counters (e.g., _transferCounter) that increment on each call and return the current counter value. Default mode provides empty method bodies. The tool also includes state variable initialization from the user-provided state object. The generated mock code is formatted as a class with methods and optional state management. All code is generated client-side — no data is stored or transmitted. The mock code is intended to be copied and used in your development environment.
WHAT IT CANNOT SEE
The tool cannot actually deploy mock contracts on-chain without a real wallet and network — the mocks are for off-chain testing only. It cannot provide full Ganache or Hardhat network simulation — the mocks are simple class stubs, not a full blockchain environment. It cannot replicate complex contract behavior without detailed implementation — the mocks do not execute real contract logic. It cannot validate mock behavior against real contract logic — the mocks are simplified and may not reflect actual contract behavior. It cannot generate mocks for contracts with complex inheritance, libraries, or internal function calls — only top-level functions are mocked. It cannot handle events, modifiers, or fallback functions — only standard functions are supported. The tool is read-only and does not sign any transactions.
PLEASE NOTE
This tool works exclusively with EVM-compatible chains for the wallet connection, but the mock generation is chain-agnostic and works with any ABI. Solana, Tron, Starknet, SUI, TON, Aptos, Bitcoin, Cosmos, and XRP are not supported for wallet connection but the mock generation works regardless. The generated mocks are for testing and development purposes only — they should not be used in production. The tool does not store any data — all operations are performed client-side. The tool is provided as-is with no warranty or liability. Always verify mock behavior against real contract deployments.