PyArweave


NamePyArweave JSON
Version 0.6.0 PyPI version JSON
download
home_pagehttps://github.com/xloem/pyarweave
SummaryTiny Arweave Library
upload_time2023-05-16 17:31:58
maintainer
docs_urlNone
authorxloem
requires_python
license
keywords arweave crypto
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyArweave
This is a small python client for arweave, based on https://github.com/MikeHibbert/arweave-python-client .

I can struggle to code, so the hope is to keep this small and simple and ask the universe for more developers to take over maintainership.

Meanwhile, here's an arweave library.

## Installing
```
pip install pyarweave
```

# possibly-outdated documentation

## Using your wallet
Once installed you can import it and supply the wallet object with the path to your wallet JSON file:
```
import ar


wallet_file_path = '/some/folder/on/your/system'
wallet = ar.Wallet(wallet_file_path)

balance =  wallet.balance

last_transaction = wallet.get_last_transaction_id()
```

## Loading your wallet
If your wallet data is stored in a secret manager or anywhere other than a file, you can load it with the `from_data` classmethod:
```
import ar

wallet_data = // Load from cloud storage or wherever
wallet = ar.Wallet.from_data(wallet_data)

balance =  wallet.balance
```

## Transactions
To send a transaction you will need to open your wallet, create a transaction object, sign the transaction and then finally post the transaction:
```
import ar


wallet_file_path = '/some/folder/on/your/system'
wallet = ar.Wallet(wallet_file_path)

transaction = ar.Transaction(wallet, quantity=0.3, to='<some wallet address')
transaction.sign()
transaction.send()
```

#####ATTENTION! quantity is in AR and is automatically converted to Winston before sending

## Uploading large files
Uploading large data files is now possible! you can now upload data larger than your physical memory or maximum transaction size (12MB) in the following way
```
from ar.arweave_lib import Wallet, Transaction
from ar.transaction_uploader import get_uploader

wallet = Wallet(jwk_file)

with open('my_mahoosive_file.dat', 'rb', buffering=0) as file_handler:
    tx = Transaction(wallet, file_handler=file_handler, file_path='/some/path/my_mahoosive_file.dat')
    tx.add_tag('Content-Type', 'application/dat')
    tx.sign()

    uploader = get_uploader(tx, file_handler)

    while not uploader.is_complete:
        uploader.upload_chunk()

        logger.info('{}% complete, {}/{}'.format(
            uploader.pct_complete, uploader.uploaded_chunks, uploader.total_chunks
        ))
```
NOTE: When uploading you only need to supply a file handle with buffering=0 instead of reading in the data all at once. The data will be read progressively in small chunks

To check the status of a transaction after sending:
```
status = transaction.get_status()
```

To check the status much later you can store the ```transaction.id``` and reload it:
```
transaction = Transaction(wallet, id='some id you stored')
status = transaction.get_status()
```

## Storing data
As you know Arweave allows you to permanently store data on the network and you can do this by supplying data to the transaction as a string object:
```
wallet = Wallet(jwk_file)

with open('myfile.pdf', 'r') as mypdf:
    pdf_string_data = mypdf.read()

    transaction = Transaction(wallet, data=pdf_string_data)
    transaction.sign()
    transaction.send()
```

## Retrieving transactions/data
To get the information about a transaction you can create a transaction object with the ID of that transaction:
```
tx = Transaction(wallet, id=<your tx id>)
tx.get_transaction()
```

In addition you may want to get the data attached to this transaction once you've decided you need it:
```
tx.get_data()
print(tx.data)
> 'some data'
```

## Sending to a specific Node
You can specify a specific node by setting the api_url of the wallet/transaction object:
```
wallet = Wallet(jwk_file)
wallet.api_url = 'some specific node ip/address and port'

Or

transaction = Transaction(wallet, data=pdf_string_data)
transaction.api_url = 'some specific node ip/address and port'

```

