https://github.com/Olanetsoft/compact-playground
Compile Compact smart contracts in the browser. Built for Learn Compact.
https://github.com/Olanetsoft/compact-playground
compact midnightntwrk
Last synced: 3 months ago
JSON representation
Compile Compact smart contracts in the browser. Built for Learn Compact.
- Host: GitHub
- URL: https://github.com/Olanetsoft/compact-playground
- Owner: Olanetsoft
- Created: 2026-01-20T16:01:15.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-03-26T10:10:07.000Z (3 months ago)
- Last Synced: 2026-03-27T03:40:48.821Z (3 months ago)
- Topics: compact, midnightntwrk
- Language: TypeScript
- Homepage:
- Size: 29.3 KB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- midnight-awesome-dapps - Compact Playground - Browser-based Compact smart contract compiler, built as a companion to Learn Compact (Developer Tools)
README
# Compact Playground
Compile Compact smart contracts in the browser. Built for [Learn Compact](https://github.com/Olanetsoft/learn-compact).
This project integrates with the Midnight Network.
**Live API:** https://compact-playground.up.railway.app
## API
### POST /compile
```bash
curl -X POST https://compact-playground.up.railway.app/compile \
-H "Content-Type: application/json" \
-d '{"code": "export circuit add(a: Uint<64>, b: Uint<64>): Uint<64> { return (a + b) as Uint<64>; }"}'
```
**Response:**
```json
{
"success": true,
"output": "Compilation successful",
"executionTime": 3360
}
```
**Error Response:**
```json
{
"success": false,
"errors": [{"line": 5, "column": 12, "message": "unbound identifier Void"}]
}
```
### GET /health
```bash
curl https://compact-playground.up.railway.app/health
```
## mdBook Integration
1. Copy `frontend/compact-playground.js` and `frontend/compact-playground.css` to your mdBook
2. Add to `book.toml`:
```toml
[output.html]
additional-js = ["compact-playground.js"]
additional-css = ["compact-playground.css"]
```
3. Use `compact` language in code blocks:
````markdown
```compact
export circuit add(a: Uint<64>, b: Uint<64>): Uint<64> {
return (a + b) as Uint<64>;
}
```
````
Code blocks get a Run button. Press `Ctrl+Enter` to compile.
## Deploy
### Railway
1. Fork this repo
2. Create a new project on [railway.app](https://railway.app)
3. Connect repo, it will auto-detect the Dockerfile
4. Deploy
### Docker
```bash
docker build -t compact-playground .
docker run -p 8080:8080 compact-playground
```
## Development
```bash
npm install
npm run dev:node # Requires compactc installed locally
npm run test:run # Run tests
```
## License
MIT