hcs/deleteTopic
How to call the API from an app
Hedera Wallet Snap connects to your currently connected Metamask account by default. To learn how apps can connect to Hedera Wallet Snap using a non-metamask(external) account, refer to this documentation.
Then, depending on whether you're trying to connect to a metamask account or a non-metamask account, you can call the snap API in the following way:
const snapId = `npm:@hashgraph/hedera-wallet-snap`
const snapAPI = async () => {
const externalAccountParams = {
externalAccount: {
accountIdOrEvmAddress: '0.0.12345',
curve: 'ED25519'
}
}
await window.ethereum.request({
method: 'wallet_invokeSnap',
params: {
snapId,
request: {
method: 'hcs/deleteTopic',
params: {
network: 'testnet',
topicId: '0.0.4617270',
/*
Uncomment the below line if you want to connect
to a non-metamask account
*/
// ...externalAccountParams
}
}
}
})
}What the API does
Retrieves the currently connected account the user has selected on Metamask. If it's the first time, a new snap account is created and the account info is saved in snap state.
Parses the arguments that were passed such as the tokenId.
Calls the Hedera SDK Delete Topic API to delete a topic. Deleing a topic marks a token as deleted, though it will remain in the ledger. The operation must be signed by the specified Admin Key of the topic.
This action cannot be called if this topic was created without the admin key being set during topic creation.
Returns the transaction receipt as response

An example response:
Live Demo on CodePen
Last updated
Was this helpful?

