{"id":24261942,"url":"https://github.com/thomashoneyman/pact-template","last_synced_at":"2026-03-10T04:02:12.524Z","repository":{"id":272072068,"uuid":"915439897","full_name":"thomashoneyman/pact-template","owner":"thomashoneyman","description":"A reusable example repository for Pact projects","archived":false,"fork":false,"pushed_at":"2025-01-12T01:19:41.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T22:37:00.063Z","etag":null,"topics":["kadena","pact"],"latest_commit_sha":null,"homepage":"","language":"Pact","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomashoneyman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-11T21:08:38.000Z","updated_at":"2025-01-12T01:19:45.000Z","dependencies_parsed_at":"2025-01-11T22:22:56.927Z","dependency_job_id":"bbc95c18-6a86-4b2c-b0bd-269392d14dda","html_url":"https://github.com/thomashoneyman/pact-template","commit_stats":null,"previous_names":["thomashoneyman/pact-template"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thomashoneyman/pact-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomashoneyman%2Fpact-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomashoneyman%2Fpact-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomashoneyman%2Fpact-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomashoneyman%2Fpact-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomashoneyman","download_url":"https://codeload.github.com/thomashoneyman/pact-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomashoneyman%2Fpact-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30324185,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T01:36:58.598Z","status":"online","status_checked_at":"2026-03-10T02:00:06.579Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kadena","pact"],"created_at":"2025-01-15T06:54:34.499Z","updated_at":"2026-03-10T04:02:12.481Z","avatar_url":"https://github.com/thomashoneyman.png","language":"Pact","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pact Template\n\n[![Contract Tests](https://github.com/thomashoneyman/pact-template/actions/workflows/pact.yaml/badge.svg)](https://github.com/thomashoneyman/pact-template/actions/workflows/pact.yaml)\n\nA project template for writing smart contracts in the Pact language for use in the Kadena ecosystem. This template is a suitable starting point for new projects, providing:\n\n* A smart contract and associated REPL files demonstrating best practices for testing\n* Bootstrap REPL files which mimic the Chainweb environment for more realistic tests\n* Continuous integration via GitHub workflows\n\n## Installation \u0026 Use\n\nThis repository is a template, so you should feel free to copy and modify it for your needs.\n\nThe root includes a `.pact-version` file suitable for use with [pactup](https://github.com/kadena-community/pactup). The same Pact version is used in continuous integration. There are no dependencies for this project except `pact` and a shell.\n\nThere is an included test runner that will execute module tests. This is particularly useful with `watchexec` to execute tests while you work on particular modules. There are more details about how this script works in the **Test Structure** section.\n\n```sh\n# the 'test runner'\n./contracts/tests/run.sh\n```\n\n## Project Structure\n\nThis template recommends a specific structure for your Pact code:\n\n```tree\ncontracts/\n├── interfaces/          # Interface definitions\n     └── your-iface.pact\n├── modules/             # Contract implementations\n     ├── constants.pact  # Constant definitions for your modules\n     ├── ns.pact         # Definition of your principal namespace\n     └── your-module.pact\n└── tests/\n    ├── bootstrap/       # Chainweb environment simulation\n         ├── coin.pact\n         └── ...\n    ├── bootstrap.repl   # Initialize test environment\n    └── modules/         # Tests grouped by module\n        └── your-module/ # Tests for specific module\n            ├── setup.repl    # Module initialization \u0026 dependencies\n            ├── gas.repl      # Gas consumption measurements\n            ├── auth.repl     # Access control tests\n            ├── unit/         # Individual function tests\n                 ├── transfer.repl\n                 └── stake.repl\n            └── main.repl     # Top-level integration/usage tests\n```\n\n## Test Structure\n\nEach module in `modules` must have a corresponding test directory in `tests/modules`, unless explicitly excluded via the exceptions file.\n\n### Test Types\n\nThe test runner recognizes four types of tests:\n\n1. **Main Tests (Required)**\n   - Either `main.repl` or a `main/` directory with .repl files\n   - Contains integration tests demonstrating complete module workflows\n   - Must be present and non-empty\n\n2. **Auth Tests (Optional for modules without auth)**\n   - Either `auth.repl` or an `auth/` directory\n   - Tests access control, capabilities, signatures, etc.\n   - Recommended for any module that uses capabilities or keysets\n\n3. **Unit Tests (Optional for trivial modules)**\n   - Either `unit.repl` or a `unit/` directory\n   - Tests individual function behavior\n   - Recommended for all non-trivial modules\n\n4. **Gas Tests (Optional)**\n   - Either `gas.repl` or a `gas/` directory\n   - Measures gas consumption of operations\n\nFor each test type, you may use either a single .repl file or a directory of .repl files. Main tests are required; all others are optional but recommended where appropriate.\n\n### Running Tests\n\nThe test runner provides several options for running tests:\n\n```bash\n# Run all tests for all modules\n./run.sh\n\n# Run tests for specific modules\n./run.sh --module simple-staking,other-module\n\n# Run specific test types\n./run.sh --type unit,auth\n\n# Skip specific test types\n./run.sh --exclude-type gas\n```\n\n### Verbosity Options\n\nThe test runner supports different verbosity levels:\n\n```bash\n# Normal mode (default) - shows which tests are running\n./run.sh\n\n# Quiet mode - only shows output on failure\n./run.sh --quiet\n\n# Verbose mode - shows all Pact output\n./run.sh --verbose\n\n# Debug mode - shows all output and enables Pact trace mode\n./run.sh --debug\n```\n\n### Excluding Modules from Testing\n\nTo exclude modules from testing requirements (e.g., utility modules), list their filenames in `contracts/tests/test-exceptions.txt`:\n\n```txt\n# List modules that don't require tests (one per line)\nns.pact\nconstants.pact\n```\n\n### Test Execution Order\n\nThe test runner executes tests in this order:\n\n1. Auth tests (if present)\n2. Unit tests (if present)\n3. Main tests (required)\n4. Gas tests (if present, run last)\n\nThe runner collects all failures and reports them at the end rather than stopping at the first failure.\n\n## Testing Environment\n\nThe `bootstrap.repl` file creates a local testing environment that mimics the Chainweb blockchain. This includes:\n\n- Basic Kadena contracts (coin, ns, etc.)\n- Standard namespaces (free, util, kip, etc.)\n- Test accounts with funded KDA\n- A principal namespace for your project's contracts\n\n### Using in Tests\n\nTo use this environment in your tests:\n\n```repl\n;; First load the bootstrap environment\n(load \"../bootstrap.repl\")\n\n;; Now you can use the pre-configured accounts and namespaces\n(begin-tx)\n(use base)  ;; Access environment constants\n\n;; Test your contract\n(expect \"Transfer should succeed\"\n  \"Write succeeded\"\n  (your-contract.transfer ALICE BOB 100.0))\n\n(expect \"Bob's balance increased\"\n  100.0\n  (your-contract.get-balance BOB))\n```\n\nThe base module provides constants for accounts, keys, and guards - see `bootstrap.repl` for all available values.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomashoneyman%2Fpact-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomashoneyman%2Fpact-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomashoneyman%2Fpact-template/lists"}