zbox - a CLI for Züs dStorage
zbox is a command line interface (CLI) tool to understand the capabilities of Züs dStorage and prototype your app. The utility is built using Züs GoSDK. For more information on Züs Network and the system overview, refer to docs.zus.network.

Getting started
1. Installation
Prerequisites
- Go: Installation instructions for Mac, Linux and Windows can be found here.
Procedures
- Clone the
zboxcli repo and install
git clone https://github.com/0chain/zboxcli.git
cd zboxcli
make install
- Add config yaml at
~/.zcn/config.yaml
The following script sets https://demo.zus.network as your network.
cat > ~/.zcn/config.yaml << EOF
block_worker: https://mainnet.zus.network/dns
signature_scheme: bls0chain
min_submit: 50 # in percentage
min_confirmation: 50 # in percentage
confirmation_chain_length: 3
EOF
- Run
zboxcli to display the list of supported commands.
./zbox
For machine requirements and pre-requisites, follow the guides below:
2. Run zbox commands
The following steps assume that your terminal’s working directory is inside the zboxcli repo.
Running zbox
When you run the ./zbox command in terminal with no arguments, it will list all the available commands and the global flags. For working of specific command check commands section.
Usage:
zbox [command]
Available Commands:
alloc-cancel Cancel an allocation
alloc-fini Finalize an expired allocation
bl-info Get blobber info
bl-update Update blobber settings by its delegate_wallet owner
collect-reward Collect accrued rewards for a stake pool.
completion Generate the autocompletion script for the specified shell
copy copy an object(file/folder) to another folder on blobbers
cp-info Challenge pool information.
createdir Create directory
decrypt Decrypt text with passphrase
delete delete file from blobbers
download download file from blobbers
feed download segment files from remote live feed, and upload
get-download-cost Get downloading cost
get-upload-cost Get uploading cost
getallocation Gets the allocation info
getwallet Get wallet information
help Help about any command
kill-blobber punitively deactivate a blobber
kill-validator punitively deactivate a validator
list list files from blobbers
list-all list all files from blobbers
listallocations List allocations for the client
ls-blobbers Show active blobbers in storage SC.
ls-validators Show active Validators.
meta get meta data of files from blobbers
move move an object(file/folder) to another folder on blobbers
newallocation Creates a new allocation
rename rename an object(file/folder) on blobbers
rp-create Create read pool if missing
rp-info Read pool information.
rp-lock Lock some tokens in read pool.
rp-unlock Unlock some expired tokens in a read pool.
sc-config Show storage SC configuration.
share share files from blobbers
shutdown-blobber deactivate a blobber
shutdown-validator deactivate a validator
sign-data Sign given data
sp-info Stake pool information.
sp-lock Lock tokens lacking in stake pool.
sp-unlock Unlock tokens in stake pool.
sp-user-info Stake pool information for a user.
start-repair start repair file to blobbers
stats stats for file from blobbers
sync Sync files to/from blobbers
transferallocation Transfer an allocation from one account to another
update update file to blobbers
updateallocation Updates allocation's expiry and size
upload upload file to blobbers
validator-info Get validator info
validator-update Update validator settings by its delegate_wallet owner
version Prints version information
wp-lock Lock some tokens in write pool.
wp-unlock Unlock some expired tokens in a write pool.
Flags:
--config string config file (default is config.yaml)
--configDir string configuration directory (default is $HOME/.zcn)
--fee float transaction fee for the given transaction (if unset, it will be set to blockchain min fee)
-h, --help help for zbox
--network string network file to overwrite the network details (if required, default is network.yaml)
--silent (default false) Do not show interactive sdk logs (shown by default)
--wallet string wallet file (default is wallet.json)
--wallet_client_id string wallet client_id
--wallet_client_key string wallet client_key
--withNonce int nonce that will be used in transaction (default is 0)
Use "zbox [command] --help" for more information about a command.
Global Flags
Global Flags are parameters in zbox that can be used with any command to override the default configuration.zbox supports the following global parameters.
| Flags |
Description |
Usage |
| –config string |
Specify a zbox configuration file (default is $HOME/.zcn/config.yaml) |
zbox [command] --config config1.yaml |
| –configDir string |
Specify a zbox configuration directory (default is $HOME/.zcn) |
zbox [command] --configDir /$HOME/.zcn2 |
| -h, --help |
Gives more information about a particular command. |
zbox [command] --help |
| –network string |
Specify a network file to overwrite the network details(default is $HOME/.zcn/network.yaml) |
zbox [command] --network network1.yaml |
| –verbose |
Provides additional details as to what the particular command is doing. |
zbox [command] --verbose |
| –wallet string |
Specify a wallet file or 2nd wallet (default is $HOME/.zcn/wallet.json) |
zbox [command] --wallet wallet2.json |
| –wallet_client_id string |
Specify a wallet client id (By default client_id specified in $HOME/.zcn/wallet.json is used) |
zbox [command] --wallet_client_id <client_id> |
| –wallet_client_key string |
Specify a wallet client_key (By default client_key specified in $HOME/.zcn/wallet.json is used) |
zbox [command] --wallet_client_key < client_key> |
Commands
Note in this document, we will only show the commands for particular functionalities,
the response will vary depending on your usage and may not be provided in all places.
To get a more descriptive view of all the zbox functionalities check zbox cli
documentation at docs.0chain.net.
Creating and Managing Allocations
Create new allocation
Command newallocation reserves hard disk space on the blobbers. Later upload
can be used to save files to the blobber. newallocation has three modes triggered
by the presence or absence of the cost
and free_storage parameters.
cost Converts newallocation into a query that returns the cost of the allocation
determined by the remaining parameters.
free_storage Creates an allocation using a free storage marker. All other
parameters except cost will be ignored. The allocation settings will be set
automatically by 0chain, from preconfigured values.
otherwise Creates an allocation applying the settings indicated by the
remaining parameters.
- Use
owner if you want to create and fund an allocation for someone else. If
using this option then you need to provide the new owner’s public key. Otherwise,
the owner defaults to the client.
| Parameter |
Description |
Default |
Valid Values |
| allocationFileName |
local file to store allocation information |
allocation.txt |
file path |
| cost |
returns the cost of the allocation, no allocation created |
|
flag |
| data |
number of data shards, effects upload and download speeds |
2 |
int |
| free_storage |
free storage marker file. |
|
file path to json marker file |
| owner |
owner’s id, use for funding an allocation for another |
|
string |
| owner_public_key |
public key, use for funding an allocation for another |
|
string |
| lock* |
lock write pool with given number of tokens |
|
float |
| parity |
number of parity shards, effects availability (has to be more than 1 and less than the number of available blobbers on the chain (upper capped to 30)) |
2 |
int |
| read_price |
filter blobbers by read price range |
0-inf |
range |
| size |
size of space reserved on blobbers |
2147483648 |
bytes |
| usd |
give token value in USD |
|
flag |
| write_price |
filter blobbers by write price range |
0-inf |
range |
| third_party_extendable |
specify if the allocation can be extended by users other than the owner |
false |
bool |
| forbid_upload |
specify if users cannot upload to this allocation |
false |
bool |
| forbid_delete |
specify if the users cannot delete objects from this allocation |
false |
bool |
| forbid_update |
specify if the users cannot update objects in this allocation |
false |
bool |
| forbid_move |
specify if the users cannot move objects from this allocation |
false |
bool |
| forbid_copy |
specify if the users cannot copy object from this allocation |
false |
bool |
| forbid_rename |
specify if the users cannot rename objects in this allocation |
false |
bool |
| blobber_auth_tickets |
comma separated list of blobber auth tickets |
|
comma separated list of strings |
| force |
force to get blobbers even if required number of blobbers are not available (should be passed true in case of restricted blobbers) |
false |
bool |
| name |
allocation name |
|
string |
| preferred_blobbers |
comma separated list of preferred blobber ids |
|
comma separated list of strings |
* - only required if free_storage not set. |
|
|
|
newallocation


