Skip to content

Latest commit

 

History

History
65 lines (41 loc) · 1.59 KB

README.md

File metadata and controls

65 lines (41 loc) · 1.59 KB

@cere-ddc-sdk/blockchain

The package provides API for interacting with Cere blockchain.

Installation

Using NPM:

npm install @cere-ddc-sdk/blockchain --save

Using yarn:

yarn add @cere-ddc-sdk/blockchain

Usage

The package provides Blockchain class which acts as an entry point and multiple DDC pallet wrappers, each of which is responsible for interacting with a particular DDC pallet on the blockchain.

Here is an example how to create a bucket

  1. Create a Blockchain instance and connect it to TESTNET

    import { Blockchain, UriSigner } from '@cere-ddc-sdk/blockchain';
    
    const account = new UriSigner('//Alice');
    const blockchain = await Blockchain.connect({
      wsEndpoint: 'wss://rpc.testnet.cere.network/ws',
    });
  2. Make a deposit

    const deposit = 100n * 10n ** blockchain.chainDecimals; // 100 CERE
    const tx = blockchain.ddcCustomers.deposit(deposit);
    
    await blockchain.send(tx, { account })

    The account used to make deposit and create the bucket should have positive CERE tokens balance.

  3. Create a public bucket

    const clusterId = '0x...';
    const tx = blockchain.ddcCustomers.createBucket(clusterId, { isPublic: true });
    
    const { events } = await blockchain.send(tx, { account })
    const [bucketId] = blockchain.ddcCustomers.extractCreatedBucketIds(events);
    
    console.log('Bucket ID', bucketId);

Documentation

For more information about what this package provides, see API reference

License

Licensed under the Apache License