Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Latest commit

 

History

History
170 lines (123 loc) · 3.31 KB

File metadata and controls

170 lines (123 loc) · 3.31 KB
description
These examples demonstrates several common DDC CLI use-cases.

💻 CLI

The example assume that you already installed DDC CLI by following #install-ddc-cli instructions.

Create an account

This example demonstrates how to create a new account (wallet) on DDC Testnet

Generate a new account

npx cere-ddc account --random

Output

New account
  Mnemonic: gospel fee escape timber toilet crouch artist catalog salt icon bulb ivory
  Type: sr25519
  Address: 6PxrvjkVJFrQs6Tqdeov1GcJkS5rpzuM3NYGhX8KQErv49V2

Create a configuration

Create a configuration file (ddc.config.json) with the following content

{
  "signer": "gospel fee escape timber toilet crouch artist catalog salt icon bulb ivory"
}

Top-up the account

Top-up the account with CERE tokens either by using the faucet or by sending some amount of CERE tokens from another account.

6PxrvjkVJFrQs6Tqdeov1GcJkS5rpzuM3NYGhX8KQErv49V2

Check the account balance

npx cere-ddc --config ./ddc.config.json account

Output

Account information
  Network: testnet
  Type: sr25519
  Address: 6PxrvjkVJFrQs6Tqdeov1GcJkS5rpzuM3NYGhX8KQErv49V2
  Public key: 0x140366f3907d204001192a29c9e38243d344bae9b83726e531e46839ac461214
  Balance: 50
  Deposit: 0

Deposit tokens

Deposit 20 CERE tokens to the account

npx cere-ddc --config ./ddc.config.json deposit 20

Output

Deposit completed
  Network: testnet
  Amount: 20
  Total deposit: 20

Create a bucket

Add clusterId to the configuration file (ddc.config.json)

{
  "signer": "gospel fee escape timber toilet crouch artist catalog salt icon bulb ivory",
  "clusterId": "0x825c4b2352850de9986d9d28568db6f0c023a1e3" // <--
}

Private bucket

npx cere-ddc --config ./ddc.config.json create-bucket --access private

Output

Bucket created
  Network: testnet
  Cluster ID: 0x825c4b2352850de9986d9d28568db6f0c023a1e3
  Bucket ID: 27327n

Public bucket

npx cere-ddc --config ./ddc.config.json create-bucket --access public

Output

Bucket created
  Network: testnet
  Cluster ID: 0x825c4b2352850de9986d9d28568db6f0c023a1e3
  Bucket ID: 27328n

Upload/download files

Add bucketId to the configuration file (ddc.config.json)

{
  "signer": "gospel fee escape timber toilet crouch artist catalog salt icon bulb ivory",
  "clusterId": "0x825c4b2352850de9986d9d28568db6f0c023a1e3",
  "bucketId": "27327"
}

Upload a file

npx cere-ddc --config ./ddc.config.json upload ./2mb.jpg

Output

File upload completed
  Network: testnet
  Bucket ID: 27327n
  Path: 2mb.jpg
  CID: baebb4ide2ma4fvzr35kkgaqlnh5lgeojwsyhp4n4k7jc2qgsdizcariizm

Download the file

npx cere-ddc --config ./ddc.config.json download baebb4ide2ma4fvzr35kkgaqlnh5lgeojwsyhp4n4k7jc2qgsdizcariizm ./2mb-downloaded.jpg

Output

File download completed
  Network: testnet
  Bucket ID: 27327
  CID: baebb4ide2ma4fvzr35kkgaqlnh5lgeojwsyhp4n4k7jc2qgsdizcariizm
  Destination: 2mb-downloaded.jpg

{% hint style="info" %} Runnable versions of the examples are available in the examples directory. {% endhint %}