Free storage newallocation

Free storage allocation
Entities can give free 0chain storage in the form of markers. A marker takes the
form of a json file
{
"assigner": "my_corporation",
"recipient": "f174cdda7e24aeac0288afc2e8d8b20eda06b18333efd447725581dc80552977",
"free_tokens": 2.1,
"timestamp": 2000000,
"signature": "9edb86c8710d5e3ee4fde247c638fd6b81af67e7bb3f9d60700aec8e310c1f06"
}
assigner A label for the entity providing the free storage.
recipient The marker has to be run by the recipient to be valid.
free_tokens The amount of free tokens. When creating a new allocation the
free tokens will be split between the allocation’s write pool,
and a new read pool; the ratio of this split configured on the blockchain.
timestamp A unique timestamp. Used to prevent multiple applications of the same marker.
signature Signed by the assigner, validated using the stored public key on the blockchain.
All allocation settings, other than lock, will be set automatically by 0chain.
Once created, an allocation funded by a free storage marker becomes identical to
any other allocation; Its history forgotten.
Allocation created : d0939e912851959637257573b08c748474f0dd0ebbc8e191e4f6ad69e4fdc7ac
Example
To create a new allocation with default values,use newallocation with a --lock flag to add
some tokens to the write pool .On success a related write pool is created and the allocation
information is stored under $HOME/.zcn/allocation.txt.
./zbox newallocation --lock 0.5
To use a free storage marker, you only need to provide the path to the marker file.
./zbox newallocation --lock 0.5 --free_storage markers/my_marker.json
Response:
Allocation created : d0939e912851959637257573b08c748474f0dd0ebbc8e191e4f6ad69e4fdc7ac
Update allocation
updateallocation updates allocation settings. It has two modes depending on
the presence of the free_storage field.
free_storage Uses a free storage marker to fund this allocation update; settings
predefined by 0chain. See newallocation for further details.
otherwise Update an allocation applying the settings indicated by the
remaining parameters.
If not a free_storage update, then tokens will come from those locked.
Further we can add a blobber to the allocation,
adding a blobber will allow a blobber to be removed.
An increase in blobber count will increment the parity shards.
| Parameter | Required | Description | Default| Valid Values |
| -------------- | -------- | -------------------------------------------------------------------- | | ------------ |
| allocation | yes | allocation id | | string |
| name | | allocation name | | string |
| extend | | adjust storage expiration time | | duration |
| free_storage | | free storage marker file | | string |
| lock | yes* | lock additional tokens in write pool | | int |
| size | | adjust allocation size | | bytes |
| add_blobber | | add a new blobber to the allocation, required for remove_blobber | | string |
| add_blobber_auth_ticket | | Auth ticket of blobber to add to the allocation | | string |
| remove_blobber | | remove a blobber from the allocation, requires an add_blobber option | | string |
| third_party_extendable | | specify if the allocation can be extended by users other than the owner | false | bool
| forbid_upload | |specify if users cannot upload to this allocation | false | bool
| forbid_delete | |specify if the users cannot delete objects from this allocation | false | bool
| forbid_update | |specify if the users cannot update objects in this allocation | false | bool
| forbid_move | |specify if the users cannot move objects from this allocation | false | bool
| forbid_copy | |specify if the users cannot copy object from this allocation | false | bool
| forbid_rename | |specify if the users cannot rename objects in this allocation | false | bool
* only required if free_storage not set.
updateallocation

Free storage updateallocation

