{"id":13338170,"url":"https://github.com/Tynik/python-fift","last_synced_at":"2025-03-11T08:32:32.073Z","repository":{"id":106380064,"uuid":"217590653","full_name":"Tynik/python-fift","owner":"Tynik","description":"The python module to implement TON smart contracts","archived":true,"fork":false,"pushed_at":"2019-11-18T06:04:30.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-23T20:13:08.603Z","etag":null,"topics":["blockchain","contest","fift","prototype","python","smart-contract","telegram","ton"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tynik.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":"2019-10-25T18:13:47.000Z","updated_at":"2023-01-28T13:52:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"ed63d302-c1d3-4e3a-bf0b-e3abb39d4514","html_url":"https://github.com/Tynik/python-fift","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/Tynik%2Fpython-fift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tynik%2Fpython-fift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tynik%2Fpython-fift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tynik%2Fpython-fift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tynik","download_url":"https://codeload.github.com/Tynik/python-fift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243000967,"owners_count":20219779,"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":["blockchain","contest","fift","prototype","python","smart-contract","telegram","ton"],"created_at":"2024-07-29T19:15:37.013Z","updated_at":"2025-03-11T08:32:32.062Z","avatar_url":"https://github.com/Tynik.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Python to Fift language transformer [PROTOTYPE]\n\nIt's the prototype version and only has a little bit a part of Fift language \npossibility.\n\nFift language book [link](https://test.ton.org/fiftbase.pdf).\n\n### Examples\n\nCreate an empty Fift script:\n```python\nfrom fift.fift import *\n\n@script(out_filename='script.fif')\ndef main():\n    # python code which will be transformed to Fift language\n    pass\n\nfift_code = main()\n```\nSo, you can do something with the generated Fift code in `fift_code` variable or \nset an optional keyword argument `out_filename` and the code will be automatically\nsaved into the passed filename.\n\nTo run the code transformation you need to call a function `main` wrapped `@script` \ndecorator. As a result you will get the generated Fift code.\n\n#### Include another Fift script\n\n```python\nfrom fift.fift import *\n\n@script()\ndef main():\n    # will be transformed as `\"Asm.fif\" include`\n    include('Asm.fif')\n    include('TonUtil.fif')\n\nmain()\n```\n\n#### Work with strings\n\n```python\nfrom fift.fift import *\n\n@script()\ndef main():\n    # Transforms in: `\"abc\"`\n    string('abc')\n    # Concatenation of many string values. Transforms in: `\"a\" \"b\" $+ 1 (.) $+`\n    string('a', 'b', 1)\n    # Transforms in: `.\"abc\"`\n    string('abc').print()\n    # Transforms in: `.\"abc\" cr`\n    string('abc').print(cr=True)\n    \n    # Convert a constant with number value to string value\n    # Transforms in: `1 constant a`\n    a = const('a', 1)\n    # Transforms in: `@' a (.) =: a`\n    assign(a, string(a))\n\nmain()\n```\n\n#### Create the new word and its usage\n\n```python\nfrom fift.fift import *\n\n@script()\ndef main():\n    # Transforms in: `{ dup * } : square`\n    square = word('square', dup(), '*')\n    # `2 square`\n    square(2)\n    # `{ dup square square * } : **5`\n    power5 = word('**5', square(square(dup())), '*')\n    power5(3)\n\nmain()\n```\n\n#### Create the different constants\n\n```python\nfrom fift.fift import *\n\n@script()\ndef main():\n    # create a constant with name `a` and value `1`\n    a = const('a', 1)\n    \n    # will be transformed as `dictnew constant d`\n    d = const('d', {})\n    # if a constant created with `{}` value the result variable will have `Dict` interface\n    # and you can add a new value to the created dict with using the next ways\n    # where:\n    #   1 : it's the key\n    #   (4, 'u') : the key size and type (u - unsigned, i - signed)\n    #   builder() : the value. Transformed as `\u003cb  b\u003e`. Also, you can pass another entity as value.\n    d.add(1, (4, 'u'), builder())\n    d[2] = ((4, 'u'), builder())\n    \n    # create the string constant\n    const('c', String('abc'))\n\nmain()\n```\n\n#### Construct the builder\n\n```python\nfrom fift.fift import *\n\n@script()\ndef main():\n    # create an empty builder and will be transformed as `\u003cb  b\u003e`\n    builder()\n    # `\u003cb 0 32 u, b\u003e`\n    builder().u(0, 32)\n    # `\u003cb 2 4 i, b\u003e`\n    builder().i(2, 4)\n    # `\u003cb swap B, b\u003e`\n    builder().b(swap())\n    # `\u003cb swap ref, b\u003e`\n    builder().r(swap())\n    # `\u003cb b{1001} s, b\u003e`\n    builder().s('b{1001}')\n    # `\u003cb 3 16 u, .s b\u003e`\n    builder().u(3, 16).inspect()\n    # `\u003cb 0 32 u, 2 4 i, b\u003e`\n    builder().u(0, 32).i(2, 4)\n\nmain()\n```\n\n#### Work with files (read, write and data deserialization)\n\n```python\nfrom fift.fift import *\n\n@script()\ndef main():\n    # read a file. Transforms in `\"test.bin\" file\u003eB`\n    file('test.bin').read()\n    # write to file. Transforms in `\"test.bin\" B\u003efile`\n    file('test.bin').write()\n    # deserialize data from a file\n    # transforms in `\"test.bin\" file\u003eB B\u003eboc \u003cs 7 u@+ 2 s@+ 256 B@+ ref@+`\n    file('test.bin').deserialize().u(7).s(2).b(256).r()\n\n    # deserialize data and safe something to constants\n    # transforms in:\n    #   null constant a\n    #   null constant b\n    #   \"test.bin\" file\u003eB B\u003eboc \u003cs 7 u@+ 2 s@+ 256 B@+ =: c ref@+ =: d\n    a = const('a', 'null')\n    b = const('b', 'null')\n    (file('test.bin').deserialize()\n        .u(7)\n        .s(2)\n        .b(256, const=a)\n        .r(const=b))\n\nmain()\n```\n\n#### Create a block\n\n```python\nfrom fift.fift import *\n\n@script()\ndef main():\n    # Transforms in: `{  }`\n    block()\n\nmain()\n```\n\n*** Also to understand how it works you can look at the python tests.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTynik%2Fpython-fift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTynik%2Fpython-fift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTynik%2Fpython-fift/lists"}