gems is a command-line tool written in Rust to interact with the Autonomi network. It allows you to:
- Upload files.
- Optionally verify uploads by downloading the data immediately.
- Optionally create a
PublicArchiveautomatically after upload. - Create a
PublicArchivefor a file already on the network using itsDataAddress. - Download single files using their
DataAddress. - Download all files referenced within a
PublicArchiveusing itsArchiveAddress.
- Rust Toolchain: Ensure you have Rust and Cargo installed. If not, follow the instructions at rustup.rs. Cargo is included with Rust.
- Git: Needed to clone the repository.
- ETH Wallet: You need an ETH wallet private key with sufficient funds ANT & ETH on the Arbitrum Network to pay for uploads and archive creation.
-
Clone the Repository:
git clone git@github.com:josh-clsn/gems.git cd gems -
Create
.envfile: In the root directory of the project (whereCargo.tomlis), create a file named.env. -
Add Private Key: Add your ETH private key (in hex format, usually without the
0xprefix) to the.envfile:AUTONOMI_PRIVATE_KEY=<your_actual_private_key_hex>
-
Install using Cargo: This compiles the tool and places the
gemsexecutable in your Cargo binary path (~/.cargo/bin/by default), making it available as a command.cargo install --path .Ensure that
~/.cargo/binis in your system'sPATHenvironment variable. If you just installed Rust, you might need to restart your terminal or runsource ~/.cargo/env.
Once installed, you can run the tool using the gems command followed by a subcommand (upload, archive, or download).
This command uploads a local file to the network.
gems upload --file-path <path/to/your/local/file>
# Example:
gems upload -f ./my_document.pdfWorkflow:
- The tool reads the local file.
- It asks you upfront if you want to download and verify the data after the upload completes successfully.
- It asks you upfront if you want to create a new archive for the data after the upload completes successfully.
- The tool then attempts the upload, retrying up to 50 times if it fails. You can leave the process running.
- If the upload is successful, it prints the
Data Address. - Based on your earlier answers:
- If you requested verification, it proceeds to download and verify the data.
- If you requested archiving, it proceeds to create and upload the
PublicArchivestructure, printing theArchive Address.
Optional Output Directory for Verification:
You can specify where the verified file should be saved (if verification is performed) using -o or --output-dir (defaults to the current directory).
gems upload -f ./image.jpg -o ./verified_downloads
# (It will still ask the verify/archive questions before uploading)Use this command if you have already uploaded a file (and know its Data Address) and want to create a separate PublicArchive record for it.
gems archive <data_address_hex> [OPTIONS]
# Example using the DataAddress from a previous upload:
gems archive 7ca61972d90c00d5e2ec085c24a6c09d11eb602c27637490ec6fc9b7f7cc7351<data_address_hex>: The hex string of theData Addressfor the content you want to archive.
Optional Path in Archive:
You can specify the name/path this file should have within the archive using -p or --archive-path. This can be just a filename (like my_video.mp4) or include directories (like movies/my_video.mp4).
# Archive with just a filename:
gems archive 7ca6... --archive-path my_important_video.mp4
# Archive with a relative path:
gems archive 7ca6... --archive-path "movies/action/my_video.mp4"
# If not specified, it defaults to "archived_file"- This command creates and uploads a new
PublicArchivecontaining just this one entry and prints theArchive Addressof the new archive.
This command can download either a single file (using its DataAddress) or all files within an archive (using the archive's ArchiveAddress).
A) Download a Single File:
Provide the DataAddress and the desired local output file path.
gems download <data_address_hex> --output-path <local/save/path/file.ext>
# Example:
gems download 7ca6... -o ./downloaded_drama.mp4<data_address_hex>: The hex string of theData Addressof the file content.--output-path(-o): The full path where the downloaded file should be saved.
B) Download Archive Contents:
Provide the ArchiveAddress and an output directory. Add the --archive flag.
gems download <archive_address_hex> --output-path <local/save/directory> --archive
# Example:
gems download <archive_address_hex> -o ./my_downloaded_archive --archive<archive_address_hex>: The hex string of theArchive Addressitself.--output-path(-o): The directory where the archive contents should be saved. Any directory structure specified in the archive's paths (seearchivecommand above) will be recreated within this output directory.--archive: This flag tells the command to treat the address as an archive and download its contents.