./zbox updateallocation --allocation d0939e912851959637257573b08c748474f0dd0ebbc8e191e4f6ad69e4fdc7ac --expiry 48h --size 4096
./zbox updateallocation --allocation d0939e912851959637257573b08c748474f0dd0ebbc8e191e4f6ad69e4fdc7ac --free_storage "markers/my_marker.json"
Output:
Allocation updated with txId : fb84185dae620bbba8386286726f1efcd20d2516bcf1a448215434d87be3b30d
Transfer allocation ownership
transferallocation transfers an allocation from one account to another.
This operation needs to be run by the current owner of the allocation.
| Parameter |
Required |
Description |
Valid Values |
| allocation |
yes |
allocation id |
string |
| new_owner |
yes |
new owner id |
string |
| new_owner_key |
yes |
new owner public key |
string |
./zbox transferallocation --allocation d0939e912851959637257573b08c748474f0dd0ebbc8e191e4f6ad69e4fdc7ac --new_owner e61b1d5f081c4dfa4d45c852ca8abbfcdc3023ed4ffe2402ba7e9b2ebc56b129 --new_owner_key 421d9f68e121884a02587c1d5aad0ca81a4df2358abe1acb0952efdd5a6afc0ed198ec897a848890bd36a74f3dfd178a1ed9dcd2fab969b6ed073f98d795759d
Output:
transferred ownership of allocation : d0939e912851959637257573b08c748474f0dd0ebbc8e191e4f6ad69e4fdc7ac to e61b1d5f081c4dfa4d45c852ca8abbfcdc3023ed4ffe2402ba7e9b2ebc56b129
Forbid Allocation
There are various operations which you can forbid on an allocation. Forbid flag works with update allocation command. Check its working first.
Here are the operations:
| Parameter |
Description |
| –forbid_copy |
specify if the users cannot copy object from this allocation |
| –forbid_update |
specify if the users cannot update objects in this allocation |
| –forbid_delete |
specify if the users cannot delete objects from this allocation |
| –forbid_move |
specify if the users cannot move objects from this allocation |
| –forbid_rename |
specify if the users cannot rename objects in this allocation |
| –forbid_upload |
specify if users cannot upload to this allocation |
Here is a sample command for --forbid_upload .Other parameters can be done the same way.
./zbox updateallocation --allocation $ALLOC --forbid_upload
Sample Response :
Allocation Updated with txID : b84185dae620bbba8386286726f1efcd20d2516bcf1a448215434d87be3b30d
To test functionality try uploading file to allocation. You should get the following response :
Upload failed. this options for this file is not permitted for this allocation:
file_option_not_permitted.
Cancel allocation
alloc-cancel immediately return all remaining tokens from challenge pool back to the
allocation’s owner and cancels the allocation. If blobbers already got some tokens,
the tokens will not be returned. Remaining min lock payment to the blobber will be
funded from the allocation’s write pools.
Cancelling an allocation can only occur if the amount of failed challenges exceed a preset threshold.
| Parameter |
Required |
Description |
Valid Values |
| allocation |
yes |
allocation id |
string |
alloc-cancel

Example
./zbox alloc-cancel --allocation <allocation_id>
Sample Response :
Allocation canceled with txId : 501df5a8e2a6b8ebced1d1e7dc4ed17f653012dd49834801b4413786ec031cd2
Finalise allocation
alloc-fini finalises an expired allocation. An allocation becomes expired when
the expiry time has passed followed by a period equal to the challenge completion
period.
Any remaining min lock payment to the blobber will be funded from the
allocation’s write pools. Any available money in the challenge pool returns to
the allocation’s owner.
An allocation can be finalised by the owner or one of the allocation blobbers.
| Parameter |
Required |
Description |
Valid Values |
| allocation |
yes |
allocation id |
string |
alloc-fini

Example
./zbox alloc-fini --allocation <allocation_id>
Sample Response:
Allocation finalized with txId : 2a6c031ced1d1e7dc4ed17801b4413786ecd2501df5ab8ebf653012dd498348e
List blobbers
Use ls-blobbers command to show active blobbers.
| Parameter |
Required |
Description |
Valid Values |
| all |
no |
shows active and non active blobbers |
bool |
| json |
no |
display result in .json format |
bool |
| stakable |
no |
gets only stakable list of blobbers if set to true |
bool |
ls-blobbers

Example
./zbox ls-blobbers
- id: 0ece681f6b00221c5567865b56040eaab23795a843ed629ce71fb340a5566ba3
url: http://demo.zus.network:31302
used / total capacity: 101.7 GiB / 1000.0 GiB
terms:
read_price: 0.01 tok / GB
write_price: 0.01 tok / GB / time_unit
min_lock_demand: 0.1
max_offer_duration: 744h0m0s
- id: 788b1deced159f12d3810c61b4b8d381e80188c470e9798939f2e5036d964ffc
url: http://demo.zus.network:31301
used / total capacity: 102.7 GiB / 1000.0 GiB
terms:
read_price: 0.01 tok / GB
write_price: 0.01 tok / GB / time_unit
min_lock_demand: 0.1
max_offer_duration: 744h0m0s
Use bl-info command to get detailed blobber information.
| Parameter |
Required |
Description |
default |
Valid values |
| blobber_id |
yes |
blobber on which to get information |
|
string |
| json |
no |
print result in json format |
false |
boolean |
bl-info

Example
./zbox bl-info --blobber_id f65af5d64000c7cd2883f4910eb69086f9d6e6635c744e62afcfab58b938ee25
Response:
id: f65af5d64000c7cd2883f4910eb69086f9d6e6635c744e62afcfab58b938ee25
url: http://localhost:5051
capacity: 1.0 GiB
last_health_check: 2021-04-08 22:54:50 +0700 +07
capacity_used: 0 B
terms:
read_price: 0.01 tok / GB
write_price: 0.1 tok / GB
min_lock_demand: 10 %
max_offer_duration: 744h0m0s
settings:
delegate_wallet: 8b87739cd6c966c150a8a6e7b327435d4a581d9d9cc1d86a88c8a13ae1ad7a96
min_stake: 1 tok
max_stake: 100 tok
num_delegates: 50
service_charge: 30 %
List all files
list-all lists all the files stored with an allocation
| Parameter |
Required |
Description |
Default |
Valid values |
| allocation |
yes |
allocation id, sender must be allocation owner |
|
string |
Sample Request :
./zbox list-all --allocation 4ebeb69feeaeb3cd308570321981d61beea55db65cbeba4ba3b75c173c0f141b
Sample Response :
[{"size":0,"mimetype":"","actual_size":0,"hash":"","type":"d","encrypted_key":"","lookup_hash":"55e45925760e33f113642569a539e17a531285d2bf53dc78fde954017c8b27b3","created_at":1714335152,"updated_at":1714335152,"name":"abcd","path":"/abcd"}]
List owner’s allocations
listallocations provides a list of all allocations owned by the user.
| Parameter |
Required |
Description |
default |
Valid values |
| json |
no |
print output in json format |
|
boolean |
listallocations

