{"id":16728269,"url":"https://github.com/tmc/goteal","last_synced_at":"2025-04-10T11:03:56.966Z","repository":{"id":48332553,"uuid":"383285399","full_name":"tmc/goteal","owner":"tmc","description":"Go to TEAL compiler","archived":false,"fork":false,"pushed_at":"2021-08-20T02:02:52.000Z","size":149,"stargazers_count":10,"open_issues_count":1,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-24T09:47:14.242Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmc.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}},"created_at":"2021-07-05T23:19:15.000Z","updated_at":"2025-02-05T17:25:14.000Z","dependencies_parsed_at":"2022-09-18T10:42:33.308Z","dependency_job_id":null,"html_url":"https://github.com/tmc/goteal","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fgoteal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fgoteal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fgoteal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fgoteal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmc","download_url":"https://codeload.github.com/tmc/goteal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248207163,"owners_count":21065194,"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":[],"created_at":"2024-10-12T23:09:32.942Z","updated_at":"2025-04-10T11:03:56.934Z","avatar_url":"https://github.com/tmc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goteal\n\ngoteal enables writing Smart Contracts for Algorand in the Go programming language.\n\ngoteal achieves this by compiling Go programs into [AVM](https://developer.algorand.org/articles/introducing-algorand-virtual-machine-avm-09-release/)/[TEAL](https://developer.algorand.org/docs/reference/teal/specification/) programs.\n\n\n## Why goteal\n\ngoteal exists to simplify the process of authoring and testing Algorand Smart Contracts for people\nthat are familiar with the Go programming language.\n\nThose familiar with Go know that the language and surrounding ecosystem offers many helpful tools. `goteal` exists to bridge the Go ecosystem with the Algorand Smart Contract ecosystem. \n\n## How goteal works\n\ngoteal takes a Go program that follows a few constraints (see below) and transpiles/compiles it to\n[TEAL](https://developer.algorand.org/docs/reference/teal/specification/) (Transaction Execution Approval Language) - the language that nodes in the Algorand network execute to validate and approve transactions.\n\n## Constraints\n\nA [TEAL](https://developer.algorand.org/docs/reference/teal/specification/) program must exit with\nan integer value that indicates whether or not the transaction should proceed (zero for should-not-proceed,  \u003e0 for should-proceed). `goteal` expects a package that is being compiled to TEAL to expose the following interface:\n\n```go\n\nfunc Contract(globals types.Globals, gtxn types.GroupTransaction, txn types.Transaction) (int,\nerror)\n```\n\nWhere if any non-nil error is returned the program will halt (and reject the transaction).\n\n## Interface\n\nWhen an Algorand Smart Contract is executing there are several important sources of context:\n\n* globals - contains network-wide information including values of current global configuration\n  parameters.\n* txn - The current Transaction.\n* gtxn - The current Transaction Group (a Transaction in Algorand may be part of a group).\n\n\n# Compiling a contract with goteal\n\nYou compile a go program to TEAL program with the following pattern:\n\n```shell\ngoteal build github.com/yourname/yourproject/contract1\n```\n\nThis will leverage your current Go environment to find source code in the `contract1` package, will\nfind the `Contract()` entrypoint (as defined above) and output to stdout the TEAL program\nequivalent.\n\nYou can output direct bytecode by supplying the `-o bytecode` argument.\n\n# Important subcommands\n\n## goteal vet\n\n`goteal` intends to encourage common patterns and warn contract authors about common missteps or\nerrors in contract development. The `goteal vet` subcommand will run your contract through several\nstatic analysis checks to help guide you in your contract authorship.\n\n**Example usage:** `goteal vet github.com/yourname/yourproject/contract1`\n\n`goteal vet` will output in a standard format any issues that are detected in your contract design.\n\n## goteal test\n\n`goteal` leverages the rich testing ecosystem from the Go programming language and makes it easy to\nwrite tests that verify the behavior of your contract.\n\nBy placing your test code into `*_test.go` files in your package directory you can easily test your\ncontract via `goteal test`:\n\n**Example usage:** `goteal test github.com/yourname/yourproject/contract1`\n\n# Example Contracts\n\nThe [examples](./examples) subdirectory contains a number of example contracts.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmc%2Fgoteal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmc%2Fgoteal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmc%2Fgoteal/lists"}