Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/patara43/crust-interface-patara
A simple tool to interact with Crust Shadow and Crust Mainnet. Under development
https://github.com/patara43/crust-interface-patara
crust ipfs python substrate web3
Last synced: 18 days ago
JSON representation
A simple tool to interact with Crust Shadow and Crust Mainnet. Under development
- Host: GitHub
- URL: https://github.com/patara43/crust-interface-patara
- Owner: PaTara43
- License: apache-2.0
- Created: 2022-07-23T01:38:31.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-04T17:29:11.000Z (10 months ago)
- Last Synced: 2024-11-30T23:41:36.393Z (about 2 months ago)
- Topics: crust, ipfs, python, substrate, web3
- Language: Python
- Homepage:
- Size: 40 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# crust-file-uploader
https://crust.network/
https://apps.crust.network/
https://wiki.crust.network/en
https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc-shadow.crust.network%2F#/explorerThis is a simple tool to pin your files sing Crust Network or Crust Shadow.
## Setup
### Installation:
```bash
pip3 install crust-interface-patara
```## Features
The module is divided into `Mainnet` and `Shadow`
`Mainnet` provides Crust interaction functionality to check user balance, calculate file storage price, placing
file storage order, add tokens to renewal pool and checking replicas count.```python
import time
from crustinterface import Mainnet
from substrateinterface import KeypairTypeseed = "seed"
mainnet = Mainnet(seed=seed, crypto_type=KeypairType.SR25519)# get any IPFS CID and size
cid, size = "QmbJtyu82TQSHU52AzRMXBENZGQKYqPsmao9dPuTeorPui", 18 ## Check balance
balance = mainnet.get_balance()
print(balance)# Check price in Main net. Price in pCRUs
price = mainnet.get_appx_store_price(int(size))
print(price)# Store file in Mainnet for CRUs
file_stored = mainnet.store_file(cid, size)
print(file_stored)# Add renewal pool
file_prepaid = mainnet.add_renewal_pool_balance(cid, price*2)
print(file_prepaid)# Get replicas
time.sleep(10)
replicas = mainnet.get_replicas(cid)
print(replicas)```
`Shadow` allows you to perform `Xstorage` extrinsic in Crust Shadow network.
```python
from crustinterface import Shadow
from substrateinterface import KeypairTypeseed = "seed"
shadow = Shadow(seed=seed, crypto_type=KeypairType.SR25519)# get any IPFS CID and size
cid, size = "QmbJtyu82TQSHU52AzRMXBENZGQKYqPsmao9dPuTeorPui", 18 #print(cid, size)
# Check balance
balance = shadow.get_balance()
print(balance)# Store file in Shadow for CSMs
file_stored = shadow.store_file(cid, size)
print(file_stored)
````Parachain` allows you to perform `Xstorage` extrinsic in Crust Polkadot Parachain network.
```python
from crustinterface import Parachain
from substrateinterface import KeypairTypeseed = "seed"
parachain = Parachain(seed=seed, crypto_type=KeypairType.SR25519)# get any IPFS CID and size
cid, size = "QmbJtyu82TQSHU52AzRMXBENZGQKYqPsmao9dPuTeorPui", 18 #print(cid, size)
# Check balance
balance = parachain.get_balance()
print(balance)# Store file in Shadow for CSMs
file_stored = parachain.store_file(cid, size)
print(file_stored)
```