pwrpy


Namepwrpy JSON
Version 6.0.4 PyPI version JSON
download
home_pagehttps://github.com/pwrlabs/pwrpy
SummaryPWRPY is a Python library for interacting with the PWR network.
upload_time2024-09-26 21:52:31
maintainerNone
docs_urlNone
authorPWR Labs
requires_python<3.13,>=3.8
licenseMIT
keywords pwr network python library
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PWRPY

PWRPY is a Python library for interacting with the PWR network.
It provides an easy interface for wallet management and sending transactions on PWR.

<div align="center">
<!-- markdownlint-restore -->

[![Pull Requests welcome](https://img.shields.io/badge/PRs-welcome-ff69b4.svg?style=flat-square)](https://github.com/pwrlabs/pwrpy/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
[![pypi](https://img.shields.io/pypi/v/pwrpy)](https://pypi.org/project/pwrpy/)
<a href="https://github.com/pwrlabs/pwrpy/blob/main/LICENSE/">
  <img src="https://img.shields.io/badge/license-MIT-black">
</a>
<!-- <a href="https://github.com/pwrlabs/pwrpy/stargazers">
  <img src='https://img.shields.io/github/stars/pwrlabs/pwrpy?color=yellow' />
</a> -->
<a href="https://pwrlabs.io/">
  <img src="https://img.shields.io/badge/powered_by-PWR Chain-navy">
</a>
<a href="https://www.youtube.com/@pwrlabs">
  <img src="https://img.shields.io/badge/Community%20calls-Youtube-red?logo=youtube"/>
</a>
<a href="https://twitter.com/pwrlabs">
  <img src="https://img.shields.io/twitter/follow/pwrlabs?style=social"/>
</a>

</div>

## Installation

```bash
# latest official release (main branch)
pip3 install pwrpy
```

## 🌐 Documentation

How to [Guides](https://pwrlabs.io) 🔜 & [API](https://pwrlabs.io) 💻

Play with [Code Examples](https://github.com/keep-pwr-strong/pwr-components/) 🎮

## 💫 Getting Started

**Import the library:**

```python
from pwrpy.pwrsdk import PWRPY
from pwrpy.pwrwallet import PWRWallet
```

**Set your rpc and wallet:**

```python
private_key = "0xac0974bec...f80"
pwr = PWRPY()
wallet = PWRWallet(private_key)
```

**Get wallet address:**

```python
address = wallet.get_address()
```

**Get wallet balance:**

```python
balance = wallet.get_balance()
```

**Get private key:**

```python
pk = wallet.get_private_key()
```

**Transfer PWR tokens:**

```python
transfer = wallet.transfer_pwr("recipientAddress", 100000)
```

Sending a transcation to the PWR Chain returns a Response object, which specified if the transaction was a success, and returns relevant data.
If the transaction was a success, you can retrieive the transaction hash, if it failed, you can fetch the error.

```python
transfer = wallet.transfer_pwr("recipientAddress", 100000)
if transfer.success:
    print("Transfer:", transfer.__dict__)
else:
    print("FAILED!")
```

**Send data to a VM:**

```python
data = "Hello World!"
sendVmData = wallet.send_vm_data_transaction(123, data.encode())
if sendVmData.success:
    print("SendVmData:", sendVmData.__dict__)
else:
    print("FAILED!")
```

### Other Static Calls

**Get RPC Node Url:**

Returns currently set RPC node URL.

```python
url = pwr.get_rpc_node_url()
```

**Get Fee Per Byte: **

Gets the latest fee-per-byte rate.

```python
fee = pwr.get_fee_per_byte()
```

**Get Balance Of Address:**

Gets the balance of a specific address.

```python
balance = pwr.get_balance_of_address('0x...')
```

**Get Nonce Of Address:**

Gets the nonce/transaction count of a specific address.

```python
nonce = pwr.get_nonce_of_address('0x...')
```

**Get VM Data:**

```python
start_block = 843500
end_block = 843750
vm_id = 123

transactions = pwr.get_vm_data_txns(start_block, end_block, vm_id)
for txs in transactions:
    print("Data:", txs.data)
```

**Broadcast Txn:**

Broadcasts a signed transaction to the network.

```python
signedTransaction = "..."
broadcast = pwr.broadcast_transaction(signedTransaction)
```

## ✏️ Contributing

If you consider to contribute to this project please read [CONTRIBUTING.md](https://github.com/pwrlabs/pwrpy/blob/main/CONTRIBUTING.md) first.

You can also join our dedicated channel for [pwrpy](https://discord.com/channels/1141787507189624992/1167387492153032735) on the [PWR Chain Discord](https://discord.com/invite/YASmBk9EME)

## 📜 License

Copyright (c) 2024 PWR Labs

Licensed under the [MIT license](https://github.com/pwrlabs/pwrpy/blob/main/LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pwrlabs/pwrpy",
    "name": "pwrpy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.8",
    "maintainer_email": null,
    "keywords": "pwr, network, python, library",
    "author": "PWR Labs",
    "author_email": "devservices@pwrlabs.io",
    "download_url": "https://files.pythonhosted.org/packages/d1/d2/f2c9238aa909309ed1b27041ded9a5b7f2e2323582433a89e0909dd5dcf3/pwrpy-6.0.4.tar.gz",
    "platform": null,
    "description": "# PWRPY\n\nPWRPY is a Python library for interacting with the PWR network.\nIt provides an easy interface for wallet management and sending transactions on PWR.\n\n<div align=\"center\">\n<!-- markdownlint-restore -->\n\n[![Pull Requests welcome](https://img.shields.io/badge/PRs-welcome-ff69b4.svg?style=flat-square)](https://github.com/pwrlabs/pwrpy/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)\n[![pypi](https://img.shields.io/pypi/v/pwrpy)](https://pypi.org/project/pwrpy/)\n<a href=\"https://github.com/pwrlabs/pwrpy/blob/main/LICENSE/\">\n  <img src=\"https://img.shields.io/badge/license-MIT-black\">\n</a>\n<!-- <a href=\"https://github.com/pwrlabs/pwrpy/stargazers\">\n  <img src='https://img.shields.io/github/stars/pwrlabs/pwrpy?color=yellow' />\n</a> -->\n<a href=\"https://pwrlabs.io/\">\n  <img src=\"https://img.shields.io/badge/powered_by-PWR Chain-navy\">\n</a>\n<a href=\"https://www.youtube.com/@pwrlabs\">\n  <img src=\"https://img.shields.io/badge/Community%20calls-Youtube-red?logo=youtube\"/>\n</a>\n<a href=\"https://twitter.com/pwrlabs\">\n  <img src=\"https://img.shields.io/twitter/follow/pwrlabs?style=social\"/>\n</a>\n\n</div>\n\n## Installation\n\n```bash\n# latest official release (main branch)\npip3 install pwrpy\n```\n\n## \ud83c\udf10 Documentation\n\nHow to [Guides](https://pwrlabs.io) \ud83d\udd1c & [API](https://pwrlabs.io) \ud83d\udcbb\n\nPlay with [Code Examples](https://github.com/keep-pwr-strong/pwr-components/) \ud83c\udfae\n\n## \ud83d\udcab Getting Started\n\n**Import the library:**\n\n```python\nfrom pwrpy.pwrsdk import PWRPY\nfrom pwrpy.pwrwallet import PWRWallet\n```\n\n**Set your rpc and wallet:**\n\n```python\nprivate_key = \"0xac0974bec...f80\"\npwr = PWRPY()\nwallet = PWRWallet(private_key)\n```\n\n**Get wallet address:**\n\n```python\naddress = wallet.get_address()\n```\n\n**Get wallet balance:**\n\n```python\nbalance = wallet.get_balance()\n```\n\n**Get private key:**\n\n```python\npk = wallet.get_private_key()\n```\n\n**Transfer PWR tokens:**\n\n```python\ntransfer = wallet.transfer_pwr(\"recipientAddress\", 100000)\n```\n\nSending a transcation to the PWR Chain returns a Response object, which specified if the transaction was a success, and returns relevant data.\nIf the transaction was a success, you can retrieive the transaction hash, if it failed, you can fetch the error.\n\n```python\ntransfer = wallet.transfer_pwr(\"recipientAddress\", 100000)\nif transfer.success:\n    print(\"Transfer:\", transfer.__dict__)\nelse:\n    print(\"FAILED!\")\n```\n\n**Send data to a VM:**\n\n```python\ndata = \"Hello World!\"\nsendVmData = wallet.send_vm_data_transaction(123, data.encode())\nif sendVmData.success:\n    print(\"SendVmData:\", sendVmData.__dict__)\nelse:\n    print(\"FAILED!\")\n```\n\n### Other Static Calls\n\n**Get RPC Node Url:**\n\nReturns currently set RPC node URL.\n\n```python\nurl = pwr.get_rpc_node_url()\n```\n\n**Get Fee Per Byte: **\n\nGets the latest fee-per-byte rate.\n\n```python\nfee = pwr.get_fee_per_byte()\n```\n\n**Get Balance Of Address:**\n\nGets the balance of a specific address.\n\n```python\nbalance = pwr.get_balance_of_address('0x...')\n```\n\n**Get Nonce Of Address:**\n\nGets the nonce/transaction count of a specific address.\n\n```python\nnonce = pwr.get_nonce_of_address('0x...')\n```\n\n**Get VM Data:**\n\n```python\nstart_block = 843500\nend_block = 843750\nvm_id = 123\n\ntransactions = pwr.get_vm_data_txns(start_block, end_block, vm_id)\nfor txs in transactions:\n    print(\"Data:\", txs.data)\n```\n\n**Broadcast Txn:**\n\nBroadcasts a signed transaction to the network.\n\n```python\nsignedTransaction = \"...\"\nbroadcast = pwr.broadcast_transaction(signedTransaction)\n```\n\n## \u270f\ufe0f Contributing\n\nIf you consider to contribute to this project please read [CONTRIBUTING.md](https://github.com/pwrlabs/pwrpy/blob/main/CONTRIBUTING.md) first.\n\nYou can also join our dedicated channel for [pwrpy](https://discord.com/channels/1141787507189624992/1167387492153032735) on the [PWR Chain Discord](https://discord.com/invite/YASmBk9EME)\n\n## \ud83d\udcdc License\n\nCopyright (c) 2024 PWR Labs\n\nLicensed under the [MIT license](https://github.com/pwrlabs/pwrpy/blob/main/LICENSE).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "PWRPY is a Python library for interacting with the PWR network.",
    "version": "6.0.4",
    "project_urls": {
        "Documentation": "https://docs.pwrlabs.io/",
        "Homepage": "https://github.com/pwrlabs/pwrpy",
        "Repository": "https://github.com/pwrlabs/pwrpy"
    },
    "split_keywords": [
        "pwr",
        " network",
        " python",
        " library"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fd473e43408379180f38f2ae6c8083c63c175ea52a49eb0eafe1f091b388dfd0",
                "md5": "8bea66fd9e7c0a6fe89312621a44744f",
                "sha256": "3856fd0791048c08ffafd55edf46b4f7bfd82184142d1cb9d858d63b5e24edc0"
            },
            "downloads": -1,
            "filename": "pwrpy-6.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8bea66fd9e7c0a6fe89312621a44744f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.8",
            "size": 21556,
            "upload_time": "2024-09-26T21:52:30",
            "upload_time_iso_8601": "2024-09-26T21:52:30.034154Z",
            "url": "https://files.pythonhosted.org/packages/fd/47/3e43408379180f38f2ae6c8083c63c175ea52a49eb0eafe1f091b388dfd0/pwrpy-6.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d1d2f2c9238aa909309ed1b27041ded9a5b7f2e2323582433a89e0909dd5dcf3",
                "md5": "b20f0dfc619604fb34e790cdf75c4ab3",
                "sha256": "60b092a38dbcd91e23233becc1245993ddb3e70c237b58ba07d3befd725882bd"
            },
            "downloads": -1,
            "filename": "pwrpy-6.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "b20f0dfc619604fb34e790cdf75c4ab3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.8",
            "size": 19757,
            "upload_time": "2024-09-26T21:52:31",
            "upload_time_iso_8601": "2024-09-26T21:52:31.478784Z",
            "url": "https://files.pythonhosted.org/packages/d1/d2/f2c9238aa909309ed1b27041ded9a5b7f2e2323582433a89e0909dd5dcf3/pwrpy-6.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-26 21:52:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pwrlabs",
    "github_project": "pwrpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pwrpy"
}
        
Elapsed time: 1.39176s