shdwDrive
  • Your cloud. Your token.
  • Guides
    • Support & FAQ
    • Start Building
    • Phone Settings
  • Build
    • Install shdwDrive
    • CLI
    • SDKs
      • JavaScript
      • Rust
      • Python
      • API
    • S3-Compatible Client Access
    • FAQ
  • Reference
    • Change Logs
    • Social Media & Community
    • Podcasts & Presentations
    • shdwGlossary
Powered by GitBook
On this page
  • Installing ShdwDrive
  • Example - Create Account, File Upload, Add or Reduce Storage, and Delete Account using Python
Export as PDF
  1. Build
  2. SDKs

Python

PreviousRustNextAPI

Last updated 4 months ago

shdwDrive v1.5 is no longer maintained. Please migrate to v2 and consult the new for instructions.

Installing ShdwDrive

pip install shadow-drive

Also for running the examples:

pip install solders

Check out the directory for a demonstration of the functionality.

https://shdw-drive.genesysgo.net/[STORAGE_ACCOUNT_ADDRESS]

Example - Create Account, File Upload, Add or Reduce Storage, and Delete Account using Python

from shadow_drive import ShadowDriveClient
from solders.keypair import Keypair
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--keypair', metavar='keypair', type=str, required=True,
                    help='The keypair file to use (e.g. keypair.json, dev.json)')
args = parser.parse_args()

# Initialize client
client = ShadowDriveClient(args.keypair)
print("Initialized client")

# Create account
size = 2 ** 20
account, tx = client.create_account("full_test", size, use_account=True)
print(f"Created storage account {account}")

# Upload files
files = ["./files/alpha.txt", "./files/not_alpha.txt"]
urls = client.upload_files(files)
print("Uploaded files")

# Add and Reduce Storage
client.add_storage(2**20)
client.reduce_storage(2**20)

# Get file
current_files = client.list_files()
file = client.get_file(current_files[0])
print(f"got file {file}")

# Delete files
client.delete_files(urls)
print("Deleted files")

# Delete account
client.delete_account(account)
print("Closed account")

Methods

Section under development.

About the

This package uses PyO3 to build a wrapper around the official ShdwDrive Rust SDK. For more information, see the .

Github Repo
Rust SDK documentation
developer guide
examples
Install Python SDK
Examples
Github
Methods