Note that you do not need to pass in "mirrorNodeUrl" but if you do, the snap will use that URL instead of the default public Hedera mirror nodes which may have rate limits associated with it.
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.
Displays an alert dialog blox on Metamask with some content.
Note that if you're connecting to the snap using MetaMask wallet(default option), metamaskEvmAddress will show your metamask wallet address and if you're connecting to the snap using an external account(importing using private key directly),externalEvmAddress will be empty.
Note that if you're connecting to the snap using MetaMask wallet(default option), the metamaskEvmAddress andhederaEvmAddresswill be different. This is because Hedera Wallet Snap creates a snap internal wallet as the snap has no direct access to the MetaMask wallet's private key.
Conversely, if you're connecting to the snap using an external account(importing using private key directly), externalEvmAddress andhederaEvmAddresswill be the same. This is because Hedera Wallet Snap has access to the private key of the external account so there is no need to create a snap internal wallet.
Live Demo on CodePen
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
deleteAllowance
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constdeleteAllowanceAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'deleteAllowance', params: { network:'testnet', assetType:'HBAR',// 'HBAR' | 'TOKEN' | 'NFT' spenderAccountId:'0.0.67890',/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
For assetType HBAR/TOKEN, you must pass the parameter spenderAccountId.
For asetType TOKEN/NFT, you must pass the parameter assetId that is either the token id or nft id.
Note that you can also call this API to delete allowance for other tokens and nfts.
For tokens, you would need to pass in additional parameters as shown below:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'deleteAllowance', params: { network:'testnet', assetType:'TOKEN', spenderAccountId:'0.0.67890' assetId: '0.0.45634'// This is token ID } } } })}
For nfts, you would need to pass in additional parameters as shown below:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'approveAllowance', params: { network:'testnet', assetType:'NFT', assetId:'0.0.57894'// This is nft ID } } } })}
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.
Calls the Hedera SDK Delete Allowance API that allows a token owner to delete allowances. For NFTs, deleteAllTokenNftAllowances is called to delete the allowances for the given NFT ID. For hbar and fungible tokens, approveTokenAllowance is called with the amount of 0 to delete the allowances.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
unstakeHbar
How to call the API from an app
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:
What the API does
Returns the transaction receipt as response
Some example responses:
For a hedera account id 0.0.4559:
Unstake Hbar Live Demo on CodePen
Some things to keep in mind while interacting with the above demo
approveAllowance
How to call the API from an app
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:
For assetType TOKEN/NFT, you will need to pass in additional parameter assetDetail that contains the following:
Note that you can also call this API to approve allowance for other tokens and nfts.
For tokens, you would need to pass in additional parameters as shown below:
For nfts, you would need to pass in additional parameters as shown below:
What the API does
Returns the transaction receipt as response.
Some example responses:
For a hedera account id 0.0.4559:
Live Demo on CodePen
Some things to keep in mind while interacting with the above demo
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 .
To learn about what it means to stake to a node vs an account, please refer to .
Retrieves the currently connected account the user has selected on Metamask. If it's the first time, a new is created and the account info is saved in snap state.
Calls the to change the property related to staking which means it will also update setDeclineStakingReward to true hence, the account will stop receiving staking rewards
If you're getting any errors with the live demo, make sure you go through the section to learn about what you may be missing. You need to install in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at .
You can also check out the to learn how each API works.
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 .
Retrieves the currently connected account the user has selected on Metamask. If it's the first time, a new is created and the account info is saved in snap state.
Calls the that allows a token owner to delegate a token spender to spend the specified token amount on behalf of the token owner. The owner can provide an allowance for HBAR, fungible(TOKEN) and non-fungible(NFT) tokens.
If you're getting any errors with the live demo, make sure you go through the section to learn about what you may be missing. You need to install in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at .
You can also check out the to learn how each API works.
constsnapId=`npm:@hashgraph/hedera-wallet-snap`awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'approveAllowance', params: { network:'testnet', spenderAccountId:'0.0.67890', amount:25, assetType:'TOKEN', assetDetail: { assetId:'0.0.45634'// This is token ID } } } } })}
constsnapId=`npm:@hashgraph/hedera-wallet-snap`awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'approveAllowance', params: { network:'testnet', spenderAccountId:'0.0.67890', amount:25, assetType:'NFT', assetDetail: { assetId:'0.0.57894'// This is nft ID all: false,// If this is set to true, it will approve all the NFTs in the above collection } } } } })}
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`consttransferCryptoAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }consttransfers= [ { assetType:'HBAR',// 'HBAR' | 'TOKEN' | 'NFT' to:'0.0.4498148', amount:1, assetId?,// You must pass in a Token ID or NFT Id for transferring tokens from?,// This can be passed if you're trying to do a delegated transfer } ]// If you're sending to an exchange account, // you will likely need to fill this outconstmemo=''awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'transferCrypto', params: { network:'testnet', transfers, memo, maxFee:undefined/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
If you pass an 'undefined' value to maxFee, the snap uses the maximum possible value as maxFee
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 asset to transfer, who to transfer to and the amount to transfer.
Calls the Hedera SDK Transfer Cryptocurrency API to transfer hbar, tokens, nfts, etc. It can also be used to do a delegate transfer if the account has another account approved to spend tokens on its behalf.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
deleteAccount
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constdeleteAccountAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'deleteAccount', params: { network:'testnet', transferAccountId:'0.0.67890',/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
Note that deleting an account is an irreversible action and the user can never re-activate it again and the user is prompted with a MetaMask dialog box to confirm their choice for additional security.
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.
Calls the Hedera SDK Delete Account API that deletes an existing account from the Hedera Token. Before deleting an account, the existing HBAR is transferred to the account defined by transferAccountId. NOTE: Deleting an account is an irreversible action.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
hts/mintToken
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constmintTokenAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'hts/mintToken', params: { network:'testnet', assetType:'TOKEN',// TOKEN | NFT tokenId:'0.0.4279119', amount:100, metadata?,// Optional param - only needed for NFT/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
You do not need to pass the amount for NFTs
You do not need to pass the metadata for fungible tokens
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, amount, etc.
Calls the Hedera SDK Mint Token API to mint new tokens for both fungible and non-fungible token (NFT) types, thereby increasing the total supply of the specified token. The new tokens are sent to the treasury account.
This action cannot be called if this token was created without passing the supplyPublicKey parameter. Furthermore, this action must also be called using the same public key account.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
hts/pauseToken
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constpauseTokenAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'hts/pauseToken', params: { network:'testnet', tokenId:'0.0.4280233',/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
You must call this API with the account that has the ability to pause. This is defined during account creation with pausePublicKey parameter.
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 Pause Token API to pause a token. A token pause transaction prevents the token from being involved in any kind of operation. The token's pause key is required to sign the transaction. This is a key that is specified during the creation of a token. If a token has no pause key, you will not be able to pause the token. If the pause key was not set during the creation of a token, you will not be able to update the token to add this key.
This action cannot be called if this token was created without passing the pausePublicKey parameter. Furthermore, this action must also be called using the same public key account.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
hts/freezeAccount
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constfreezeAccountAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'hts/freezeAccount', params: { network:'testnet', tokenId:'0.0.4280233', accountId:'0.0.1',/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
You must call this API with the account that has the ability to freeze an account. This is defined during account creation with freezePublicKey parameter.
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, accountId, etc
Calls the Hedera SDK Freeze Account API to freeze an account. It freezes transfers of the specified token for the account.
This action cannot be called if this token was created without passing the freezePublicKey parameter. Furthermore, this action must also be called using the same public key account.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
hts/updateToken
How to call the API from an app
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:
At least one optional parameter must be passed before calling this API or it will fail
What the API does
Parses the arguments that were passed
This action cannot be called if this token was created without the admin key being set during token creation. Furthermore, this action must also be called using the same public key account.
Returns the transaction receipt as response
An example response:
Live Demo on CodePen
Some things to keep in mind while interacting with the above demo
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 .
Retrieves the currently connected account the user has selected on Metamask. If it's the first time, a new is created and the account info is saved in snap state.
Calls the to update the properties of the existing token. The admin key must sign this transaction to update any of the token properties. With one exception. All secondary keys can sign a transaction to change themselves. The admin key can update exisitng keys, but cannot add new keys if they were not set during the creation of the token. If no value is given for a field, that field is left unchanged.
If you're getting any errors with the live demo, make sure you go through the section to learn about what you may be missing. You need to install in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at .
You can also check out the to learn how each API works.
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constdisableKYCFlagAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'hts/disableKYCFlag', params: { network:'testnet', tokenId:'0.0.4280233', accountId:'0.0.1',/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
You must call this API with the account that has the ability to revoke KYC from an account. This is defined during account creation with kycPublicKey parameter.
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, accountId, etc
This action cannot be called if this token was created without passing the kycPublicKey parameter. Furthermore, this action must also be called using the same public key account.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
hts/deleteToken
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constdeleteTokenAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'hts/deleteToken', params: { network:'testnet', tokenId:'0.0.4280233',/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
You must call this API with an admin account. This is the account that had created the token originally
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 Token API to delete a token . Deleing a token marks a token as deleted, though it will remain in the ledger. The operation must be signed by the specified Admin Key of the Token. If the Admin Key is not set, the Transaction will result in TOKEN_IS_IMMUTABlE. Once deleted update, mint, burn, wipe, freeze, unfreeze, grant KYC, revoke KYC and token transfer transactions will resolve to TOKEN_WAS_DELETED.
This action cannot be called if this token was created without the admin key being set during token creation. Furthermore, this action must also be called using the same public key account.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
hts/completeSwap
How to call the API from an app
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:
This API must be called within 30 minutes after initializing the swap or the transaction will fail
What the API does
Parses the arguments that were passed
Returns the transaction receipt as response
Example of how the Atomic Swap is performed
Let's assume Alice wants to swap her 1 Hbar with 10 Tuum token that Bob has(basically a peer to peer swap)
Snap creates this atomic swap transaction and sends it to the network as a scheduled transaction with a max expiry of 30 minutes
Snap returns the schedule Id for this transaction
Alice lets Bob know about this atomic swap transaction and gives him the schedule Id
Bob queries the schedule Id and verifies everything looks good
Bob calls the snap API for hts/completeSwap with the schedule Id
The scheduled transaction is executed and the atomic swap transaction is complete
An example response:
Live Demo on CodePen
Some things to keep in mind while interacting with the above demo
hts/updateTokenFeeSchedule
How to call the API from an app
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:
You must call this API with the account that has the ability to update token fee schedule. This is defined during account creation with feeSchedulePublicKey parameter.
What the API does
Parses the arguments that were passed
This action cannot be called if this token was created without passing the feeScheedulePublicKey parameter. Furthermore, this action must also be called using the same public key account.
Returns the transaction receipt as response
An example response:
Live Demo on CodePen
Some things to keep in mind while interacting with the above demo
hts/initiateSwap
How to call the API from an app
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:
Both the requester and responder must be passed
Swap cannot be initiated with the same token. So, for example, requester cannot try to swap 1 Hbar with the responder for 10 Hbar
What the API does
Parses the arguments that were passed
Returns the transaction receipt as response
Example of how the Atomic Swap is performed
Let's assume Alice wants to swap her 1 Hbar with 10 Tuum token that Bob has(basically a peer to peer swap)
Alice calls the snap API for hts/initiateSwap and as part of the parameters, she says she wants to give her 1 Hbar to Bob if Bob can give Alice 10 Tuum tokens
Snap creates this atomic swap transaction and sends it to the network as a scheduled transaction with a max expiry of 30 minutes
Snap returns the schedule Id for this transaction
Alice lets Bob know about this atomic swap transaction and gives him the schedule Id
Bob queries the schedule Id and verifies everything looks good
The scheduled transaction is executed and the atomic swap transaction is complete
An example response:
Live Demo on CodePen
Some things to keep in mind while interacting with the above demo
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 .
Before this API can be called, a corresponding API must first be called that will initialize the atomic swap between two parties
Retrieves the currently connected account the user has selected on Metamask. If it's the first time, a new is created and the account info is saved in snap state.
Uses to implement the atomic swap feature whereby the requester initiates the swap with the responder by calling the API upon which the snap sends this transaction as a scheduled transaction to the ledger. Within 30 minutes, if the respondercalls this API with the scheduleId of the transaction, the swap is complete.
Alice calls the snap API for and as part of the parameters, she says she wants to give her 1 Hbar to Bob if Bob can give Alice 10 Tuum tokens
If you're getting any errors with the live demo, make sure you go through the section to learn about what you may be missing. You need to install in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at .
You can also check out the to learn how each API works.
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 .
Retrieves the currently connected account the user has selected on Metamask. If it's the first time, a new is created and the account info is saved in snap state.
Calls the to update the custom fees for a given token. If the token does not have a fee schedule, the network response returned will be CUSTOM_SCHEDULE_ALREADY_HAS_NO_FEES. You will need to sign the transaction with the fee schedule key to update the fee schedule for the token.
If you're getting any errors with the live demo, make sure you go through the section to learn about what you may be missing. You need to install in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at .
You can also check out the to learn how each API works.
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 .
You can have multiple atomic swaps as part of the same transaction with multiple requester and responder but all the parties must call the API to complete the transaction or the transaction will fail
The responder must must sign the transaction by calling API within 30 minutes or the transaction will fail
Retrieves the currently connected account the user has selected on Metamask. If it's the first time, a new is created and the account info is saved in snap state.
Uses to implement the atomic swap feature whereby the requester initiates the swap with the responder by calling this API upon which the snap sends this transaction as a scheduled transaction to the ledger. Within 30 minutes, if the responder calls the API with the scheduleId of the transaction, the swap is complete.
Bob calls the snap API for with the schedule Id
If you're getting any errors with the live demo, make sure you go through the section to learn about what you may be missing. You need to install in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at .
You can also check out the to learn how each API works.
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constinitiateSwapAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }consttokenCustomFee= { feeCollectorAccountId:'0.0.35453', hbarAmount?,// Optional param - type number - Set the amount of HBAR to be collected tokenAmount?,// Optional param - type number - Sets the amount of tokens to be collected as the fee denominatingTokenId?, // Optional param - type string - The ID of the token used to charge the fee. The denomination of the fee is taken as HBAR if left unset
allCollectorsAreExempt?, // Optional param - type boolean - If true, exempts all the token's fee collector accounts from this fee
}awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'hts/updateTokenFeeSchedule', params: { network:'testnet', tokenId:'0.0.4535645', customFees: [tokenCustomFee],/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
Users can connect to both metamask accounts and non-metamask accounts with Hedera Wallet Snap. For connecting to metamask accounts, everything is handled automatically as snap has direct access to Metamask APIs however for connecting to non-metamask accounts, some additional flags must be passed so the snap recognizes that the user is trying to connect to an external account.
Hedera Wallet Snap lets users connect to their Hedera accounts that were created using the following curves:
ECDSA_SECP256K1: A cryptographic algorithm used for data integrity and widely used in cryptocurrencies. In this term, "secp256k1" refers to the specific parameters of the elliptic curve used, making it efficient for computations. Hedera supports this signature scheme for generating cryptographic keys and signing transactions.
ED25519: In the context of Hedera, Ed25519 is one of the signature schemes supported for the creation and verification of digital signatures. It's often used for signing transactions, as it provides a strong level of security while still being efficient to compute.
signMessage
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constsignMessageAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'signMessage', params: { network:'testnet', message:'Hello there, this is a sample message. ',/* 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.
Displays the MetaMask dialog box for the message to sign.
Signs the given message using the private key of the user.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
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.
Returns the account info currently stored within the snap state. Note that this info may not be up-to-date with the info on the ledger. If you want to retrieve the most up-to-date info from the ledger, you will need to call getAccountInfo snap API.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
getAccountBalance
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constgetAccountInfoAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'getAccountBalance', params: { network:'testnet', mirrorNodeUrl:'https://testnet.mirrornode.hedera.com'// Pass 'accountId' is useful if you want to retrieve account balance// for someone else rather than yourself accountId: '0.0.67890',/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
If you don't pass in "accountId", it will retrieve account info for the currently connected account.
Note that you can also call this API to retrieve account balance for another account Id which you do not own. Think of this as fetching the account balance of an arbitrary hedera account Id.
To do that, you would just pass in accountId like this:
This would retrieve the account balance of the account 0.0.1 from the Hedera Network Nodes.
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.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
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.
Displays an alert dialog blox on Metamask with the private key of the snap account. The user can then copy it if they like. Note that the private key is never passed to the applications and is only displayed on the dialog box.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
stakeHbar
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`conststakeHbarAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'stakeHbar', params: { network:'testnet', nodeId:0/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
You must pass in either "nodeId" or "accountId" but not both.
To learn about what it means to stake to a node vs an account, please refer to Staking Info Documentation.
Note that you can also call this API to stake to another Account Id instead of a Node.
To do that, you would just pass in accountId like this:
Note that you can also call this API to unstake your Hbar from a node or an accountId. This basically changes the account property for declining staking reward.
To do that, you would just pass in null to both nodeId and accountId
This would make it so that you stop getting staking rewards.
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.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
getAccountInfo
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constgetAccountInfoAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'getAccountInfo', params: { network:'testnet', mirrorNodeUrl:'https://testnet.mirrornode.hedera.com'// Pass 'accountId' is useful if you want to retrieve account info // for someone else rather than yourself accountId: '0.0.67890',/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
If you don't pass in "mirrorNodeUrl", the snap will query the Hedera Ledger node to retrieve the account information and this may have some costs associated with the query. In addition, the token balance would also not be retrieved as that can only be retrieved from querying a mirror node.
If you want to retrieve the complete account data and want to do it for free, be sure to pass in "mirrorNodeUrl" in your parameter.
If you don't pass in "accountId", it will retrieve account info for the currently connected account.
Note that you can also call this API to retrieve account info for another account Id which you do not own. Think of this as fetching the account info of an arbitrary hedera account Id.
To do that, you would just pass in accountId like this:
This would retrieve the account info of the account 0.0.1 from the Hedera Mirror Nodes.
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.
{"currentAccount": {"hederaAccountId":"0.0.4235873","hederaEvmAddress":"0x3ba201df50314e4702d4d92b52d304ee63bfca23","balance": {"hbars":0.75108133,"timestamp":"Wed, 24 Jan 2024 21:58:32 GMT","tokens": {} },"network":"mainnet" },"accountInfo": {"accountId":"0.0.4235873","alias":"HORADX2QGFHEOAWU3EVVFUYE5ZR37SRD","createdTime":"Mon, 11 Dec 2023 05:42:32 GMT","expirationTime":"Sun, 10 Mar 2024 05:42:32 GMT","memo":"lazy-created account","evmAddress":"0x3ba201df50314e4702d4d92b52d304ee63bfca23","key": {"type":"ECDSA_SECP256K1","key":"0380f14bf0a7c8c8c0bbae90e4f6d18b8a016fa945ec646943e8d56a1f7e4dd02a" },"balance": {"hbars":0.75108133,"timestamp":"Wed, 24 Jan 2024 21:58:32 GMT","tokens": {} },"autoRenewPeriod":"7776000","ethereumNonce":"0","isDeleted":false,"stakingInfo": {"declineStakingReward":false,"stakePeriodStart":"","pendingReward":"0","stakedToMe":"0","stakedAccountId":"","stakedNodeId":"" } }}
Live Demo on CodePen
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
HTS APIs
Transactions APIs
hts/createToken
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constcreateTokenAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'hts/createToken', params: { network:'testnet', assetType:'TOKEN',// TOKEN | NFT name:'Tuum', symbol:'TUUM', decimals:1, supplyType:'INFINITE',// FINITE | INFINITE initialSupply?,// Optional param - type: number kycPublicKey?,// Optional param - type: string freezePublicKey?,// Optional param - type: string pausePublicKey?,// Optional param - type: string wipePublicKey?,// Optional param - type: string supplyPublicKey?,// Optional param - type: string feeSchedulePublicKey?,// Optional param - type: string freezeDefault?,// Optional param - type: boolean expirationTime?,// Optional param - type: string autoRenewAccountId?,// Optional param - type: string tokenMemo?,// Optional param - type: string customFees?,// Optional param - type: TokenCustomFee/* type TokenCustomFee = { feeCollectorAccountId: string; // Sets the fee collector account ID that collects the fee hbarAmount?: number; // Set the amount of HBAR to be collected tokenAmount?: number; // Sets the amount of tokens to be collected as the fee denominatingTokenId?: string; // The ID of the token used to charge the fee. The denomination of the fee is taken as HBAR if left unset
allCollectorsAreExempt?: boolean; // If true, exempts all the token's fee collector accounts from this fee
}; */ maxSupply?,// Optional param - type: number/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
supplyPublicKey must be passed for the NFT assetType
maxSupply cannot be passed for INFINITE supply type
If you don't pass in supplyPublicKey you will not be able to mint or burn tokens
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 name of the token, symbol, decimals, initialSupply, etc
Calls the Hedera SDK Create Token API to create a new fungible or non-fungible token (NFT) on the Hedera network.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
hts/unpauseToken
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constunpauseTokenAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'hts/unpauseToken', params: { network:'testnet', tokenId:'0.0.4280233',/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
You must call this API with the account that has the ability to unpause. This is defined during account creation with pausePublicKey parameter.
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 Unpause Token API to unpause a token. A token unpause transaction is a transaction that unpauses the token that was previously disabled from participating in transactions. The token's pause key is required to sign the transaction. Once the unpause transaction is submitted the token pause status is updated to unpause.
This action cannot be called if this token was created without passing the pausePublicKey parameter. Furthermore, this action must also be called using the same public key account.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
hts/burnToken
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constburnTokenAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'hts/burnToken', params: { network:'testnet', assetType:'TOKEN',// TOKEN | NFT tokenId:'0.0.4279119', amount:100, serialNumbers?,// Optional param - only needed for NFTs and is of type Number[]/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
You do not need to pass the amount for NFTs
You do not need to pass the metadata for fungible tokens
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, amount, etc.
Calls the Hedera SDK Burn Token API to burn tokens owned by the treasury account for both fungible and non-fungible token (NFT) types, thereby decreasing the total supply of the specified token.
This action cannot be called if this token was created without passing the supplyPublicKey parameter. Furthermore, this action must also be called using the same public key account.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
getTransactions
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:
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constgetTransactionsAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }/* If you want to retrieve all the transactions for your account, transactionId can be empty */constgetTransactionsParams= { transactionId:'0.0.4228598@1706816923.997995813' }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'getTransactions', params: { network:'testnet', transactionId:getTransactionsParams.transactionId,/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}
If you pass in an empty transactionId or don't pass anything to this API, it'll retrieve all the transactions associated with your account.
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 transactionId to retrieve info for. If this is not passed, the API will fetch all the transactions for the account.
Some things to keep in mind while interacting with the above demo
If you're getting any errors with the live demo, make sure you go through the FAQs section to learn about what you may be missing. You need to install Metamask in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at template application github repository.
You can also check out the API reference to learn how each API works.
hts/enableKYCFlag
How to call the API from an app
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:
You must call this API with the account that has the ability to grant KYC to an account. This is defined during account creation with kycPublicKey parameter.
What the API does
Parses the arguments that were passed such as the tokenId, accountId, etc
This action cannot be called if this token was created without passing the kycPublicKey parameter. Furthermore, this action must also be called using the same public key account.
Returns the transaction receipt as response
An example response:
Live Demo on CodePen
Some things to keep in mind while interacting with the above demo
hts/wipeToken
How to call the API from an app
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:
You must call this API with the account that has the ability to wipe tokens from an account. This is defined during account creation with wipePublicKey parameter.
What the API does
Parses the arguments that were passed such as the tokenId, accountId, amount, etc.
This action cannot be called if this token was created without passing the wipePublicKey parameter. Furthermore, this action must also be called using the same public key account.
Returns the transaction receipt as response
An example response:
Live Demo on CodePen
Some things to keep in mind while interacting with the above demo
hts/associateTokens
How to call the API from an app
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:
Note that you can also pass in multiple token Ids to associate multiple tokens to an account.
What the API does
Parses the arguments that were passed
Returns the transaction receipt as response.
Some example responses:
Live Demo on CodePen
Some things to keep in mind while interacting with the above demo
hts/unfreezeAccount
How to call the API from an app
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:
You must call this API with the account that has the ability to unfreeze an account. This is defined during account creation with freezePublicKey parameter.
What the API does
Parses the arguments that were passed such as the tokenId, accountId, etc
This action cannot be called if this token was created without passing the freezePublicKey parameter. Furthermore, this action must also be called using the same public key account.
Returns the transaction receipt as response
An example response:
Live Demo on CodePen
Some things to keep in mind while interacting with the above demo
hts/dissociateTokens
How to call the API from an app
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:
Note that you can also pass in multiple token Ids to dissociate multiple tokens from an account.
What the API does
Parses the arguments that were passed
Returns the transaction receipt as response.
Some example responses:
Live Demo on CodePen
Some things to keep in mind while interacting with the above demo
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 .
Retrieves the currently connected account the user has selected on Metamask. If it's the first time, a new is created and the account info is saved in snap state.
Calls the to grant KYC to the Hedera accounts for the given Hedera token.
If you're getting any errors with the live demo, make sure you go through the section to learn about what you may be missing. You need to install in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at .
You can also check out the to learn how each API works.
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 .
Retrieves the currently connected account the user has selected on Metamask. If it's the first time, a new is created and the account info is saved in snap state.
Calls the to wipes the provided amount of fungible or non-fungible tokens from the specified Hedera account. This transaction does not delete tokens from the treasury account. Wiping an account's tokens burns the tokens and decreases the total supply.
If you're getting any errors with the live demo, make sure you go through the section to learn about what you may be missing. You need to install in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at .
You can also check out the to learn how each API works.
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 .
Retrieves the currently connected account the user has selected on Metamask. If it's the first time, a new is created and the account info is saved in snap state.
Calls the to associate the account with the token Ids that are passed in parameters. This works for associating both fungible and non-fungible tokens.
If you're getting any errors with the live demo, make sure you go through the section to learn about what you may be missing. You need to install in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at .
You can also check out the to learn how each API works.
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 .
Retrieves the currently connected account the user has selected on Metamask. If it's the first time, a new is created and the account info is saved in snap state.
Calls the to unfreeze an account. It unfreezes transfers of the specified token for the account.
If you're getting any errors with the live demo, make sure you go through the section to learn about what you may be missing. You need to install in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at .
You can also check out the to learn how each API works.
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 .
Retrieves the currently connected account the user has selected on Metamask. If it's the first time, a new is created and the account info is saved in snap state.
Calls the to dissociate the account with the token Ids that are passed in parameters. This works for dissociating both fungible and non-fungible tokens.
If you're getting any errors with the live demo, make sure you go through the section to learn about what you may be missing. You need to install in your browser for the live demo to work
To ease the integration of Hedera Wallet Snap on an application, we have created a template web application that you can run locally and check out the code in its entirety to learn how you can integrate and interact with various APIs exposed by Hedera Wallet Snap. Check out the full source code at .
You can also check out the to learn how each API works.
constsnapId=`npm:@hashgraph/hedera-wallet-snap`constwipeTokenAPI=async () => {constexternalAccountParams= { externalAccount: { accountIdOrEvmAddress:'0.0.12345', curve:'ED25519' } }awaitwindow.ethereum.request({ method:'wallet_invokeSnap', params: { snapId, request: { method:'hts/wipeToken', params: { network:'testnet', assetType:'TOKEN',// TOKEN | NFT tokenId:'0.0.4279119', accountId:'0.0.1', amount:100, serialNumbers?,// Optional param - only needed for NFTs and is of type Number[]/* Uncomment the below line if you want to connect to a non-metamask account */// ...externalAccountParams } } } })}