https://github.com/OpShin/plutus-bench
A unified framework for Cardano Smart Contract testing and benchmarking m
https://github.com/OpShin/plutus-bench
benchmark cardano plutus smart-contracts
Last synced: 4 months ago
JSON representation
A unified framework for Cardano Smart Contract testing and benchmarking m
- Host: GitHub
- URL: https://github.com/OpShin/plutus-bench
- Owner: OpShin
- Created: 2023-03-03T22:43:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-03T16:41:06.000Z (4 months ago)
- Last Synced: 2025-03-20T18:41:35.962Z (4 months ago)
- Topics: benchmark, cardano, plutus, smart-contracts
- Language: Python
- Homepage: https://mockfrost.dev/redoc
- Size: 2.91 MB
- Stars: 21
- Watchers: 4
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![]()
MockFrost / Plutus-Bench
Test and benchmark Plutus Smart Contracts.
This project enables you to construct entire smart contract transactions against a mock environment, and measure the correctness (i.e. unit test) and performance of your smart contracts.Plutus Bench creates a mock ledger with an arbitrary UTxO set specified by the user.
It then hosts a mock blockfrost API to interact with the ledger, supporting popular off-chain tooling
like [translucent](https://github.com/antibody-cardano/translucent) and [pycardano](https://pycardano.readthedocs.io/en/latest/).> Note: Plutus Bench is currently in Beta. Expect rough edges!
### Why Plutus Bench?
- **Compatability**: Plutus Bench is written in Python, and is compatible with popular off-chain tooling relying on BlockFrost APIs. Ogmios mocking is also planned.
- **Holistic Testing**: Plutus Bench allows you to test the entire lifecycle of a smart contract, from minting to consuming, in a single test.
- **Simple**: Plutus Bench is designed to be simple to use, and easy to integrate with your existing infrastructure.### Installation and running
```bash
# install the plutus-bench package
git clone https://github.com/OpShin/plutus-bench.git
cd plutus-bench
# install the package
pip install .
# run the mock server
uvicorn plutus_bench.mockfrost.server:app
```After running these commands, a mock blockfrost server will be running on `http://localhost:8000`.
Head to `http://localhost:8000/docs` to see the API documentation.### Usage
Generally the workflow is as follows:
- Create a new session with the `/session/create` endpoint. You receive a session ID.
- Initialize a BlockFrost client in your off-chain code, and point it to the mock server. The base url is `http://localhost:8000//api/v1`. Project id is not required.That's it! You can now interact with the mock ledger using the BlockFrost client.
You may further manipulate the ledger using the `//ledger` endpoints.
## Tutorials and Walkthroughs
- Concrete example and introduction (Reddit): https://www.reddit.com/r/CardanoDevelopers/comments/1j2irs1/introducing_mockfrost_plutusbench_for_endtoend/
- Walkthrough: How to adapt your off-chain scripts to MockFrost (YouTube): https://youtu.be/B2wZd1xDSMU### Similar Projects
- [lucid transaction emulator](https://lucid.spacebudz.io/) - Allows emulation of transactions on the Cardano blockchain. Only supports JavaScript and TypeScript.
- [helios transaction emulator](https://github.com/hyperion-bt/helios) - Allows emulation of transactions on the Cardano blockchain. Only supports JavaScript and TypeScript.
- [plutus simple model](https://github.com/mlabs-haskell/plutus-simple-model) - Allows evaluating Plutus smart contracts. Only supports Haskell.### What about the language comparison?
The language comparison has been moved to [contest](./contest).
It is planned to expand to cover different implementations of the same contract in different languages and the same language, tailored for performance optimizations.