py-near


Namepy-near JSON
Version 1.2.7 PyPI version JSON
download
home_pageNone
SummaryAsync client for NEAR Blockchain with native HOT Protocol & NEAR Intents support
upload_time2025-11-17 06:27:53
maintainerNone
docs_urlNone
authorNone
requires_python<4,>=3.9
licensePermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords python near async
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # py-near

[![Financial Contributors on Open Collective](https://opencollective.com/py-near/all/badge.svg?style=flat-square)](https://opencollective.com/py-near) 
[![PyPi Package Version](https://img.shields.io/pypi/v/py-near?style=flat-square)](https://pypi.org/project/py-near)
[![Supported python versions](https://img.shields.io/pypi/pyversions/py-near)](https://pypi.python.org/pypi/py-near)
[![Documentation Status](https://img.shields.io/readthedocs/py-near?style=flat-square)](https://py-near.readthedocs.io/en/latest)
[![Github issues](https://img.shields.io/github/issues/pvolnov/py-near.svg?style=flat-square)](https://github.com/pvolnov/py-near/issues)
[![MIT License](https://img.shields.io/pypi/l/py-near.svg?style=flat-square?style=flat-square)](https://opensource.org/licenses/MIT)
[![Twitter](https://img.shields.io/twitter/follow/p_volnov?label=Follow)](https://twitter.com/p_volnov)

[//]: # ([![downloads]&#40;https://img.shields.io/github/downloads/pvolnov/py-near/total?style=flat-square&#41;]&#40;https://pypi.org/project/py-near&#41;)


**py-near** is a Async client for NEAR Blockchain with native HOT Protocol & NEAR Intents support

## Examples
<details>
  <summary>πŸ“š Click to see some basic examples</summary>


**Few steps before getting started...**
- Install the latest stable version of py-near, simply running `pip install py-near`
- Create NEAR account and get your private key [wallet](https://wallet.near.org/create)

### Simple money transfer

```python
from py_near.account import Account
import asyncio
from py_near.dapps.core import NEAR

ACCOUNT_ID = "bob.near"
PRIVATE_KEY = "ed25519:..."


async def main():
   acc = Account(ACCOUNT_ID, PRIVATE_KEY)

   await acc.startup()
   print(await acc.get_balance() / NEAR)
   print(await acc.get_balance("bob.near") / NEAR)

   tr = await acc.send_money("bob.near", NEAR * 2)
   print(tr.transaction.hash)
   print(tr.logs)


asyncio.run(main())
```

### Working with NEAR Intents (OmniBalance)

```python
from py_near.omni_balance import OmniBalance
import asyncio

ACCOUNT_ID = "bob.near"
PRIVATE_KEY = "ed25519:..."


async def main():
    omni = OmniBalance(ACCOUNT_ID, PRIVATE_KEY)
    await omni.startup()
    
    # Create intent with multiple actions: transfer, token swap, and auth call
    commitment = omni.transfer(
        tokens={"nep141:wrap.near": "5"},
        receiver_id="alice.near",
        memo="Test transfer",
    ).token_diff({
        "nep141:wrap.near": "-5",
    }).auth_call("contract.near", msg="test").sign()
    
    # Simulate intent before submitting
    sim = await omni.simulate_intent(commitment)
    print(sim.logged_intents)
    
    # Submit intent to solver network
    intent_hash = await omni.publish_intents(commitment)
    print(f"Intent hash: {intent_hash}")
    
    # Wait for transaction hash
    tr_hash = await omni.get_tr_hash_from_intent(intent_hash)
    print(f"Transaction hash: {tr_hash}")
    
    await omni.shutdown()


asyncio.run(main())
```

### Parallel requests

Only one parallel request can be made from one private key.
All transaction calls execute sequentially.
To make several parallel calls you need to use several private keys



```python3
acc = Account("bob.near", private_key1)

for i in range(2):
  signer = InMemorySigner.from_random(AccountId("bob.near"), KeyType.ED25519)
  await acc.add_full_access_public_key(str(signer.public_key))
  print(signer.secret_key)
```

Now we can call transactions in parallel

```python3
acc = Account("bob.near", [private_key1, private_key2, private_key3])
# request time = count transactions / count public keys
tasks = [
  asyncio.create_task(acc.send_money("alisa.near", 1)),
  asyncio.create_task(acc.send_money("alisa.near", 1)),
  asyncio.create_task(acc.send_money("alisa.near", 1)),
]
for t in tasks:
  await t
```

</details>


## Official py-near resources:
 - News: [@herewallet](https://t.me/herewallet)
 - Social media:
   - πŸ‡ΊπŸ‡Έ [Telegram](https://t.me/neafiol)
   - πŸ‡ΊπŸ‡Έ [Twitter](https://twitter.com/p_volnov)
 - PyPI: [py-near](https://pypi.python.org/pypi/py-near)
 - Documentation: [py-near.readthedocs.io](https://py-near.readthedocs.io/en/latest)
 - Source: [Github repo](https://github.com/pvolnov/py-near)
 - Issues/Bug tracker: [Github issues tracker](https://github.com/pvolnov/py-near/issues)

## Contributors

### Code Contributors

This project exists thanks to all the people who contribute. [[Code of conduct](CODE_OF_CONDUCT.md)].
<a href="https://github.com/pvolnov/py-near/graphs/contributors"><img src="https://opencollective.com/py-near/contributors.svg?width=890&button=false" /></a>

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "py-near",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.9",
    "maintainer_email": null,
    "keywords": "python, near, async",
    "author": null,
    "author_email": "pvolnov <peter@hot-labs.org>",
    "download_url": "https://files.pythonhosted.org/packages/1c/93/586a8ccf01f55f11aa2bd496634d54c0b4af987bd89fbf1118b87e37be6e/py_near-1.2.7.tar.gz",
    "platform": null,
    "description": "# py-near\n\n[![Financial Contributors on Open Collective](https://opencollective.com/py-near/all/badge.svg?style=flat-square)](https://opencollective.com/py-near) \n[![PyPi Package Version](https://img.shields.io/pypi/v/py-near?style=flat-square)](https://pypi.org/project/py-near)\n[![Supported python versions](https://img.shields.io/pypi/pyversions/py-near)](https://pypi.python.org/pypi/py-near)\n[![Documentation Status](https://img.shields.io/readthedocs/py-near?style=flat-square)](https://py-near.readthedocs.io/en/latest)\n[![Github issues](https://img.shields.io/github/issues/pvolnov/py-near.svg?style=flat-square)](https://github.com/pvolnov/py-near/issues)\n[![MIT License](https://img.shields.io/pypi/l/py-near.svg?style=flat-square?style=flat-square)](https://opensource.org/licenses/MIT)\n[![Twitter](https://img.shields.io/twitter/follow/p_volnov?label=Follow)](https://twitter.com/p_volnov)\n\n[//]: # ([![downloads]&#40;https://img.shields.io/github/downloads/pvolnov/py-near/total?style=flat-square&#41;]&#40;https://pypi.org/project/py-near&#41;)\n\n\n**py-near** is a Async client for NEAR Blockchain with native HOT Protocol & NEAR Intents support\n\n## Examples\n<details>\n  <summary>\ud83d\udcda Click to see some basic examples</summary>\n\n\n**Few steps before getting started...**\n- Install the latest stable version of py-near, simply running `pip install py-near`\n- Create NEAR account and get your private key [wallet](https://wallet.near.org/create)\n\n### Simple money transfer\n\n```python\nfrom py_near.account import Account\nimport asyncio\nfrom py_near.dapps.core import NEAR\n\nACCOUNT_ID = \"bob.near\"\nPRIVATE_KEY = \"ed25519:...\"\n\n\nasync def main():\n   acc = Account(ACCOUNT_ID, PRIVATE_KEY)\n\n   await acc.startup()\n   print(await acc.get_balance() / NEAR)\n   print(await acc.get_balance(\"bob.near\") / NEAR)\n\n   tr = await acc.send_money(\"bob.near\", NEAR * 2)\n   print(tr.transaction.hash)\n   print(tr.logs)\n\n\nasyncio.run(main())\n```\n\n### Working with NEAR Intents (OmniBalance)\n\n```python\nfrom py_near.omni_balance import OmniBalance\nimport asyncio\n\nACCOUNT_ID = \"bob.near\"\nPRIVATE_KEY = \"ed25519:...\"\n\n\nasync def main():\n    omni = OmniBalance(ACCOUNT_ID, PRIVATE_KEY)\n    await omni.startup()\n    \n    # Create intent with multiple actions: transfer, token swap, and auth call\n    commitment = omni.transfer(\n        tokens={\"nep141:wrap.near\": \"5\"},\n        receiver_id=\"alice.near\",\n        memo=\"Test transfer\",\n    ).token_diff({\n        \"nep141:wrap.near\": \"-5\",\n    }).auth_call(\"contract.near\", msg=\"test\").sign()\n    \n    # Simulate intent before submitting\n    sim = await omni.simulate_intent(commitment)\n    print(sim.logged_intents)\n    \n    # Submit intent to solver network\n    intent_hash = await omni.publish_intents(commitment)\n    print(f\"Intent hash: {intent_hash}\")\n    \n    # Wait for transaction hash\n    tr_hash = await omni.get_tr_hash_from_intent(intent_hash)\n    print(f\"Transaction hash: {tr_hash}\")\n    \n    await omni.shutdown()\n\n\nasyncio.run(main())\n```\n\n### Parallel requests\n\nOnly one parallel request can be made from one private key.\nAll transaction calls execute sequentially.\nTo make several parallel calls you need to use several private keys\n\n\n\n```python3\nacc = Account(\"bob.near\", private_key1)\n\nfor i in range(2):\n  signer = InMemorySigner.from_random(AccountId(\"bob.near\"), KeyType.ED25519)\n  await acc.add_full_access_public_key(str(signer.public_key))\n  print(signer.secret_key)\n```\n\nNow we can call transactions in parallel\n\n```python3\nacc = Account(\"bob.near\", [private_key1, private_key2, private_key3])\n# request time = count transactions / count public keys\ntasks = [\n  asyncio.create_task(acc.send_money(\"alisa.near\", 1)),\n  asyncio.create_task(acc.send_money(\"alisa.near\", 1)),\n  asyncio.create_task(acc.send_money(\"alisa.near\", 1)),\n]\nfor t in tasks:\n  await t\n```\n\n</details>\n\n\n## Official py-near resources:\n - News: [@herewallet](https://t.me/herewallet)\n - Social media:\n   - \ud83c\uddfa\ud83c\uddf8 [Telegram](https://t.me/neafiol)\n   - \ud83c\uddfa\ud83c\uddf8 [Twitter](https://twitter.com/p_volnov)\n - PyPI: [py-near](https://pypi.python.org/pypi/py-near)\n - Documentation: [py-near.readthedocs.io](https://py-near.readthedocs.io/en/latest)\n - Source: [Github repo](https://github.com/pvolnov/py-near)\n - Issues/Bug tracker: [Github issues tracker](https://github.com/pvolnov/py-near/issues)\n\n## Contributors\n\n### Code Contributors\n\nThis project exists thanks to all the people who contribute. [[Code of conduct](CODE_OF_CONDUCT.md)].\n<a href=\"https://github.com/pvolnov/py-near/graphs/contributors\"><img src=\"https://opencollective.com/py-near/contributors.svg?width=890&button=false\" /></a>\n",
    "bugtrack_url": null,
    "license": "Permission is hereby granted, free of charge, to any\n        person obtaining a copy of this software and associated\n        documentation files (the \"Software\"), to deal in the\n        Software without restriction, including without\n        limitation the rights to use, copy, modify, merge,\n        publish, distribute, sublicense, and/or sell copies of\n        the Software, and to permit persons to whom the Software\n        is furnished to do so, subject to the following\n        conditions:\n        \n        The above copyright notice and this permission notice\n        shall be included in all copies or substantial portions\n        of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF\n        ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED\n        TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n        PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT\n        SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n        CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n        OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR\n        IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n        DEALINGS IN THE SOFTWARE.\n        ",
    "summary": "Async client for NEAR Blockchain with native HOT Protocol & NEAR Intents support",
    "version": "1.2.7",
    "project_urls": {
        "changelog": "https://github.com/pvolnov/py-near/blob/main/CHANGELOG.md",
        "documentation": "https://py-near.readthedocs.io/en/latest",
        "funding": "https://opencollective.com/py-near",
        "homepage": "https://github.com/pvolnov/py-near",
        "repository": "https://github.com/pvolnov/py-near",
        "twitter": "https://twitter.com/p_volnov"
    },
    "split_keywords": [
        "python",
        " near",
        " async"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "24a7caab3e06e10b73fc038907c9f84510e71d795ee2ea27e3b8727dd912482d",
                "md5": "7af7520c1e8838f1d2b32e7b4fb52f9a",
                "sha256": "4ae5045a0f1e00838a14155c75549f05340812c9761ef7cff624747246c5184b"
            },
            "downloads": -1,
            "filename": "py_near-1.2.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7af7520c1e8838f1d2b32e7b4fb52f9a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.9",
            "size": 50188,
            "upload_time": "2025-11-17T06:27:52",
            "upload_time_iso_8601": "2025-11-17T06:27:52.195380Z",
            "url": "https://files.pythonhosted.org/packages/24/a7/caab3e06e10b73fc038907c9f84510e71d795ee2ea27e3b8727dd912482d/py_near-1.2.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1c93586a8ccf01f55f11aa2bd496634d54c0b4af987bd89fbf1118b87e37be6e",
                "md5": "5ed5782f83cc52296e33f7b1a60a6e82",
                "sha256": "d680ce2ac9ade5e79a27c8d4c478438d14676d03364d48331d569770c9b8b154"
            },
            "downloads": -1,
            "filename": "py_near-1.2.7.tar.gz",
            "has_sig": false,
            "md5_digest": "5ed5782f83cc52296e33f7b1a60a6e82",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.9",
            "size": 43116,
            "upload_time": "2025-11-17T06:27:53",
            "upload_time_iso_8601": "2025-11-17T06:27:53.801193Z",
            "url": "https://files.pythonhosted.org/packages/1c/93/586a8ccf01f55f11aa2bd496634d54c0b4af987bd89fbf1118b87e37be6e/py_near-1.2.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-11-17 06:27:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pvolnov",
    "github_project": "py-near",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "py-near"
}
        
Elapsed time: 2.10583s