@cere-ddc-sdk/ddc / DagApi
The DagApi
class provides methods to interact with the DDC DAG API.
Example
import { DagApi, GrpcTransport } from '@cere-ddc-sdk/ddc';
const transport = new GrpcTransport(...);
const dagApi = new DagApi(transport);
▸ getNode(request
): Promise
<undefined
| Node
>
Retrieves a DAG node from DDC.
Name | Type | Description |
---|---|---|
request |
GetRequest |
An object that includes the access token and the CID of the node to retrieve. |
Promise
<undefined
| Node
>
The retrieved node as a Node
object, or undefined
if the node does not exist.
Example
const request: GetRequest = { token: '...', cid: '...' };
const node = await dagApi.getNode(request);
console.log(node);
▸ putNode(request
): Promise
<Uint8Array
>
Stores a node in DDC DAG.
Name | Type | Description |
---|---|---|
request |
PutRequest |
An object that includes the access token and the node to store. |
Promise
<Uint8Array
>
The CID of the stored node as a Uint8Array
.
Example
const request: PutRequest = { token: '...', node: { ... } };
const cid = await dagApi.putNode(request);
console.log(cid);