0Chain
Search…
Step 8: Creating an Allocation on Blobber
To create storage space on the blobber we have to use the zboxcli and zwalletcli to interface with the blockchain.
  1. 1.
    Get the test tokens into your wallet using the zwallet CLI tool. If you have not installed zwallet CLI clone the repository and install using these commands
git clone https://github.com/0chain/zwalletcli.git
cd zwalletcli
export PATH=$PATH:/usr/local/go/bin
make install
After a successful build, you should see the following output:
2. Now register and get the test tokens into your wallet by using
./zwallet register
./zwallet faucet --methodName pour --input "{Pay day}"
On Successful response:
Wallet Registered !
Execute faucet smart contract success with txn : 50e6cf293567e456527a13a6981f1188fb6eb6b930c805c7ddba5e7e26ba9e6f
3.Check Token balance in zwallet using the
./zwallet getbalance
Response-
Balance: 1.000 ZCN (0.44 USD)
Note : Before Proceeding further at least have 3 ZCN balance in the wallet. The tokens are required for staking before creating an allocation. 4. Once the wallet has an available balance, you have to lock tokens into stake pool .To lock tokens into stake pool you need a id of blobbers to stake which can be fetched using the command
./zbox ls-blobbers
The sample response will show all the active blobbers:
- id: 7a90e6790bcd3d78422d7a230390edc102870fe58c15472073922024985b1c7d
url: http://198.18.0.92:5052
used / total capacity: 0 B / 1.0 GiB
last_health_check: 1631835252
terms:
read_price: 10.000 mZCN / GB
write_price: 100.000 mZCN / GB / time_unit
min_lock_demand: 0.1
cct: 2m0s
max_offer_duration: 744h0m0s
- id: f65af5d64000c7cd2883f4910eb69086f9d6e6635c744e62afcfab58b938ee25
url: http://198.18.0.91:5051
used / total capacity: 0 B / 1.0 GiB
last_health_check: 1631835202
terms:
read_price: 10.000 mZCN / GB
write_price: 100.000 mZCN / GB / time_unit
min_lock_demand: 0.1
cct: 2m0s
max_offer_duration: 744h0m0s
5. Export Blobber IDs to variables.
export BLOBBER1=f65af5d64000c7cd2883f4910eb69086f9d6e6635c744e62afcfab58b938ee25
export BLOBBER2=7a90e6790bcd3d78422d7a230390edc102870fe58c15472073922024985b1c7d
6.Add tokens to the stake pools of all the active blobbers to allow them to accept allocations.
./zbox sp-lock --blobber_id $BLOBBER1 --tokens 1
./zbox sp-lock --blobber_id $BLOBBER2 --tokens 1
Sample Response:
tokens locked, pool id: 057f92514a2d3faca13443b7c0023878552e73c984c15ba7450b9892446adfbd
7. Once the tokens are locked into stake pool you can create and fun storage allocation by using the zbox newallocation command. To understand the syntax type
./zbox newallocation --help
This will output the mandatory and optional flags that need to be added with the newallocation command.
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
expire
duration to allocation expiration
720h
duration
free_storage
free storage marker file.
file path
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
mcct
max challenge completion time
1h
duration
parity
number of parity shards, effects availability
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
7.For getting started we can create a basic allocation with 1 data and parity shard. Lock some tokens using lock float variable(for example 0.5) . The complete command would be :
./zbox newallocation --lock 0.5 --data 1 --parity 1
Successful Response will create an allocation with allocation ID:
Allocation created :fa34be9c225077ede736b8012738d6b591aff822d75a630701ae99c05c32fac7
Note: For creating allocation with more data and parity shards, run more blobbers. The sum of data and parity shards should be equal or smaller than the number of running blobbers. 8.If you have successfully created an allocation verify it by running
./zbox listallocations
You will see your allocation ID listed with the specified configuration:
Response:
ID | SIZE | EXPIRATION | DATASHARDS | PARITYSHARDS | FINALIZED | CANCELED | R PRICE | W PRICE
+------------------------------------------------------------------+------------+-------------------------------+------------+--------------+-----------+----------+----------+----------+
52fb9b5926c06e43a9290e9d7ad3217a4aee51c94684baf0fc174aa41abe6059 | 2147483648 | 2021-05-14 17:50:59 +0000 UTC | 2 | 2 | false | false | 0.04 | 0.04
Notes:
  • If you are not able to create allocation and getting "transaction not found on any of the sharders", check error causes in zbox Tips and Troubleshooting Section.
  • To upload files on an allocation, modify allocation and use advanced features check zboxcli documentation.
Copy link