## Arql
You can now perform searches using the arql method:
```
from ar.arweave_lib import arql

wallet_file_path = '/some/folder/on/your/system'
wallet = ar.Wallet(wallet_file_path)

transaction_ids = arql(
    wallet,
    {
        'op': 'equals',
        'expr1': 'from',
        'expr2': 'Some owner address'
    })
```

Alternatively, you can use a the helper method arql_with_transaction_data() to get all transaction ids as well as all the data stored in the blockchain
```
import ar

wallet_file_path = '/some/folder/on/your/system'
wallet = ar.Wallet(wallet_file_path)

transactions = aweave.arql_with_transaction_data(
    wallet,
    {
        'op': 'equals',
        'expr1': 'from',
        'expr2': 'Some owner address'
    })
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/xloem/pyarweave",
    "name": "PyArweave",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "arweave,crypto",
    "author": "xloem",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/2f/25/a13337c5ca2c6d773400bb8dfd76ea91a7bd4c3a9e21a4ee18b9a983f1f6/PyArweave-0.6.0.tar.gz",
    "platform": null,
    "description": "# PyArweave\nThis is a small python client for arweave, based on https://github.com/MikeHibbert/arweave-python-client .\n\nI can struggle to code, so the hope is to keep this small and simple and ask the universe for more developers to take over maintainership.\n\nMeanwhile, here's an arweave library.\n\n## Installing\n```\npip install pyarweave\n```\n\n# possibly-outdated documentation\n\n## Using your wallet\nOnce installed you can import it and supply the wallet object with the path to your wallet JSON file:\n```\nimport ar\n\n\nwallet_file_path = '/some/folder/on/your/system'\nwallet = ar.Wallet(wallet_file_path)\n\nbalance =  wallet.balance\n\nlast_transaction = wallet.get_last_transaction_id()\n```\n\n## Loading your wallet\nIf your wallet data is stored in a secret manager or anywhere other than a file, you can load it with the `from_data` classmethod:\n```\nimport ar\n\nwallet_data = // Load from cloud storage or wherever\nwallet = ar.Wallet.from_data(wallet_data)\n\nbalance =  wallet.balance\n```\n\n## Transactions\nTo send a transaction you will need to open your wallet, create a transaction object, sign the transaction and then finally post the transaction:\n```\nimport ar\n\n\nwallet_file_path = '/some/folder/on/your/system'\nwallet = ar.Wallet(wallet_file_path)\n\ntransaction = ar.Transaction(wallet, quantity=0.3, to='<some wallet address')\ntransaction.sign()\ntransaction.send()\n```\n\n#####ATTENTION! quantity is in AR and is automatically converted to Winston before sending\n\n## Uploading large files\nUploading large data files is now possible! you can now upload data larger than your physical memory or maximum transaction size (12MB) in the following way\n```\nfrom ar.arweave_lib import Wallet, Transaction\nfrom ar.transaction_uploader import get_uploader\n\nwallet = Wallet(jwk_file)\n\nwith open('my_mahoosive_file.dat', 'rb', buffering=0) as file_handler:\n    tx = Transaction(wallet, file_handler=file_handler, file_path='/some/path/my_mahoosive_file.dat')\n    tx.add_tag('Content-Type', 'application/dat')\n    tx.sign()\n\n    uploader = get_uploader(tx, file_handler)\n\n    while not uploader.is_complete:\n        uploader.upload_chunk()\n\n        logger.info('{}% complete, {}/{}'.format(\n            uploader.pct_complete, uploader.uploaded_chunks, uploader.total_chunks\n        ))\n```\nNOTE: When uploading you only need to supply a file handle with buffering=0 instead of reading in the data all at once. The data will be read progressively in small chunks\n\nTo check the status of a transaction after sending:\n```\nstatus = transaction.get_status()\n```\n\nTo check the status much later you can store the ```transaction.id``` and reload it:\n```\ntransaction = Transaction(wallet, id='some id you stored')\nstatus = transaction.get_status()\n```\n\n## Storing data\nAs you know Arweave allows you to permanently store data on the network and you can do this by supplying data to the transaction as a string object:\n```\nwallet = Wallet(jwk_file)\n\nwith open('myfile.pdf', 'r') as mypdf:\n    pdf_string_data = mypdf.read()\n\n    transaction = Transaction(wallet, data=pdf_string_data)\n    transaction.sign()\n    transaction.send()\n```\n\n## Retrieving transactions/data\nTo get the information about a transaction you can create a transaction object with the ID of that transaction:\n```\ntx = Transaction(wallet, id=<your tx id>)\ntx.get_transaction()\n```\n\nIn addition you may want to get the data attached to this transaction once you've decided you need it:\n```\ntx.get_data()\nprint(tx.data)\n> 'some data'\n```\n\n## Sending to a specific Node\nYou can specify a specific node by setting the api_url of the wallet/transaction object:\n```\nwallet = Wallet(jwk_file)\nwallet.api_url = 'some specific node ip/address and port'\n\nOr\n\ntransaction = Transaction(wallet, data=pdf_string_data)\ntransaction.api_url = 'some specific node ip/address and port'\n\n```\n\n## Arql\nYou can now perform searches using the arql method:\n```\nfrom ar.arweave_lib import arql\n\nwallet_file_path = '/some/folder/on/your/system'\nwallet = ar.Wallet(wallet_file_path)\n\ntransaction_ids = arql(\n    wallet,\n    {\n        'op': 'equals',\n        'expr1': 'from',\n        'expr2': 'Some owner address'\n    })\n```\n\nAlternatively, you can use a the helper method arql_with_transaction_data() to get all transaction ids as well as all the data stored in the blockchain\n```\nimport ar\n\nwallet_file_path = '/some/folder/on/your/system'\nwallet = ar.Wallet(wallet_file_path)\n\ntransactions = aweave.arql_with_transaction_data(\n    wallet,\n    {\n        'op': 'equals',\n        'expr1': 'from',\n        'expr2': 'Some owner address'\n    })\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Tiny Arweave Library",
    "version": "0.6.0",
    "project_urls": {
        "Homepage": "https://github.com/xloem/pyarweave"
    },
    "split_keywords": [
        "arweave",
        "crypto"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b6506c003212b2041dd4eb29e85e8c4d37afab679aa8438dd23fe94af3ad5473",
                "md5": "9b9dc7d1468eef2f41decb35500dc43b",
                "sha256": "6b3ee5a8c706739ddec8a8052f919e90b4502770149033193355d837e6f12f8b"
            },
            "downloads": -1,
            "filename": "PyArweave-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9b9dc7d1468eef2f41decb35500dc43b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 57256,
            "upload_time": "2023-05-16T17:31:54",
            "upload_time_iso_8601": "2023-05-16T17:31:54.359501Z",
            "url": "https://files.pythonhosted.org/packages/b6/50/6c003212b2041dd4eb29e85e8c4d37afab679aa8438dd23fe94af3ad5473/PyArweave-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f25a13337c5ca2c6d773400bb8dfd76ea91a7bd4c3a9e21a4ee18b9a983f1f6",
                "md5": "f67fa3c743c9ad92ad5a1cb7e71bd3db",
                "sha256": "7fd8b8d36e2921376007c1431e58c2df6b30771d2e7f068548c6f7934ff32cf5"
            },
            "downloads": -1,
            "filename": "PyArweave-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f67fa3c743c9ad92ad5a1cb7e71bd3db",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 64699,
            "upload_time": "2023-05-16T17:31:58",
            "upload_time_iso_8601": "2023-05-16T17:31:58.447868Z",
            "url": "https://files.pythonhosted.org/packages/2f/25/a13337c5ca2c6d773400bb8dfd76ea91a7bd4c3a9e21a4ee18b9a983f1f6/PyArweave-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-16 17:31:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xloem",
    "github_project": "pyarweave",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pyarweave"
}
        
Elapsed time: 0.06817s