How To Guides

How to drop an anchor


Ledger SDK allows users to drop anchors.

Dropping an anchor

Bellow is an example of how to drop 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>'
    }
})

await sdk.anchor
    .drop('tel-123-usd')
    .hash()
    .sign([{ keyPair: yourKeyPair }])
    .send()

You can also drop an anchor by passing the ledger record you want to delete, in cases where you have fetched it before.

const record: LedgerRecord<LedgerAnchor> = {
  hash: '<hash>',
  data: {
    handle: '<anchor-handle>',
    wallet: '<wallet>',
    target: '<target>',
    symbol: '<symbol>',
  },
  luid: '<luid>',
  meta: {
    proofs: [
      {
        custom: {
          luid: '<luid>',
          moment: '<moment>',
          status: '<status>',
        },
        digest: '<digest>',
        method: '<method>',
        public: '<public-key>',
        result: '<result>',
      },
    ],
    status: '<status>',
    moment: '<moment>',
    owners: ['<owner>'],
  },
}

// Initialize a drop record builder for the anchor
const dropAnchorRecord = await sdk.anchor.drop(record).hash().sign([{ keyPair: yourKeyPair }])
/**
 * Send the DELETE request to the backend.
 * Optionally, you can pass authParams and headers to the send method.
 */
const response = await dropAnchorRecord.send({authParams, headers})