./zbox listallocations
ZED | CANCELED | R PRICE | W PRICE
+------------------------------------------------------------------+-----------+-------------------------------+------------+--------------+-----------+----------+----------+--------------+
4ebeb69feeaeb3cd308570321981d61beea55db65cbeba4ba3b75c173c0f141b | 104857600 | 2021-07-16 13:34:29 +0100 BST | 1 | 1 | false | false | 0.02 | 0.1999999998
Update blobber settings
Use ./zbox bl-update to update a blobber’s configuration settings. This updates the settings
on the blockchain not the blobber.
| Parameter |
Required |
Description |
default |
Valid values |
| blobber_id |
yes |
id of blobber of which to update settings |
|
string |
| capacity |
no |
update blobber capacity |
|
int |
| max_offer_duration |
no |
update max offer duration |
|
duration |
| max_stake |
no |
update maximum stake |
|
float |
| min_lock_demand |
no |
update minimum lock demand |
|
float |
| min_stake |
no |
update minimum stake |
|
float |
| num_delegates |
no |
update maximum number of delegates |
|
int |
| read_price |
no |
update read price |
|
float |
| service_charge |
no |
update service charge |
|
float |
| write_price |
no |
update write price |
|
float |
| url |
no |
update the url of the blobber |
|
string |
| is_restricted |
no |
update whether blobber is restricted |
false |
bool |
| not_available |
no |
set blobber’s availability for new allocations |
false |
bool |
bl-update

Example
Update blobber read price
./zbox bl-update --blobber_id 0ece681f6b00221c5567865b56040eaab23795a843ed629ce71fb340a5566ba3 --read_price 0.1
Response :
blobber settings updated successfully
Update validator settings
Use ./zbox validator-update to update a validator’s configuration settings. This updates the settings
on the blockchain not the validator.
| Parameter |
Required |
Description |
default |
Valid values |
| validator_id |
yes |
id of validator of which to update settings |
|
string |
| max_stake |
no |
update maximum stake |
|
float |
| min_stake |
no |
update minimum stake |
|
float |
| num_delegates |
no |
update maximum number of delegates |
|
int |
| service_charge |
no |
update service charge |
|
float |
Example
Update validator service charge
./zbox validator-update --validator_id 0ece681f6b00221c5567865b56040eaab23795a843ed629ce71fb340a5566ba3 --service_charge 0.1
Get Version
The version of Zbox and Gosdk can be fetched using the ./zbox version command.
./zbox version
Sample Response:
zbox....: v1.4.3
gosdk...: v1.8.14
List All Validators
List all active validators on the network
Command:
./zbox ls-validators
| Parameter |
Required |
Description |
| –stakable |
no |
Gets only validators that can be staked if set to true |
| –json |
no |
Print Response as json data |
Response :
id: b9f4f244e2e483548795e42dad0c5b5bb8f5c25d70cadeafc202ce6011b7ff8c
url: https://demo.zus.network/validator03/
settings:
delegate_wallet: 9c693cb14f29917968d6e8c909ebbea3425b4c1bc64b6732cadc2a1869f49be9
min_stake: 1.000 ZCN
max_stake: 100.000 ZCN
num_delegates: 50
service_charge: 30 %
id: c025fad27d3daa6fbe6a10ef38f1075dc5a6386760951816ece953391ff9804b
url: https://demo.zus.network/validator02/
settings:
delegate_wallet: 9c693cb14f29917968d6e8c909ebbea3425b4c1bc64b6732cadc2a1869f49be9
min_stake: 1.000 ZCN
max_stake: 100.000 ZCN
num_delegates: 50
service_charge: 30 %
Get Validator Configuration
./zbox validator-info command is used to get a particular validator configuration . Here are the parameters for the command .
| Parameter |
Required |
Description |
| –validator_id |
yes |
id of validator whose configuration has to be fetched |
| –json |
optional |
Print Response as json data |
Sample Command :
./zbox validator-info --validator_id f82ab34a98406b8757f11513361752bab9cb679a5cb130b81
Sample Response :
id: f82ab34a98406b8757f11513361752bab9cb679a5cb130b81a4e86cec50eefc3
url: https://demo2.zus.network/validator01
last_health_check: 2023-05-12 20:09:15 +0530 IST
is killed: false
is shut down: false
settings:
delegate_wallet: 9c693cb14f29917968d6e8c909ebbea3425b4c1bc64b6732cadc2a1869f49be9
min_stake: 0 SAS
max_stake: 0 SAS
total_stake: 200000000000
total_unstake: 0
num_delegates: 50
service_charge: 10 %
Shutdown Blobber
./zbox shutdown-blobber command deactivates a blobber to avoid storage of data . Required parameters are :
| Parameter |
Required |
Description |
| –id |
yes |
Blobber Id to kill a specific blobber.Can be retrieved using List blobbers. |
| –fee |
no |
Custom fee for transaction |
Sample Command :
./zbox shutdown-blobber --id $BLOBBER_ID --wallet $CHAIN_OWNER_WALLET
Note : Shutdown Blobber command should be invoked from chain owner wallet only
Sample Response :
shutdown blobber $BLOBBER_ID with txId : 2a6c031ced1d1e7dc4ed17801b4413786ecd2501df5ab8ebf653012dd498348e
Shutdown Validator
./zbox shutdown-validator command deactivates a validator. Required parameters are :
| Parameter |
Required |
Description |
| –id |
yes |
Validator Id to kill a specific validator.Can be retrieved using List all Validators. |
| –fee |
no |
Custom fee for transaction |
Sample Command :
./zbox shutdown-validator --id $VALIDATOR_ID --wallet $CHAIN_OWNER_WALLET
Note : Shutdown Validator command should be invoked from chain owner wallet only
Sample Response :
shutdown validator $VALIDATOR_ID with txId : 2a6c031ced1d1e7dc4ed17801b4413786ecd2501df5ab8ebf653012dd498348e
Kill Blobber
./zbox kill-blobber command deactivates a blobber to avoid storage of data . Required parameters are :
| Parameter |
Required |
Description |
| –id |
yes |
Blobber Id to kill a specific blobber.Can be retrieved using List blobbers. |
Sample Command :
./zbox kill-blobber --id $BLOBBER_ID --wallet $CHAIN_OWNER_WALLET
Note : Kill Blobber command should be evoked from chain owner wallet only
Sample Response :
killed blobber $BLOBBER_ID
Kill Validator
./zbox kill-validator command deactivates a specific validator available on the network. Required parameters are :
| Parameter |
Required |
Description |
| –id |
yes |
Validator Id to kill a specific blobber.Can be retrieved using List all Validators. |
Sample Command :
./zbox kill-validator --id $VALIDATOR_ID --wallet $CHAIN_OWNER_WALLET
Sample Response :
killed validator, id: $VALIDATOR_ID
Uploading and Managing files
Create Directory
Use createdir command to create a directory in the specified allocation
The user must be the owner of the allocation.
| Parameter |
Required |
Description |
Default |
Valid values |
| allocation |
yes |
allocation id, sender must be allocation owner |
|
string |
| dirname |
yes |
path to directory |
|
string |
Sample Request :
./zbox createdir --allocation {ALLOC_ID} --dirname /abcd/
Sample Response :
/abcd/ directory created
Upload
Use upload command to upload file(s).
- upload a local file
- download segment files from remote live feed, and upload them
- start live streaming from local devices, encode it into segment files with
ffmpeg, and upload them.
The user must be the owner of the allocation.You can request the file be encrypted before upload, and can send thumbnails with the file.
| Parameter |
Required |
Description |
Default |
Valid values |
| allocation |
yes |
allocation id, sender must be allocation owner |
|
string |
| encrypt |
no |
encrypt file before upload |
false |
boolean |
| web-streaming |
no |
transcode file before upload to fragmented mp4 |
false |
boolean |
| localpath |
yes |
local path of the file to upload |
|
file path |
| remotepath |
yes |
remote path to upload file to, use to access file later |
|
string |
| thumbnailpath |
no |
local path of thumbnail |
|
file path |
| chunknumber |
no |
how many chunks should be uploaded in a http request |
1 |
int |
| attr-who-pays-for-reads |
no |
Who pays for reads: owner or 3rd_party |
owner |
owner / 3rd_party |
| multiuploadjson |
no |
A JSON file containing multiupload options |
|
file path |
upload

