@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
-
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',
});
-
Make a deposit
const deposit = 100n * 10n ** blockchain.chainDecimals;
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.
-
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