Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/MikeHibbert/arweave-python-client

This client allows you to integrate your python apps with the Arweave network allowing you to perform wallet operations and transactions
https://github.com/MikeHibbert/arweave-python-client

arweave cryptocurrency python transaction wallet

Last synced: about 2 months ago
JSON representation

This client allows you to integrate your python apps with the Arweave network allowing you to perform wallet operations and transactions

Awesome Lists containing this project

README

        

# arweave-python-client
This client allows you to integrate your python apps with the Arweave network allowing you to got wallet operations and transactions

## Installing
To use the library simply install it:
```buildoutcfg
pip install arweave-python-client
```

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

wallet_file_path = "/some/folder/on/your/system"
wallet = arweave.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:
```buildoutcfg
import arweave

wallet_data = // Load from cloud storage or wherever
wallet = arweave.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:
```buildoutcfg
import arweave

wallet_file_path = "/some/folder/on/your/system"
wallet = arweave.Wallet(wallet_file_path)

transaction = arweave.Transaction(wallet, quantity=0.3, to=')
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:
```buildoutcfg
from arweave.arweave_lib import arql

wallet_file_path = "/some/folder/on/your/system"
wallet = arweave.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
```buildoutcfg
import arweave

wallet_file_path = "/some/folder/on/your/system"
wallet = arweave.Wallet(wallet_file_path)

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