Example
Upload file with no encryption
./zbox upload --localpath /absolute-path-to-local-file/hello.txt --remotepath /myfiles/hello.txt --allocation d0939e912851959637257573b08c748474f0dd0ebbc8e191e4f6ad69e4fdc7ac
Response:
12390 / 12390 [================================================================================] 100.00% 3s
Status completed callback. Type = application/octet-stream. Name = hello.txt
Upload file with encryption
Use upload command with optional encrypt parameter to upload a file in encrypted
format. This can be downloaded as normal from same wallet/allocation or utilize
Proxy Re-Encryption facility (see download command).
./zbox upload --encrypt --localpath <absolute path to file>/sensitivedata.txt --remotepath /myfiles/sensitivedata.txt --allocation d0939e912851959637257573b08c748474f0dd0ebbc8e191e4f6ad69e4fdc7ac
Response:
12390 / 12390 [================================================================================] 100.00% 3s
Status completed callback. Type = application/octet-stream. Name = sensitivedata.txt
Upload file with web-streaming
Use upload command with optional web-streaming parameter to upload a video file in fragmented
mp4 format to support streaming from browser.
./zbox upload --web-streaming --localpath <absolute path to file>/samplevideo.mov --remotepath /myfile/ --allocation d0939e912851959637257573b08c748474f0dd0ebbc8e191e4f6ad69e4fdc7ac
Response:
15691733 / 15691733 [=====================================================================================] 100.00% 32s
Status completed callback. Type = video/fmp4. Name = raw.samplevideo.mp4
Feed
Use feed command to automatically download segment files from remote live feed with --downloader-args "-q -f best"
- encode them into new segment files with
--delay and --ffmpeg-args, and upload.
- please use
youtube-dl -F https://www.youtube.com/watch?v=pC5mGB5enkw to list formats of video (see below).
The user must be the owner of the allocation.You can request the file be encrypted before upload, and can send thumbnails with the file.
| Parameter |
Required |
Description |
Default |
Valid values |
| allocation |
yes |
allocation id, sender must be allocation owner |
|
string |
| encrypt |
no |
encrypt file before upload |
false |
boolean |
| localpath |
yes |
local path of segment files to download, generate and upload |
|
file path |
| remotepath |
yes |
remote path to upload file to, use to access file later |
|
string |
| thumbnailpath |
no |
local path of thumbnaSil |
|
file path |
| chunknumber |
no |
how many chunks should be uploaded in a http request |
1 |
int |
| delay |
no |
set segment duration to seconds. |
5 |
int |
| feed |
no |
set remote live feed to url. |
false |
url |
| downloader-args |
no |
pass args to youtube-dl to download video. default is "-q -f best". |
-q -f best |
youtube-dl |
| ffmpeg-args |
no |
pass args to ffmpeg to build segments. |
-loglevel warning |
ffmpeg |
| attr-who-pays-for-reads |
no |
Who pays for reads: owner or 3rd_party |
owner |
owner / 3rd_party |
| enum |
|
|
|
|
feed

