CLI
Last updated
Last updated
shdwDrive v1.5 is no longer maintained. Please migrate to v2 and consult the new for instructions.
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.
Then run the following command
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.
Upon install, follow that up immediately with:
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!
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.
-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:
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:
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:
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:
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:
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:
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:
Example:**
All you need here is a keypair, and it will prompt you for the specific storage account to delete.
Example:
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.
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:
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:
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:
Cancels the deletion of a storage account enqueued for deletion.
Parameters:
--storage-account
Pubkey
Example:
Example:
Redeem tokens afforded to a storage account after reducing storage capacity.
Parameters:
--storage-account
Pubkey
Example:
Example:
Increase the capacity of a storage account.
Parameters:
--storage-account
Pubkey
--size
Byte (accepts KB, MB, GB)
Example:
Example:
Increase the immutable storage capacity of a storage account.
Parameters:
--storage-account
Pubkey
--size
Byte (accepts KB, MB, GB)
Example:
Example:
Reduce the capacity of a storage account.
Parameters:
--storage-account
Pubkey
--size
Byte (accepts KB, MB, GB)
Example:
Example:
Make a storage account immutable. This is irreversible.
Parameters:
--storage-account
Pubkey
Example:
Example:
Fetch the metadata pertaining to a storage account.
Parameters:
--storage-account
Pubkey
Example:
Example:
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:
List all the files in a storage account.
Parameters:
--storage-account
Pubkey
Example:
Example:
Get a file, assume it's text, and print it.
Parameters:
--storage-account
Pubkey
--filename
Example:
Example:
Get basic file object data from a storage account file.
Parameters:
--storage-account
Pubkey
--file
String
Example:
Example:
Delete a file from a storage account.
Parameters:
--storage-account
Pubkey
--filename
String
Example:
Example:
Edit a file in a storage account.
Parameters:
--storage-account
Pubkey
--path
PathBuf
Example:
Example:
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:
Prerequisites: Install on any OS.
Check .
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 .
This is one of the few commands where you will need . Before the command executes, it will prompt you as to how much will be required to reserve the storage account. There are three required options:
Since you reduced the amount of storage being used in the previous step, you are now free to claim your unused tokens. The only requirement here is a keypair.
You can entirely remove a storage account from ShdwDrive. Upon completion, your 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. how much time is remaining in the current Solana epoch to know how much grace period you will get.