Minka Ledger Docs
How To Guides

How to manage anchor labels


Ledger SDK allows users to tag anchors with labels.

Tagging an anchor with Ledger SDK

Bellow is an example of how to set a label preferred to the anchor tel-123-usd by using the Ledger SDK.

import { LedgerSdk } from '@minka/ledger-sdk'
 
const sdk = new LedgerSdk({
    server: '<your ledger URL>',
    signer: {
        format: 'ed25519-raw',
        public: '<your ledger public key>'
    }
})
 
const { anchor, meta, hash } = await sdk.anchor.read('tel-123-usd')
 
await sdk.anchor
    .from({
        meta, 
        hash,
        data: anchor
    })
    .hash()
    .sign([{ 
        keyPair: yourKeyPair,
        custom: [{
            labels: ['preferred']
        }]
    }])
    .send()

Removing a tag from anchor with Ledger SDK

Bellow is an example of how to pull the label preferred from anchor tel-123-usd by using the Ledger SDK.

import { LedgerSdk } from '@minka/ledger-sdk'
 
const sdk = new LedgerSdk({
    server: '<your ledger URL>',
    signer: {
        format: 'ed25519-raw',
        public: '<your ledger public key>'
    }
})
 
const { anchor, meta, hash } = await sdk.anchor.read('tel-123-usd')
 
await sdk.anchor
    .from({
        meta, 
        hash,
        data: anchor
    })
    .hash()
    .sign([{ 
        keyPair: yourKeyPair,
        custom: [{
            labels: {
                $pull: 'preferred'
            }
        }]
    }])
    .send()
  • See About Anchors for more details about anchor concept.
  • See About Labels for more details about labels concept and extensive list of operations allowed for managing record labels.
  • See About Labels Policies for more details about constraining labels and uniqueness criteria

On this page