{"id":19442329,"url":"https://github.com/ackeecz/tezosgen","last_synced_at":"2025-12-29T16:29:05.467Z","repository":{"id":33861512,"uuid":"157722947","full_name":"AckeeCZ/tezosgen","owner":"AckeeCZ","description":"tezosgen - generating code for Tezos smart contracts","archived":true,"fork":false,"pushed_at":"2022-07-22T07:45:26.000Z","size":8087,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-13T22:25:13.931Z","etag":null,"topics":["ios","swift","tezos"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/AckeeCZ.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}},"created_at":"2018-11-15T14:18:54.000Z","updated_at":"2024-10-23T11:40:10.000Z","dependencies_parsed_at":"2022-09-09T12:01:41.814Z","dependency_job_id":null,"html_url":"https://github.com/AckeeCZ/tezosgen","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AckeeCZ%2Ftezosgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AckeeCZ%2Ftezosgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AckeeCZ%2Ftezosgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AckeeCZ%2Ftezosgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AckeeCZ","download_url":"https://codeload.github.com/AckeeCZ/tezosgen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250733004,"owners_count":21478270,"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":["ios","swift","tezos"],"created_at":"2024-11-10T15:39:00.221Z","updated_at":"2025-12-29T16:29:05.067Z","avatar_url":"https://github.com/AckeeCZ.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![ackee|tezosgen](Resources/cover-image.png)\n\n![Tests](https://github.com/AckeeCZ/tezosgen/workflows/Tests/badge.svg)\n[![Version](https://img.shields.io/cocoapods/v/TezosGen.svg?style=flat)](http://cocoapods.org/pods/TezosGen)\n[![License](https://img.shields.io/cocoapods/l/TezosGen.svg?style=flat)](http://cocoapods.org/pods/TezosGen)\n[![Swift Package Manager compatible](https://img.shields.io/badge/SPM-compatible-brightgreen.svg?style=flat\u0026colorA=28a745\u0026\u0026colorB=4E4E4E)](https://github.com/apple/swift-package-manager)\n[![Platform](https://img.shields.io/cocoapods/p/TezosGen.svg?style=flat)](http://cocoapods.org/pods/TezosGen)\n\n## What's tezosgen\n\ntezosgen is a smart contract code generator - you just specify the smart contract's specification and tezosgen generates type-safe `.swift` files, so using smart contracts in your iOS or Mac app has never been easier!\n\nThis project has been published as a part of [Tezos-iOS-Dev-Kit](https://github.com/AckeeCZ/Tezos-iOS-Dev-Kit)\n\n## Installation\n\nThere are multiple possibilities to install tezosgen on your machine or in your project, depending on your preferences and needs. Note that if you do not install `tezosgen` using `Cocoapods`, you will have have to import `TezosSwift` by yourself.\n\n\u003cdetails\u003e\n\u003csummary\u003eUsing \u003cstrong\u003eHomebrew\u003c/strong\u003e\u003c/summary\u003e\n\n```bash\n$ brew tap AckeeCZ/tezosgen\n$ brew install tezosgen\n$ tezosgen\n```\n\n---\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003eVia \u003cstrong\u003eCocoaPods\u003c/strong\u003e\u003c/summary\u003e\n\nIf you're using CocoaPods, you can simply add `pod 'TezosGen' ~\u003e 1.1.1` to your `Podfile`.\n\nThis will download the `tezosgen` binaries and dependencies in `Pods/` during your next `pod install` execution.\n\nGiven that you can specify an exact version for ``tezosgen`` in your `Podfile`, this allows you to ensure **all coworkers will use the same version of tezosgen for this project**.\n\nYou can then invoke tezosgen from your terminal:\n```sh\nPods/tezosgen/tezosgen …\n```\n\n_Note: tezosgen isn't really a pod, as it's not a library your code will depend on at runtime; so the installation via CocoaPods is just a trick that installs the tezosgen binaries in the Pods/ folder, but you won't see any swift files in the Pods/tezosgen group in your Xcode's Pods.xcodeproj. That's normal: the tezosgen binary is still present in that folder in the Finder._\n\n---\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eSwift Package Manager\u003c/strong\u003e\u003c/summary\u003e\n\nAdd this to your `Package.swift`:\n\n```swift\n.package(url: \"https://github.com/AckeeCZ/tezosgen.git\", .upToNextMajor(from: \"1.1.1\")),\n```\n\n\u003c/details\u003e\n\n### iOS MVVM Project Template\n\nWe have also created iOS MVVM Project Template, so setting your project has never been easier. \nEasily follow the [installation instructions](https://github.com/AckeeCZ/iOS-MVVM-ProjectTemplate).\nAfter you are done, add `name_of_your_abi.json` file to `Resources`. Then add `tezosgen` to your `Podfile`, do `pod install` and run this command in your project root directory:\n```sh\nPods/tezosgen/tezosgen HelloContract NameOfYourProject/Resources/abi.json -x NameOfYourProject.xcodeproj -o NameOfYourProject/Model/Generated/GeneraredContracts\n```\n\n## Usage\n\n### Example\n\nYou can find an example app [here](https://github.com/AckeeCZ/TezosSwift).\n\n### How to Get Contract Specifcation\n\nTo be able to generate smart contract code, we first need to have its specification. To find it, simply run `curl https://url_to_your_node/chains/main/blocks/head/context/contracts/contract_address | tr -d '\\n'`.\n\nThe output could look something like this:\n\n```{\"manager\":\"tz1dD918PXDuUHV6Mh6z2QqMukA67YULuhqd\",\"balance\":\"21000000\",\"spendable\":false,\"delegate\":{\"setable\":false},\"script\":{\"code\":[{\"prim\":\"parameter\",\"args\":[{\"prim\":\"set\",\"args\":[{\"prim\":\"nat\"}]}]},{\"prim\":\"storage\",\"args\":[{\"prim\":\"set\",\"args\":[{\"prim\":\"nat\"}]}]},{\"prim\":\"code\",\"args\":[[{\"prim\":\"CDR\"},{\"prim\":\"NIL\",\"args\":[{\"prim\":\"operation\"}]},{\"prim\":\"PAIR\"}]]}],\"storage\":[{\"int\":\"1\"},{\"int\":\"2\"},{\"int\":\"3\"}]},\"counter\":\"0\"}```\n\nWhat we need for our generator is hidden under the `code` key and we need to obtain the parameter and storage. So the specification for this contract, after a little modification, would look like this: \n\n```{\"parameter\": {\"prim\":\"set\",\"args\":[{\"prim\":\"nat\"}]}, \"storage\": {\"prim\":\"set\",\"args\":[{\"prim\":\"nat\"}]}}```\n\nTo expand on this, the specification should look like this:\n\n```{\"parameter\": {code_specified_under_args_for_parameter}, \"storage\": {code_specified_under_args_for_parameter}```\n\nBy defaul the parameters are then indexed from number one for better readability, but you can also name your parameters! (and if the values are named in the contract itself, you will get this for free). To do this, it would look like this: \n```{\"parameter\": {\"prim\":\"set\", \"annots\":[\"%first\"],\"args\":[{\"prim\":\"nat\"}]}, \"storage\": {\"prim\":\"set\",\"args\":[{\"prim\":\"nat\"}]}}```\n\n(that is add to the type a new key-value pair `\"annots\":[\"%desired_name\"]`)\n\n### Codegen\nThe standard usage looks like this `tezosgen HelloContract path_to_abi/abi.json -x path_to_xcodeproj/project.xcodeproj -o relative_output_path`\n\nPlease \u003cstrong\u003enote\u003c/strong\u003e that the output path option (`--output`) should be relative to your project - if your generated files are in `YourProjectName/MainFolder/GeneratedContracts` folder, then you should write `--output MainFolder/GeneratedContracts`\nFor your projects to be bound you also \u003cstrong\u003emust\u003c/strong\u003e set the `--xcode` option as well. Otherwise you will have to drag the files to your projects manually.\n\n### Combine\n\nIf you want to use the generated code with combine, just add this option when you are generating new code:\n```bash\n--extensions combine\n```\n\n### Usage of Generated Codes\n\nThe standard call using code created by `codegen` looks like this:\n```swift\nimport TezosSwift\ntezosClient.optionalStringContract(at: \"KT1Rh4iEMxBLJbDbz7iAB6FGLJ3mSCx3qFrW\").call(param1: \"hello\").send(from: wallet, amount: Tez(1), completion: { result in\n    switch result {\n    case .failure(let error):\n        XCTFail(\"Failed with error: \\(error)\")\n        testCompletionExpectation.fulfill()\n    case .success(_):\n        testCompletionExpectation.fulfill()\n    }\n})\n```\n\n`wallet` and `tezosClient` should be created with [TezosSwift](https://github.com/AckeeCZ/TezosSwift)\nAlso note that right now the created code works with `ReactiveSwift` only.\n\nResult of the call is either a `String` hash of the transaction or an `TezosError`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fackeecz%2Ftezosgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fackeecz%2Ftezosgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fackeecz%2Ftezosgen/lists"}