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
1
git clone https://github.com/0chain/zwalletcli.git
2
cd zwalletcli
3
export PATH=$PATH:/usr/local/go/bin
4
make install
Copied!
After a successful build, you should see the following output:
2. Now register and get the test tokens into your wallet by using
1
./zwallet register
2
./zwallet faucet --methodName pour --input "{Pay day}"
Copied!
On Successful response:
1
Wallet Registered !
2
Execute faucet smart contract success with txn : 50e6cf293567e456527a13a6981f1188fb6eb6b930c805c7ddba5e7e26ba9e6f
Copied!
3.Check Token balance in zwallet using the
1
./zwallet getbalance
Copied!
Response-
1
Balance: 1.000 ZCN (0.44 USD)
Copied!
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
1
./zbox ls-blobbers
Copied!
The sample response will show all the active blobbers:
1
- id: 7a90e6790bcd3d78422d7a230390edc102870fe58c15472073922024985b1c7d
2
url: http://198.18.0.92:5052
3
used / total capacity: 0 B / 1.0 GiB
4
last_health_check: 1631835252
5
terms:
6
read_price: 10.000 mZCN / GB
7
write_price: 100.000 mZCN / GB / time_unit
8
min_lock_demand: 0.1
9
cct: 2m0s
10
max_offer_duration: 744h0m0s
11
- id: f65af5d64000c7cd2883f4910eb69086f9d6e6635c744e62afcfab58b938ee25
12
url: http://198.18.0.91:5051
13
used / total capacity: 0 B / 1.0 GiB
14
last_health_check: 1631835202
15
terms:
16
read_price: 10.000 mZCN / GB
17
write_price: 100.000 mZCN / GB / time_unit
18
min_lock_demand: 0.1
19
cct: 2m0s
20
max_offer_duration: 744h0m0s
21
Copied!
5. Export Blobber IDs to variables.
1
export BLOBBER1=f65af5d64000c7cd2883f4910eb69086f9d6e6635c744e62afcfab58b938ee25
2
export BLOBBER2=7a90e6790bcd3d78422d7a230390edc102870fe58c15472073922024985b1c7d
Copied!
6.Add tokens to the stake pools of all the active blobbers to allow them to accept allocations.
1
./zbox sp-lock --blobber_id $BLOBBER1 --tokens 1
2
./zbox sp-lock --blobber_id $BLOBBER2 --tokens 1
Copied!
Sample Response:
1
tokens locked, pool id: 057f92514a2d3faca13443b7c0023878552e73c984c15ba7450b9892446adfbd
Copied!
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
1
./zbox newallocation --help
Copied!
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 :
1
./zbox newallocation --lock 0.5 --data 1 --parity 1
Copied!
Successful Response will create an allocation with allocation ID:
1
Allocation created :fa34be9c225077ede736b8012738d6b591aff822d75a630701ae99c05c32fac7
Copied!
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
1
./zbox listallocations
Copied!
You will see your allocation ID listed with the specified configuration:
Response:
1
ID | SIZE | EXPIRATION | DATASHARDS | PARITYSHARDS | FINALIZED | CANCELED | R PRICE | W PRICE
2
+------------------------------------------------------------------+------------+-------------------------------+------------+--------------+-----------+----------+----------+----------+
3
52fb9b5926c06e43a9290e9d7ad3217a4aee51c94684baf0fc174aa41abe6059 | 2147483648 | 2021-05-14 17:50:59 +0000 UTC | 2 | 2 | false | false | 0.04 | 0.04
Copied!
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