Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rohitverma007/stackspy
Python Library to interact with the Stacks blockchain
https://github.com/rohitverma007/stackspy
Last synced: 3 months ago
JSON representation
Python Library to interact with the Stacks blockchain
- Host: GitHub
- URL: https://github.com/rohitverma007/stackspy
- Owner: rohitverma007
- Created: 2023-05-15T07:43:46.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-06T20:00:47.000Z (over 1 year ago)
- Last Synced: 2024-08-03T02:05:48.572Z (6 months ago)
- Language: Python
- Size: 64.5 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# stackspy
Python Library to interact with the Stacks blockchain
Example code to sign messages:
```
message = "Hello Stacks From Python"
encoded_message = encryption.encode_message(message)# now hash it
hash_object = hashlib.sha256(encoded_message)
hex_dig = hash_object.hexdigest()
print(hex_dig) # df0e4af616093dfbe3dcae834b0482c6f59f5845a1085165c7dc069dbf7a8ab6key = 'edf9aee84d9b7abc145504dde6726c64f369d37ee34ded868fabd876c26570bc'
signature_data = encryption.sign_message_hash_rsv(hex_dig, key)
print(signature_data)
```Example code for transactions:
```
from network import StacksTestnet
from transactions import make_stx_token_transfer, broadcast_transaction
network = StacksTestnet()
tx_options = {
"recipient": 'ST319CF5WV77KYR1H3GT0GZ7B8Q4AQPY42ETP1VPF',
"sender_key": "b244296d5907de9864c0b0d51f98a13c52890be0404e83f273144cd5b9960eed01",
"network": network,
"memo": "hello from python",
"amount": 10000000 #amount is in micro-STX
}transaction = make_stx_token_transfer(tx_options)
print(transaction.serialize().hex())
broadcast_result = broadcast_transaction(transaction, 'testnet')
print(broadcast_result.json())
```