[youtube] pC5mGB5enkw: Downloading webpage
[info] Available formats for pC5mGB5enkw:
format code extension resolution note
249 webm audio only tiny 44k , webm_dash container, opus @ 44k (48000Hz), 95.21MiB
250 webm audio only tiny 59k , webm_dash container, opus @ 59k (48000Hz), 127.05MiB
251 webm audio only tiny 123k , webm_dash container, opus @123k (48000Hz), 264.98MiB
140 m4a audio only tiny 129k , m4a_dash container, mp4a.40.2@129k (44100Hz), 277.82MiB
278 webm 256x136 144p 87k , webm_dash container, vp9@ 87k, 30fps, video only, 188.78MiB
160 mp4 256x136 144p 118k , mp4_dash container, avc1.4d400c@ 118k, 30fps, video only, 253.62MiB
242 webm 426x224 240p 190k , webm_dash container, vp9@ 190k, 30fps, video only, 409.20MiB
133 mp4 426x224 240p 252k , mp4_dash container, avc1.4d400d@ 252k, 30fps, video only, 541.15MiB
243 webm 640x338 360p 326k , webm_dash container, vp9@ 326k, 30fps, video only, 701.53MiB
134 mp4 640x338 360p 576k , mp4_dash container, avc1.4d401e@ 576k, 30fps, video only, 1.21GiB
244 webm 854x450 480p 649k , webm_dash container, vp9@ 649k, 30fps, video only, 1.36GiB
135 mp4 854x450 480p 1028k , mp4_dash container, avc1.4d401f@1028k, 30fps, video only, 2.16GiB
247 webm 1280x676 720p 1320k , webm_dash container, vp9@1320k, 30fps, video only, 2.77GiB
136 mp4 1280x676 720p 1988k , mp4_dash container, avc1.64001f@1988k, 30fps, video only, 4.17GiB
248 webm 1920x1012 1080p 2527k , webm_dash container, vp9@2527k, 30fps, video only, 5.30GiB
137 mp4 1920x1012 1080p 4125k , mp4_dash container, avc1.640028@4125k, 30fps, video only, 8.64GiB
271 webm 2560x1350 1440p 7083k , webm_dash container, vp9@7083k, 30fps, video only, 14.84GiB
313 webm 3840x2026 2160p 13670k , webm_dash container, vp9@13670k, 30fps, video only, 28.65GiB
18 mp4 640x338 360p 738k , avc1.42001E, 30fps, mp4a.40.2 (44100Hz), 1.55GiB
22 mp4 1280x676 720p 2117k , avc1.64001F, 30fps, mp4a.40.2 (44100Hz) (best)
--downloader-args "-f 22" dowloads video with 22 mp4 1280x676 720p 2117k , avc1.64001F, 30fps, mp4a.40.2 (44100Hz) (best)
./zbox feed --localpath <absolute path to file>/tvshow.m3u8 --remotepath /videos/tvsho --allocation d0939e912851959637257573b08c748474f0dd0ebbc8e191e4f6ad69e4fdc7ac --delay 10 --downloader-args "-f 22" --feed https://www.youtube.com/watch?v=pC5mGB5enkw
Download
Use download command to download your own or a shared file.
owner The owner of the allocation can always download files, in this case the owner pays for the download.
collaborator A collaborator can download files, the owner pays. To add collaborators to an allocation, use
add-collab.
authticket To download a file using authticket, you must have previous be given an auth
ticket using the share command. Use rx_pay to indicate who pays, rx_pay = true you pay,
rx_pay = false the allocation owner pays.
Use startblock and endblock to only download part of the file.
| Parameter |
Required |
Description |
Default |
Valid values |
| allocation |
yes |
allocation id |
|
string |
| authticket |
no |
auth ticked if not owner of the allocation, use share to get auth ticket |
|
string |
| blockspermarker |
no |
download multiple blocks per marker |
10 |
int |
| endblock |
no |
download until specified block number |
|
int |
| localpath |
yes |
local path to which to download the file to |
|
file path |
| remotepath |
yes |
remote path to which the file was uploaded |
|
string |
| startblock |
no |
start download from specified block |
|
int |
| thumbail |
no |
only download the thumbnail |
false |
boolean |
| live |
no |
start m3u8 downloader,and automatically generate media playlist(m3u8) on --localpath |
false |
boolean |
| delay |
no |
pass segment duration to generate media playlist(m3u8). only works with --live. default duration is 5s. |
5 |
int |
| lookuphash |
no |
The remote lookuphash of the object retrieved from the list |
|
string |
| multidownloadjson |
no |
A JSON file containing multi download options |
|
string |
| verifydownload |
no |
pass this option to verify downloaded blocks |
false |
boolean |
download

Example (for owner)
./zbox download --allocation 3c0d32560ea18d9d0d76808216a9c634f661979d29ba59cc8dafccb3e5b95341 --remotepath /myfiles/horse.jpeg --localpath ../horse.jpeg
Example (for non-owner) with authticket
./zbox download --allocation 3c0d32560ea18d9d0d76808216a9c634f661979d29ba59cc8dafccb3e5b95341 --authticket eyJjbGllbnRfaWQiOiIiLCJvd25lcl9pZCI6IiIsImFsbG9jYXRpb24iOiIzYzBkMzI1NjBlYTE4ZDlkMGQ3NjgwODIxNmE5YzYzNGY2NjE5NzlkMjliYTU5Y2M4ZGFjYmMzZTViOTUzNDEiLCJyZW1vdGVwYXRoIjoiL215ZmlsZXMvaG9yc2UuanBlZyIsImV4cG9ydCI6IjIwMjEtMDctMjFUMDk6MjA6MjAuMDAwWiJ9 --localpath ../horse.jpeg
If the authticket is for a directory, not a file, then you need to provide the lookup hash of the file you want to download. You can get the lookup hash from the list command.
Response:
4 / 4 [=======================================================================] 100.00% 3s
Status completed callback. Type = application/octet-stream. Name = horse.jpeg
Note: You can download by using only 1 on the below combination:
--remotepath, --allocation
--authticket
Downloaded file will be in the location specified by the localpath argument.
Update
Use update command to update content of an existing file in the remote path.
Like upload command. Only the owner of the allocation or a collaborator
can update a file. To add collaborators to an allocation, use
add-collab.
| Parameter |
Required |
Description |
Default |
Valid values |
| allocation |
yes |
allocation id |
|
string |
| encrypt |
no |
encrypt file before upload |
false |
boolean |
| localpath |
yes |
local file to upload |
|
file path |
| remotepath |
yes |
remote file to upload |
|
string |
| thumbnailpath |
no |
local fumbnail file to upload |
|
file path |
| chunknumber |
no |
how many chunks should be uploaded in a http request |
1 |
int |
update

Sample Command :
./zbox update --allocation {ALLOC_ID} --localpath ./zbox_commands.txt --remotepath /abcd/ --encrypt
Sample Response :
Status completed callback. Type = application/octet-stream. Name = zbox_commands.txt
Delete
Use delete command to delete your file on the allocation. Only the owner
of the application can delete a file.
| Parameter |
Required |
Description |
Default |
Valid values |
| allocation |
yes |
allocation id |
|
string |
| remotepath |
yes |
remote path of file to delete |
|
string |
delete

