CLI
Contents
Introduction
The CLI is the easiest way to interact with shdwDrive. You can use your favorite shell scripting language, or just type the commands one at a time. For test driving shdwDrive, this is the best way to get started.
Install the shdwDrive CLI
Prerequisites: Install NodeJS LTS 16.17.1 on any OS.
Then run the following command
Install the Solana CLI
In order to interact with shdwDrive, we're going to need a Solana wallet and CLI to interact with the Solana blockchain.
NOTE: The shdwDrive CLI uses it's own RPC configuration. It does not use your Solana environment configuration.
Check HERE for the latest version.
Upon install, follow that up immediately with:
Create a Keypair file
We need to have a keypair in .json format to use the shdwDrive CLI. This is going to be the wallet that owns the storage account. If you want, you can convert your browser wallet into a .json file by exporting the private keys. Solflare by default exports it in a .json format (it looks like a standard array of integers, [1,2,3,4...]. Phantom, however, needs some help and we have just the tool to do that.
If you want to create a new wallet, just use
You will see it write a new keypair file and it was display the pubkey
which is your wallet address.
You'll need to send a small amount of SOL and SHDW to that wallet address to proceed! The SOL is used to pay for transaction fees, the SHDW is used to create (and expand) the storage account!
Context-Sensitive Help
shdwDrive CLI comes with integrated help. All shdwDrive commands begin with shdw-drive
.
The above command will yield the following output
You can get further help on each of these commands by typing the full command, followed by the --help
option.
Create a Storage Account
This is one of the few commands where you will need SHDW. Before the command executes, it will prompt you as to how much SHDW will be required to reserve the storage account. There are three required options:
-kp, --keypair
Path to wallet that will create the storage account
-n, --name
What you want your storage account to be named. (Does not have to be unique)
-s, --size
Amount of storage you are requesting to create. This should be in a string like '1KB', '1MB', '1GB'. Only KB, MB, and GB storage delineations are supported.
Example:
Upload File to shdwDrive
Options for this command:
-kp, --keypair
Path to wallet that will upload the file
-f, --file
File path. Current file size limit is 1GB through the CLI.
If you have multiple storage accounts it will present you with a list of owned storage accounts to choose from. You can optionally provide your storage account address with:
-s, --storage-account
Storage account to upload file to.
--rpc <your-RPC-endpoint>
RPC endpoint to pass custom endpoint. This can resolve 410 errors if you are using methods not available from the default free public endpoint.
Example 1:
Example 2 with RPC:
Upload Multiple Files to shdwDrive
A more realistic use case is to upload an entire directory of, say, NFT images and metadata. It's basically the same thing, except we point the command to a directory.
Options:
-kp, --keypair
Path to wallet that will upload the files
-d, --directory
Path to folder of files you want to upload.
-s, --storage-account
Storage account to upload file to.
-c, --concurrent
Number of concurrent batch uploads. (default: "3")
--rpc <your-RPC-endpoint>
RPC endpoint to pass custom endpoint. This can resolve 410 errors if you are using methods not available from the default free public endpoint.
Example 1:
Example 2 with RPC:
Edit a File (aka Overwrite a File aka Replace a File)
This command is used to replace an existing file that has the exact same name. If you attempt to upload this file using edit-file
and an existing file with the same name is not already there, the request will fail.
There are three requirements for this command:
-kp, --keypair
Path to wallet that will upload the file
-f, --file
File path. Current file size limit is 1GB through the CLI. File must be named the same as the one you originally uploaded
-u, --url
ShdwDrive URL of the file you are requesting to delete
Example:
Delete a File
This is straightforward and it's important to note once it's deleted, it's gone for good.
There are two requirements and there aren't any options outside of the standard ones:
-kp, --keypair
Path to the keypair file for the wallet that owns the storage account and file
-u, --url
ShdwDrive URL of the file you are requesting to delete
Example:
Add Storage to Storage Account
You can expand the storage size of a storage account. This command consumes SHDW tokens.
There are only two requirements for this call
-kp, --keypair
Path to wallet that will upload the files
-s, --size
Amount of storage you are requesting to add to your storage account. Should be in a string like '1KB', '1MB', '1GB'. Only KB, MB, and GB storage delineations are supported currently
If you have more than one account, you'll get to pick which storage account you want to add storage to.
Example:
Reduce Storage Account Size
You can reduce your storage account and reclaim your unused SHDW tokens. This is a two part operation where you first reduce your account size, and then request your SHDW tokens. First, let's reduce the storage account size.
There are two requirements
-kp, --keypair
Path to wallet that will upload the files
-s, --size
Amount of storage you are requesting to remove from your storage account. Should be in a string like '1KB', '1MB', '1GB'. Only KB, MB, and GB storage delineations are supported currently
Example:
Claim Stake (aka Claim Unused SHDW Tokens after Reduction)
Since you reduced the amount of storage being used in the previous step, you are now free to claim your unused SHDW tokens. The only requirement here is a keypair.
Example:**
Delete a Storage Account
You can entirely remove a storage account from ShdwDrive. Upon completion, your SHDW tokens will be returned to the wallet.
NOTE: You have a grace period upon deletion that lasts until the end of the current Solana epoch. Go HERE to see how much time is remaining in the current Solana epoch to know how much grace period you will get.
All you need here is a keypair, and it will prompt you for the specific storage account to delete.
Example:
Undelete a Storage Account
Assuming the epoch is still active, you can undelete your storage account. You only need a keypair. You will be prompted to select a storage account when running the command. This removes the deletion request.
Make Storage Account Immutable
One of the most unique and useful features of ShdwDrive is that you can make your storage truly permanent. With immutable storage, no file that was uploaded to the account can ever be deleted or edited. They are solidified and permanent, as is the storage account itself. You can still continue to upload files to an immutable account, as well as add storage to an immutable account.
The only requirement is a keypair. You will be prompted to select a storage account when running the command.
Example:
The Rust CLI
(This section is under development)
CreateStorageAccount
Create an account on which to store data. Storage accounts can be globally, irreversibly marked immutable for a one-time fee. Otherwise, files can be added or deleted from them, and space rented indefinitely.
Parameters:
--name
String
--size
Byte
Example:
DeleteStorageAccount
Queues a storage account for deletion. While the request is still enqueued and not yet carried out, a cancellation can be made (see cancel-delete-storage-account subcommand).
Parameters:
--storage-account
Pubkey
Example:
Example:
CancelDeleteStorageAccount
Cancels the deletion of a storage account enqueued for deletion.
Parameters:
--storage-account
Pubkey
Example:
Example:
ClaimStake
Redeem tokens afforded to a storage account after reducing storage capacity.
Parameters:
--storage-account
Pubkey
Example:
Example:
AddStorage
Increase the capacity of a storage account.
Parameters:
--storage-account
Pubkey
--size
Byte (accepts KB, MB, GB)
Example:
Example:
AddImmutableStorage
Increase the immutable storage capacity of a storage account.
Parameters:
--storage-account
Pubkey
--size
Byte (accepts KB, MB, GB)
Example:
Example:
ReduceStorage
Reduce the capacity of a storage account.
Parameters:
--storage-account
Pubkey
--size
Byte (accepts KB, MB, GB)
Example:
Example:
MakeStorageImmutable
Make a storage account immutable. This is irreversible.
Parameters:
--storage-account
Pubkey
Example:
Example:
GetStorageAccount
Fetch the metadata pertaining to a storage account.
Parameters:
--storage-account
Pubkey
Example:
Example:
GetStorageAccounts
Fetch a list of storage accounts owned by a particular pubkey. If no owner is provided, the configured signer is used.
Parameters:
--owner
Option<Pubkey>
Example:
Example:
ListFiles
List all the files in a storage account.
Parameters:
--storage-account
Pubkey
Example:
Example:
GetText
Get a file, assume it's text, and print it.
Parameters:
--storage-account
Pubkey
--filename
Example:
Example:
GetObjectData
Get basic file object data from a storage account file.
Parameters:
--storage-account
Pubkey
--file
String
Example:
Example:
DeleteFile
Delete a file from a storage account.
Parameters:
--storage-account
Pubkey
--filename
String
Example:
Example:
EditFile
Edit a file in a storage account.
Parameters:
--storage-account
Pubkey
--path
PathBuf
Example:
Example:
StoreFiles
Upload one or more files to a storage account.
Parameters:
--batch-size
usize (default: value of FILE_UPLOAD_BATCH_SIZE)
--storage-account
Pubkey
--files
Vec<PathBuf>
Example:
Example:
Last updated