Pin

With the Pin() methods you can pin an IPFS hash on the Aleph Network. If you either prefer to upload the file by yourself refer to the Publish() methods.

Usage

Import the Store declaration to interact with the Publish function and the Item type to choose your storage location.

import { messages } from 'aleph-sdk-ts';
import { ItemType } from 'aleph-sdk-ts/dist/messages/message';

// Or used optimized import

import { Pin as pinStore } from 'aleph-sdk-ts/dist/messages/store';

Then call the pinStore function, with the required parameters as follow:

(async() => {
    const fileContent = readFileSync("./src/testFile.txt");

    const res = await pinStore({
        account: account,
        channel: 'TEST',
        fileHash: "QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j", //Hello world IPFS hash
    })
})()

Parameters

ParameterDescription

account - required Account

Account to use for signing.

channel - required string

Channel of the message. Ideally, an application would decide and use one channel.

fileHash - required string

The hash you want to Pin

APIServer - optional string

The API server endpoint used to carry the request to Aleph's network. default: 'https://api2.aleph.im'

Pin with the publish() method

You can also pin your hash by using the Publish method by sending the fileHash parameter over the fileObject one:

(async() => {
    const res = await publishStore({
        account: account,
        channel: 'TEST',
        fileHash: "QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j",
        storageEngine: ItemType.storage
        APIServer: 'https://api2.aleph.im',
    })
})()

Warning

You can't pass the fileHash and the fileObject at the same time. The hash resolution when you upload a file is made by the SDK.

Last updated