{"id":15061501,"url":"https://github.com/solana-developers/seahorse","last_synced_at":"2025-10-04T21:31:22.933Z","repository":{"id":200591257,"uuid":"665653721","full_name":"solana-developers/seahorse","owner":"solana-developers","description":"Write Anchor-compatible Solana programs in Python","archived":false,"fork":true,"pushed_at":"2024-04-09T08:21:00.000Z","size":426,"stargazers_count":31,"open_issues_count":6,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-25T23:19:50.647Z","etag":null,"topics":["anchor","anchor-lang","python","rust","seahorse","seahorse-lang","solana"],"latest_commit_sha":null,"homepage":"https://www.seahorse.dev","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ameliatastic/seahorse-lang","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/solana-developers.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2023-07-12T17:27:26.000Z","updated_at":"2024-09-08T18:23:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"ffa08525-3caf-4286-8f73-c3f5e045eaf3","html_url":"https://github.com/solana-developers/seahorse","commit_stats":null,"previous_names":["solana-developers/seahorse"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solana-developers%2Fseahorse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solana-developers%2Fseahorse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solana-developers%2Fseahorse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solana-developers%2Fseahorse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solana-developers","download_url":"https://codeload.github.com/solana-developers/seahorse/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219876778,"owners_count":16554786,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["anchor","anchor-lang","python","rust","seahorse","seahorse-lang","solana"],"created_at":"2024-09-24T23:20:19.875Z","updated_at":"2025-10-04T21:31:17.592Z","avatar_url":"https://github.com/solana-developers.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# seahorse: Write Solana programs in Python\n\n\u003e [!IMPORTANT]\n\u003e This is a fork of [seahorse-lang](https://github.com/ameliatastic/seahorse-lang). The original repository is deprecated and is broken with latest anchor updates, and is no longer maintained by its creator. If you're using `seahorse-lang` in your project, we would highly recommend migrating to `seahorse-dev`.\n\n## The ease of Python with the safety of Rust.\n\nSeahorse lets you write Solana programs in Python. It is a community-led project built on [Anchor](https://github.com/coral-xyz/anchor).\n\nDevelopers gain Python's ease-of-use, while still having the same safety guarantees of every Rust program on the Solana chain. Low-level memory problems are handled by default, letting you worry about the important stuff.\n\n### Features\n\n- **Compile-time type safety**\n- **Fully interoperable with Rust code**\n- **Compatibility with Anchor**\n\nThe Seahorse compiler generates intermediate Rust artifacts and uses Anchor to do some of the heavy lifting.\n\n_Seahorse is beta software. Many features are unimplemented and it's not production-ready._\n\n[**Get started**](https://www.seahorse.dev/)\n\n[**Installation**](https://www.seahorse.dev/introduction/installation)\n\n[**Examples**](https://github.com/solana-developers/seahorse/tree/main/examples)\n\n## Example: FizzBuzz\n\nHere's a very simple program that does something similar to the classic [FizzBuzz](https://en.wikipedia.org/wiki/Fizz_buzz#Programming) problem.\n\n```py\n# fizzbuzz\n# Built with Seahorse v0.1.0\n#\n# On-chain, persistent FizzBuzz!\n\nfrom seahorse.prelude import *\n\ndeclare_id('Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS')\n\nclass FizzBuzz(Account):\n  fizz: bool\n  buzz: bool\n  n: u64\n\n@instruction\ndef init(owner: Signer, fizzbuzz: Empty[FizzBuzz]):\n  fizzbuzz.init(payer = owner, seeds = ['fizzbuzz', owner])\n\n@instruction\ndef do_fizzbuzz(fizzbuzz: FizzBuzz, n: u64):\n  fizzbuzz.fizz = n % 3 == 0\n  fizzbuzz.buzz = n % 5 == 0\n  if not fizzbuzz.fizz and not fizzbuzz.buzz:\n    fizzbuzz.n = n\n  else:\n    fizzbuzz.n = 0\n```\n\nThis shows some basic Seahorse functionality, like account initialization and creating instructions. For more, check out [Calculator: Your first Seahorse program](https://www.seahorse.dev/introduction/calculator-your-first-seahorse-program) or other examples [here](https://github.com/solana-developers/seahorse/tree/main/examples).\n\nThe compiler architecture changed entirely in v0.2.0, here's a brief overview - more details [here](https://github.com/solana-developers/seahorse/tree/main/src/core):\n\n```\nSEAHORSE CORE: THE COMPILER (v0.2.0)\n┌───────────────────────────────────────────┐\n│                                           │\n│ ┌───────────────────────────────────────┐ │\n│ │ PARSE                                 │ │\n│ │                                       │ │\n│ │ Turn Seahorse source code into Python │ │\n│ │ AST. Handled by rustpython.           │ │\n│ └───────────────────┬───────────────────┘ │\n│                     │                     │\n│                    AST                    │\n│                     │                     │\n│ ┌───────────────────▼───────────────────┐ │\n│ │ CLEAN                                 │ │\n│ │                                       │ │\n│ │ Remove unsupported parts from the AST │ │\n│ │ (like yields statements). Does some   │ │\n│ │ minor changes to make compilation     │ │\n│ │ easier.                               │ │\n│ └───────────────────┬───────────────────┘ │\n│                     │                     │\n│                    AST                    │\n│                     │                     │\n│ ┌───────────────────▼───────────────────┐ │\n│ │ PREPROCESS                            │ │\n│ │                                       │ │\n│ │ Find the source files for every       │ │\n│ │ import - recursively calls the first  │ │\n│ │ two steps as well.                    │ │\n│ │                                       │ │\n│ │ Outputs a \"module registry\" which has │ │\n│ │ every parsed+cleaned source file.     │ │\n│ └───────────────────┬───────────────────┘ │\n│                     │                     │\n│                  registry                 │\n│                     │                     │\n│ ┌───────────────────▼───────────────────┐ │\n│ │ COMPILE                               │ │\n│ │ ┌───────────────────────────────────┐ │ │\n│ │ │ NAMESPACE                         │ │ │\n│ │ │                                   │ │ │\n│ │ │ Resolve the location of every     │ │ │\n│ │ │ import/export in each module.     │ │ │\n│ │ └─────────────────┬─────────────────┘ │ │\n│ │                   │                   │ │\n│ │         registry \u0026 namespaces         │ │\n│ │                   │                   │ │\n│ │ ┌─────────────────▼─────────────────┐ │ │\n│ │ │ SIGN                              │ │ │\n│ │ │                                   │ │ │\n│ │ │ Find types of everything outside  │ │ │\n│ │ │ function bodies - class fields,   │ │ │\n│ │ │ function params/return type.      │ │ │\n│ │ └─────────────────┬─────────────────┘ │ │\n│ │                   │                   │ │\n│ │         registry \u0026 signatures         │ │\n│ │                   │                   │ │\n│ │ ┌─────────────────▼─────────────────┐ │ │\n│ │ │ CHECK                             │ │ │\n│ │ │                                   │ │ │\n│ │ │ Type check function bodies. Also  │ │ │\n│ │ │ outputs the type of each expres-  │ │ │\n│ │ │ sion, used for doing syntactic    │ │ │\n│ │ │ transformations later.            │ │ │\n│ │ └─────────────────┬─────────────────┘ │ │\n│ │                   │                   │ │\n│ │         registry \u0026 expr. types        │ │\n│ │                   │                   │ │\n│ │ ┌─────────────────▼─────────────────┐ │ │\n│ │ │ BUILD                             │ │ │\n│ │ │                                   │ │ │\n│ │ │ Turn the original Python AST into │ │ │\n│ │ │ a Rust-like AST, assisted by the  │ │ │\n│ │ │ type information from CHECK.      │ │ │\n│ │ │                                   │ │ │\n│ │ │ The new AST includes special      │ │ │\n│ │ │ constructs for things native to   │ │ │\n│ │ │ Anchor, like ix contexts.         │ │ │\n│ │ └───────────────────────────────────┘ │ │\n│ │                                       │ │\n│ └───────────────────┬───────────────────┘ │\n│                     │                     │\n│                    AST                    │\n│                     │                     │\n│ ┌───────────────────▼───────────────────┐ │\n│ │ GENERATE                              │ │\n│ │                                       │ │\n│ │ Finally, turn the Rust-like AST into  │ │\n│ │ Rust source code. Generates code for  │ │\n│ │ each source file individually, as     │ │\n│ │ well as a lib.rs that contains the    │ │\n│ │ \"real\" instruction entrypoints.       │ │\n│ └───────────────────────────────────────┘ │\n│                                           │\n└───────────────────────────────────────────┘\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolana-developers%2Fseahorse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolana-developers%2Fseahorse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolana-developers%2Fseahorse/lists"}