The market command

Under the market subcommand Market related extrinsics are available. This chapter covers the provided commands and how to use them.

The storagext-cli getting started page covers the basic flags necessary to operate the CLI and should be read first.

add-balance

The add-balance adds balance to the market account of the extrinsic signer. It takes a single AMOUNT argument, the balance to add to the market account, the balance will be added to the free balance.

Parameters

NameDescriptionType
AMOUNTThe amount to be added to the market balancePositive integer

Example

Adding 1000000000 Plancks to Alice's account.

storagext-cli --sr25519-key "//Alice" market add-balance 1000000000
The 1000000000 value is not arbitrary, it is the minimum existential deposit for any Polkadot account. As such, when the Market account is being setup, the first deposit ever needs to meet this minimum to create the Market account.

An attempt to create a Market account with less than 1000000000, will produce the following error:

Error: Runtime error: Token error: Account cannot exist with the funds that would be given.

More information about the add_balance extrinsic is available in Pallets/Market Pallet/Add Balance.

withdraw-balance

The withdraw-balance withdraws balance from the market account of the extrinsic signer. Like add-balance, withdraw-balance takes a single AMOUNT argument; note that only free balance can be withdrawn. Likewise, withdrawal of a balance amount must be less than or equal to the free amount and greater than 0 (\({free} \ge {amount} \gt 0\)).

Parameters

NameDescriptionType
AMOUNTThe amount to be withdrawn to the market balancePositive integer

Example

Withdrawing 10000 Plancks from Alice's account.

storagext-cli --sr25519-key "//Alice" market withdraw-balance 10000

More about the withdraw_balance extrinsic is available in Pallets/Market Pallet/Withdraw Balance.

publish-storage-deals

The publish-storage-deals publishes storage deals that have been agreed upon off-chain. The deals are to be submitted by the storage provider, having been previously signed by the client.

Since this CLI is currently targeted at testing and demos, the client keypair is required to sign the deal. We know this is not secure and unrealistic in a production scenario (it is a good thing this is a demo)!

Parameters

The client keypair can be passed using --client-<key kind>, where <key kind> is one of the three supported keys, like the global keys, one is required.

NameDescriptionType
--client-sr25519-keySr25519 keypairString, encoded as hex, BIP-39 or a dev phrase like //Charlie
--client-ecdsa-keyECDSA keypairString, encoded as hex, BIP-39 or a dev phrase like //Charlie
--client-ed25519-keyEd25519 keypairString, encoded as hex, BIP-39 or a dev phrase like //Charlie
DEALSThe deals to be publishedJSON array. Can be passed as a string, or as a file path prefixed with @ pointing to the file containing the JSON object.

The DEALS JSON array is composed of objects:

NameDescriptionType
piece_cidByte encoded CIDCID
piece_sizeSize of the piecePositive integer
clientSS58 address of the storage clientSS58 address
providerSS58 address of the storage providerSS58 address
labelArbitrary client chosen labelString, with a maximum length of 128 characters
start_blockBlock number on which the deal should startPositive integer
end_blockBlock number on which the deal should endPositive integer, end_block > start_block
storage_price_per_blockPrice for the storage specified per block1Positive integer, in Plancks
provider_collateralCollateral which is slashed if the deal failsPositive integer, in Plancks
stateDeal state. Can only be set to PublishedString

Example

Publishing deals between Alice (the Storage Provider) and Charlie (the client).

storagext-cli --sr25519-key "//Alice" market publish-storage-deals \
  --client-sr25519-key "//Charlie" \
  "@deals.json"

Where deals.json is a file with contents similar to:

[
  {
    "piece_cid": "bafk2bzacecg3xxc4f2ql2hreiuy767u6r72ekdz54k7luieknboaakhft5rgk",
    "piece_size": 1337,
    "client": "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y",
    "provider": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
    "label": "Super Cool (but secret) Plans for a new Polkadot Storage Solution",
    "start_block": 69,
    "end_block": 420,
    "storage_price_per_block": 15,
    "provider_collateral": 2000,
    "state": "Published"
  },
  {
    "piece_cid": "bafybeih5zgcgqor3dv6kfdtv3lshv3yfkfewtx73lhedgihlmvpcmywmua",
    "piece_size": 1143,
    "client": "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y",
    "provider": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
    "label": "List of problematic (but flying) Boeing planes",
    "start_block": 1010,
    "end_block": 1997,
    "storage_price_per_block": 1,
    "provider_collateral": 3900,
    "state": "Published"
  }
]

More information about the publish_storage_deals extrinsic is available in Pallets/Market Pallet/Publish Storage Deals.

settle-deal-payments

The settle-deal-payments command makes the storage provider receive the owed funds from storing data for their clients. Non-existing deal IDs will be ignored.

Anyone can settle anyone's deals, though there's little incentive to do so as it costs gas, so the Storage Provider will end up being the caller most of the time.

Parameters

NameDescription
DEAL_IDSThe IDs for the deals to be settled

Example

Settling deals with the IDs 97, 1010, 1337, 42069:

storagext-cli --sr25519-key "//Alice" market settle-deal-payments 97 1010 1337 42069

More information about the publish_storage_deals extrinsic is available in Pallets/Market Pallet/Settle Deal Payments.

retrieve-balance

The retrieve-balance command checks the balance of a given market account.

Parameters

NameDescription
ACCOUNT_IDThe IDs of the account being checked

Example

storagext-cli market retrieve-balance "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" # Alice's account

This command is not signed, and does not need to be called using any of the --X-key flags.