Skip to content

Latest commit

 

History

History
82 lines (51 loc) · 1.42 KB

CnsApi.md

File metadata and controls

82 lines (51 loc) · 1.42 KB

@cere-ddc-sdk/ddc / CnsApi

Class: CnsApi

The CnsApi class provides methods to interact with the DDC CNS API.

Example

import { CnsApi, GrpcTransport } from '@cere-ddc-sdk/ddc';

const transport = new GrpcTransport(...);
const cnsApi = new CnsApi(transport);

Methods

getRecord

getRecord(request): Promise<undefined | Record>

Retrieves a CNS record from DDC.

Parameters

Name Type Description
request GetRequest An object that includes the token, bucket ID, and record name to retrieve.

Returns

Promise<undefined | Record>

The retrieved record with its signature.

Example

const request: GetRequest = {
  token: '...',
  bucketId: '...',
  name: 'example'
};

const record = await cnsApi.getRecord(getRequest);

console.log(record);

putRecord

putRecord(request): Promise<Record>

Stores a CNS record to DDC.

Parameters

Name Type Description
request PutRequest An object that includes the token, bucket ID, and record to store.

Returns

Promise<Record>

The stored record with its signature.

Example

const request: PutRequest = {
  token: '...',
  bucketId: '...',
  record: { ... }
};

const record = await cnsApi.putRecord(request);

console.log(record); //