Example
./zbox delete --allocation 3c0d32560ea18d9d0d76808216a9c634flist661979d29ba59cc8dafccb3e5b95341 --remotepath /myfiles/horse.jpeg
Response:
/myfiles/horse.jpeg deleted
File successfully deleted (Can be verified using list)
Share

Use share command to generate an authtoken that provides authorization to the holder to the specified file on the remotepath.
auth ticket can be used with download, and list,
meta and get_download_cost, but only for files in
the pre-defined remote path.
| Parameter |
Required |
Description |
Valid values |
| allocation |
yes |
allocation id |
string |
| clientid |
no |
id of user to share file with (or revoke share from), leave blank for public share (or to revoke public sharing) |
string |
| encryptionpublickey |
no |
public key of the client to share file with, required if clientId |
string |
| expiration-seconds |
no |
seconds before auth ticket expires |
int |
| remotepath |
yes |
remote path of file to share |
string |
| revoke |
no |
revoke share for remote path |
flag |
| available-after |
no |
timelock for private file that makes the file available for download at certain time. 4 input formats are supported: +1h30m, +30, 1647858200 and 2022-03-21 10:21:38. default value is current local time |
string |
share

Example
Public share
./zbox share --allocation 3c0d32560ea18d9d0d76808216a9c634f661979d29ba59cc8dafccb3e5b95341 --remotepath /myfiles/hello.txt
Response:
Auth token eyJjbGllbnRfaWQiOiIiLCJvd25lcl9pZCI6IjE3ZTExOTQwNmQ4ODg3ZDAyOGIxNDE0YWNmZTQ3ZTg4MDhmNWIzZjk4Njk2OTk4Nzg3YTIwNTVhN2VkYjk3YWYiLCJhbGxvY2F0aW9uX2lkIjoiODlkYjBjZDI5NjE4NWRkOTg2YmEzY2I0ZDBlODE0OTE3NmUxNmIyZGIyMWEwZTVjMDZlMTBmZjBiM2YxNGE3NyIsImZpbGVfcGF0aF9oYXNoIjoiM2NhNzIyNTQwZTY1M2Y3NTQ1NjI5ZjBkYzE5ZGY2ODk5ZTI0MDRjNDI4ZDRiMWZlMmM0NjI3ZGQ3MWY3ZmQ2NCIsImFjdHVhbF9maWxlX2hhc2giOiIyYmM5NWE5Zjg0NDlkZDEyNjFmNmJkNTg3ZjY3ZTA2OWUxMWFhMGJiIiwiZmlsZV9uYW1lIjoidGVzdC5wZGYiLCJyZWZlcmVuY2VfdHlwZSI6ImYiLCJleHBpcmF0aW9uIjoxNjM1ODQ5MzczLCJ0aW1lc3RhbXAiOjE2MjgwNzMzNzMsInJlX2VuY3J5cHRpb25fa2V5IjoiIiwiZW5jcnlwdGVkIjpmYWxzZSwic2lnbmF0dXJlIjoiZDRiOTM4ZTE0MDk0ZmZkOGFiMDcwOWFmN2QyMDAyZTdlMGFmNmU3MWJlNGFmMmRjNmUxMGYxZWJmZTUwOTMxOSJ9
Auth token decoded
{"client_id":"","owner_id":"17e119406d8887d028b1414acfe47e8808f5b3f98696998787a2055a7edb97af","allocation_id":"89db0cd296185dd986ba3cb4d0e8149176e16b2db21a0e5c06e10ff0b3f14a77","file_path_hash":"3ca722540e653f7545629f0dc19df6899e2404c428d4b1fe2c4627dd71f7fd64","actual_file_hash":"2bc95a9f8449dd1261f6bd587f67e069e11aa0bb","file_name":"test.pdf","reference_type":"f","expiration":1635849373,"timestamp":1628073373,"re_encryption_key":"","encrypted":false,"signature":"d4b938e14094ffd8ab0709af7d2002e7e0af6e71be4af2dc6e10f1ebfe509319"}
Encrypted share
Upload file with –encrypted tag.
Get encryptionpublickey first, by calling from user you sharing with:
./zbox getwallet
Response:
PUBLIC KEY | CLIENTID | ENCRYPTION PUBLIC KEY
-----------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------+-----------------------------------------------
19cd2396df9b8b77358a1110492ff65cbb5b55cae06b8bd204e0969b2454851ca620ae74aebe9ed641166be3bca056a1855610f6154f4f4435a29565a2111282 | b734ef935e2a02892b2fa31e3488b360ef300d3b0b32c03834cea3a83e2453f0 | 1JuT4AbQnmIaOMTuWn07t98xQRsSqXAxZYfwCI1yQLM=
You have to pickup ENCRYPTION PUBLIC KEY
Use clientid of the user to share with. encryptionpublickey - key from command above.

