Link Search Menu Expand Document

Quickstart

Table of contents

  1. Install polkadot{.js} extension
  2. Install DDC CLI
  3. Generate keys
  4. Import account to polkadot{.js} extension
  5. Create application
  6. Use DDC CLI
    1. Configure
    2. Produce Data
    3. Consume Data
  7. Use client library
    1. Install
    2. Produce Data
    3. Consuming Data

Install polkadot{.js} extension

You can download extension here: https://polkadot.js.org/extension

Install DDC CLI

Download a binary file from releases.

  1. Unzip (expand) a compressed item: Double-click the downloaded .zip file
  2. Make this file executable
    chmod +x ddc-cli
    

Generate keys

If you don’t have a wallet yet, you can use DDC CLI to generate a secret phrase (mnemonic code) and keypair (public and private keys):

./ddc-cli generate-keys

NOTE: Please write down your secret phrase and keep it in a safe place. The secret phrase (mnemonic) can be used to restore your keys (wallet). Keep it carefully to not lose your assets.

Or you can extract keys from existing secret phrase (mnemonic code):

./ddc-cli extract-keys --secret-phrase 'your super secret phrase your super secret phrase your super secret phrase'

Import account to polkadot{.js} extension

You can import generated account to the extension (if you used generate-keys command):

  1. Open extension in the browser
  2. Click the add icon at the top right
  3. Select Import account from pre-existing seed
  4. Put your secret phrase
  5. Click Next and follow instructions

Create application

To create application your account should have enough CERE tokens (depends on the tier you select) to subscribe in DDC smart contract.

Don’t have tokens yet? You can use friend bot to receive token on Testnet:

  1. Select Testnet
  2. Enter public key (that you got by generate-keys or extract-keys command)

NOTE: You can use Cere Explorer to check the balance

Then you can create application using Cere DDC Console.

  1. Click Sign Up at the top right
  2. Select account to log in and press Log in button
  3. Select a tier you want to use
  4. Click Subscribe button

Use DDC CLI

Configure

Use public and private keys to configure CLI (that you got by generate-keys or extract-keys command)

./ddc-cli configure --bootstrapNodes https://node-0.ddc.stage.cere.network/ --appPubKey APP_PUB_KEY --appPrivKey APP_PRIV_KEY

Produce Data

./ddc-cli produce -d test_data -u test_user

Consume Data

./ddc-cli consume --stream-id test_stream --offset-reset earliest

Use client library

Install

You can find the latest version of client library here

If you are using Gradle, add the following to your dependencies:

repositories {
    maven { url = uri("https://jitpack.io") }
}
dependencies {
    api("com.github.cerebellum-network:ddc-client-kotlin:1.2.0.Final")
}

If you are using Maven, add the following to your dependencies:

<dependency>
    <groupId>com.github.cerebellum-network</groupId>
    <artifactId>ddc-client-kotlin</artifactId>
    <version>1.2.0.Final</version>
</dependency>

Produce Data

Use public and private keys to configure the producer (that you got by generate-keys or extract-keys command)

val appPubKey = "0x7f9866baf46bbb2aa60a79c8e1e706d5e6ad83b05b4d3bc18cb7163ab20208c3"
val appPrivKey =
    "0xd1c60ff157b5d80df830fde62ea1156dc1905d2efa29a57c3e0a0fb09b16e4cf7f9866baf46bbb2aa60a79c8e1e706d5e6ad83b05b4d3bc18cb7163ab20208c3"
val bootstrapNodes = listOf("https://https://node-0.ddc.dev.cere.network")

val producerConfig = ProducerConfig(
    appPubKey = appPubKey,
    appPrivKey = appPrivKey,
    signatureScheme = Sr25519,
    bootstrapNodes = bootstrapNodes
)
val ddcProducer = DdcProducer(
    producerConfig
)

val res = ddcProducer.send(
    Piece(
        id = UUID.randomUUID().toString(),
        appPubKey = producerConfig.appPubKey,
        userPubKey = "test_user",
        timestamp = Instant.now(),
        data = "test_data"
    )
)
    .await().indefinitely()

println("cid: ${res.cid}")

Consuming Data

Use public key to configure the consumer (that you got by generate-keys or extract-keys command)

val appPubKey = "0x7f9866baf46bbb2aa60a79c8e1e706d5e6ad83b05b4d3bc18cb7163ab20208c3"
val bootstrapNodes = listOf("https://node-0.ddc.stage.cere.network")

val consumerConfig = ConsumerConfig(appPubKey, bootstrapNodes)
val ddcConsumer = DdcConsumer(consumerConfig)

ddcConsumer.consume("test_stream", listOf(), OffsetReset.EARLIEST)
    .subscribe().with({ cr -> println(cr.piece) }, { e -> println(e) })