How To Guides

How to drop a wallet


Ledger SDK allows users to drop wallets.

Dropping a wallet

Bellow is an example of how to drop wallet tel:123 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.wallet
  .drop('tel:123')
  .hash()
  .sign([{ keyPair: yourKeyPair }])
  .send()

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

const record: LedgerRecord<LedgerWallet> = {
  hash: '<hash>',
  data: {
    handle: '<wallet-handle>',
    access: [
      {
        action: "<action>",
        signer: {
          public: "<public-key>"
        }
      }
    ],
  },
  luid: '<luid>',
  meta: {
    proofs: [
      {
        custom: {
          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 wallet
const dropWalletRecord = await sdk.wallet.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 dropWalletRecord.send({authParams, headers})

Constraints

  • Users cannot drop a wallet that has any balance different from 0. Those balances should be spent or destroyed beforehand.
  • All the anchors associated with the wallet should be dropped if ledger is configured

to require wallet presence when creating anchors.