./zbox share --allocation 3c0d32560ea18d9d0d76808216a9c634f661979d29ba59cc8dafccb3e5b95341 --remotepath /myfiles/hello.txt --clientid b6de562b57a0b593d0480624f79a55ed46dba544404595bee0273144e01034ae --encryptionpublickey 1JuT4AbQnmIaOMTuWn07t98xQRsSqXAxZYfwCI1yQLM=
Response:
Auth token eyJjbGllbnRfaWQiOiIwMGZmODhkY2IxNjQ2Y2RlZjA2OWE4MGE0MGQwMWNlOTYyMmQ3ZmUzYmQ0ZWNjMzIzYTcwZTdkNmVkMWE2YjY3Iiwib3duZXJfaWQiOiIxN2UxMTk0MDZkODg4N2QwMjhiMTQxNGFjZmU0N2U4ODA4ZjViM2Y5ODY5Njk5ODc4N2EyMDU1YTdlZGI5N2FmIiwiYWxsb2NhdGlvbl9pZCI6Ijg5ZGIwY2QyOTYxODVkZDk4NmJhM2NiNGQwZTgxNDkxNzZlMTZiMmRiMjFhMGU1YzA2ZTEwZmYwYjNmMTRhNzciLCJmaWxlX3BhdGhfaGFzaCI6IjM2Mjk0MGMwMTZlOWZlZTQ4ZmI5MTA0OGI4MzJjOGFlNWQ2MGUyYzUzMmQ1OGNlYzdmNGM0YjBmZTRkZjM2MzYiLCJhY3R1YWxfZmlsZV9oYXNoIjoiMmJjOTVhOWY4NDQ5ZGQxMjYxZjZiZDU4N2Y2N2UwNjllMTFhYTBiYiIsImZpbGVfbmFtZSI6InRlc3QyLnBkZiIsInJlZmVyZW5jZV90eXBlIjoiZiIsImV4cGlyYXRpb24iOjE2MzU4NDk4NDMsInRpbWVzdGFtcCI6MTYyODA3Mzg0MywicmVfZW5jcnlwdGlvbl9rZXkiOiIiLCJlbmNyeXB0ZWQiOnRydWUsInNpZ25hdHVyZSI6IjNlNGMwOTAwMzAwN2M5NzUzZjFiNGIwODExMWM4OGRlY2JmZjU2MDRmNTIwZDZjMmYyMTdhMzUyZTFkMmE0MTEifQ==
Auth token decoded
{"client_id":"00ff88dcb1646cdef069a80a40d01ce9622d7fe3bd4ecc323a70e7d6ed1a6b67","owner_id":"17e119406d8887d028b1414acfe47e8808f5b3f98696998787a2055a7edb97af","allocation_id":"89db0cd296185dd986ba3cb4d0e8149176e16b2db21a0e5c06e10ff0b3f14a77","file_path_hash":"362940c016e9fee48fb91048b832c8ae5d60e2c532d58cec7f4c4b0fe4df3636","actual_file_hash":"2bc95a9f8449dd1261f6bd587f67e069e11aa0bb","file_name":"test2.pdf","reference_type":"f","expiration":1635849843,"timestamp":1628073843,"re_encryption_key":"","encrypted":true,"signature":"3e4c09003007c9753f1b4b08111c88decbff5604f520d6c2f217a352e1d2a411"}
Response contains an auth ticket- an encrypted string that can be shared.
Directory share
Follow up steps above to get encryptionpublickey
Upload multiple files to directory with zbox upload /folder1/file1.z …
./zbox share --allocation 3c0d32560ea18d9d0d76808216a9c634f661979d29ba59cc8dafccb3e5b95341 --remotepath /folder1 --clientid b6de562b57a0b593d0480624f79a55ed46dba544404595bee0273144e01034ae --encryptionpublickey 1JuT4AbQnmIaOMTuWn07t98xQRsSqXAxZYfwCI1yQLM=
Response:
Encoded
eyJjbGllbnRfaWQiOiJiNzM0ZWY5MzVlMmEwMjg5MmIyZmEzMWUzNDg4YjM2MGVmMzAwZDNiMGIzMmMwMzgzNGNlYTNhODNlMjQ1M2YwIiwib3duZXJfaWQiOiI2MzlmMjcxZmU1MTFjZDE4ODBjMmE0ZDhlYTRhNGYyNDBmYWYzMzY1YzYxYjY1YjQyNWZhYjVlMDIzMTcxM2MzIiwiYWxsb2NhdGlvbl9pZCI6IjkzN2FkNjlmYjIwZGMxMTFiY2ZkMDFkZTQyYzc5MmEwYzJiNDQxZGUzZDNjZjRjZGIzZjI1YzIxYzFhYjRiN2IiLCJmaWxlX3BhdGhfaGFzaCI6ImFkMThmMzg1Y2I2MWM4MTNjMzE0NDU2OTM0NWYxYzQ2ODE1ODljNzM0N2JkNzI4NjkyZTg1ZjFiNzM4NmI2OWQiLCJhY3R1YWxfZmlsZV9oYXNoIjoiIiwiZmlsZV9uYW1lIjoiZm9sZGVyMSIsInJlZmVyZW5jZV90eXBlIjoiZCIsImV4cGlyYXRpb24iOjE2MzYyODgwNDMsInRpbWVzdGFtcCI6MTYyODUxMjA0MywicmVfZW5jcnlwdGlvbl9rZXkiOiIiLCJlbmNyeXB0ZWQiOnRydWUsInNpZ25hdHVyZSI6ImNiYTZlMjA2OTBjOGZjZTk5YmFjZTMzYjFjMGY3ODQ5ZDE4YmJlMTdhODkyNjczODg1MjI2MDc3MGQzNzgzMGQifQ==
Decoded
{"client_id":"b734ef935e2a02892b2fa31e3488b360ef300d3b0b32c03834cea3a83e2453f0","owner_id":"639f271fe511cd1880c2a4d8ea4a4f240faf3365c61b65b425fab5e0231713c3","allocation_id":"937ad69fb20dc111bcfd01de42c792a0c2b441de3d3cf4cdb3f25c21c1ab4b7b","file_path_hash":"ad18f385cb61c813c3144569345f1c4681589c7347bd728692e85f1b7386b69d","actual_file_hash":"","file_name":"folder1","reference_type":"d","expiration":1636288043,"timestamp":1628512043,"re_encryption_key":"","encrypted":true,"signature":"cba6e20690c8fce99bace33b1c0f7849d18bbe17a8926738852260770d37830d"}
Make sure “reference_type”:“d” is “d” (directory)
Now you able to download files inside this directory with same auth*ticket. To download it just point to excact file location in *–remotepath_ param:
zbox download --allocation 76ad9fa86f9b6685880553588a250586806ba5d7d20fc229d6905998be55d64a --localpath ~/file1.z --authticket $auth --remotepath /folder1/file1.z
This method works for both: encrypted and non-encrypted files.
share-encrypted revoke
This will cancel the share for particular buyer that was performed by the seller using zbox share. Works only for files with --encrypted tag.
Use clientid of the user that was share the remotepath.
Required parameters are allocation, remotepath and clientid.
Command
./zbox share --revoke --allocation 3c0d32560ea18d9d0d76808216a9c634f661979d29ba59cc8dafccb3e5b95341 --remotepath /myfiles/hello.txt --clientid d52d82133177ec18505145e784bc87a0fb811d7ac82aa84ae6b013f96b93cfaa
Response
Returns status message showing whether the operation was successful or not.
List
Use list command to list files in given remote path of the dSt</allocation_id></allocation_id></client_key>
README 内容过长,已截取前 64 KB。完整内容请前往 GitHub 仓库查看。
评论