hashgraph / hedera-smart-contracts

Contains Hedera Smart Contract Service supporting files
Apache License 2.0
39 stars 53 forks source link

HTS NFT is still not compatible with Metamask. #634

Closed yonac1 closed 7 months ago

yonac1 commented 10 months ago

Description

HTS NFT is still not compatible with Metamask. I'm trying to send an NFT through HTS to a Hedera Testnet Metamask wallet, but then the NFT shows it to me as a Token in the token list tab inside Metamask instead of under the "NFTs" Tab and it says in the MetaMask "No NFTs yet" I already associated the nft token id

2023-12-14_-17 29 29 2023-12-14_-17 31 11

Steps to reproduce

  1. send an NFT through HTS to a Hedera Testnet Metamask wallet.
  2. NFT shows it to me as a Token in the token list tab inside Metamask instead of under the "NFTs" Tab.

Additional context

No response

Hedera network

testnet

Version

v2.25.0

Operating system

Linux

Nana-EC commented 9 months ago

Thanks @yonac1 for the ticket. We'll take a look and circle back.

Could you aid troubleshooting by providing your token id on tesnet. Thanks

AlfredoG87 commented 8 months ago

@yonac1 how did you add the NFT Token to MetaMask?

Did it auto appear? did you used Hashscan to associate and add token?

I ask, since I was able to add an NFT Token manually using MetaMask, however when doing it trough HashScan, it indeed was added on the ERC-20 Section.

Image

AlfredoG87 commented 8 months ago

@Nana-EC this seems to be an "issue" with Hashcan and how is it adding tokens to Metamask, when adding tokens to metamask, is done using the method wallet_watchAsset and params, see example:

      type: 'ERC721', // could be ERC20 or ERC721, maybe also ERC1155
      options: {
        address: tokenAddress, // The address that the token is at.
        symbol: tokenSymbol, // A ticker symbol or shorthand, up to 5 chars.
        decimals: tokenDecimals, // The number of decimals in the token
        image: tokenImage, // A string url of the token logo
      },

But taking a look at the hashscan explorer, it looks like is sending always ERC20 on the type field of the params.

see here.

yonac1 commented 8 months ago

Thanks @yonac1 for the ticket. We'll take a look and circle back.

Could you aid troubleshooting by providing your token id on tesnet. Thanks

Yes it is: 0.0.6751279

yonac1 commented 8 months ago

@yonac1 how did you add the NFT Token to MetaMask?

Did it auto appear? did you used Hashscan to associate and add token?

I ask, since I was able to add an NFT Token manually using MetaMask, however when doing it trough HashScan, it indeed was added on the ERC-20 Section.

Image

I had to add it manually, it shown on my balance that I have 1 PBL on HashScan even though It's an NFT, I want to see it in the NFT Tab, I associate the token with ethers like this:

const provider = new ethers.providers.Web3Provider(window.ethereum, "any"); const signer = provider.getSigner(); const abi = [function associate(),function dissociate()`]; const nftAddress = "0x" + TokenId.fromString(process.env.REACT_APP_NFT_TOKEN_ID) .toSolidityAddress() .toString(); let txHash; const gasLimit = ASSOCIATE_GAS_LIMIT;

const myContract = new ethers.Contract(nftAddress, abi, signer);
const associateTx = await myContract.associate({ gasLimit: gasLimit });
const associateRx = await associateTx.wait();
txHash = associateRx.transactionHash;`

When sending it to a metamask wallet which associate it in that way it doesn't get into the NFT Tab

yonac1 commented 8 months ago

@AlfredoG87 this is what happen when i'm try to import the NFT

image
quiet-node commented 8 months ago

Hello @yonac1, we appreciate your time and effort to open up this ticket, and sorry for this late response! Good thing this will now be my main priority.

it shown on my balance that I have 1 PBL on HashScan even though It's an NFT

On Hashscan, specifically on the Account Detail page, balances is the section where all your tokens (both fungible and non-fungible) are displayed. The balance displayed on HashScan showing "1 PBL" indicating ownership of 1 token with the symbol PBL. By clicking on the 'PBL' symbol, you'll be directed to the Token Detail page, where you can learn more about the token, including its type (non-fungible in this case), keys, expiration, and other details.

I associate the token with ethers like this:

const provider = new ethers.providers.Web3Provider(window.ethereum, "any"); const signer = provider.getSigner();

const abi = [function associate(), function dissociate()`];

const nftAddress = "0x" + TokenId.fromString(process.env.REACT_APP_NFT_TOKEN_ID) .toSolidityAddress() .toString();

let txHash;

const gasLimit = ASSOCIATE_GAS_LIMIT;

const myContract = new ethers.Contract(nftAddress, abi, signer);

const associateTx = await myContract.associate({ gasLimit: gasLimit });

const associateRx = await associateTx.wait();

txHash = associateRx.transactionHash;`

Excellent! That's exactly how you associate a token using the HIP-719. However, we have good news – manual token association is no longer necessary. HashScan now allows users to connect their wallet directly to the platform, enabling them to associate and add the token to Metamask effortlessly.

For your specific case, follow these steps:

  1. Click on the 'Connect wallet...' button in the top right corner.
  2. Choose Metamask as the wallet provider.
  3. Click 'Connect' and switch the wallet to the current network (testnet in this case).
  4. Choose the right account to connect.

After connecting, you'll notice a button labeled 'Import to Metamask' next to the token address within the Token Detail page. It will look like this image

image

Click on this button, and it will prompt you to associate the token with the connected account. Additionally, it will ask if you want to add the token to Metamask.

As Fredy has mentioned about this issue above, by clicking the Import to Metamask button, it will only add that token to the Tokens tab but not NFTs. I have created a ticket on Hashscan already and will push in the fix soon.

this is what happen when i'm try to import the NFT image

I notice you're attempting to manually add the NFT to your Metamask. However, based on the provided picture, it seems there might be confusion between the Token ID and Token Address. Let me clarify:

The Token ID represents the unique identifier (or Serial Number in HTS) of the specific token you own. Follow these steps to find the Token ID for your owned token:

  1. Visit your Account Detail page on Hashscan.
  2. In the 'Balances' section, locate the 'Show all tokens' button. Clicking it will redirect you to the 'Account Balances' page, displaying all fungible and non-fungible tokens you own.
  3. Identify the token you want to check for the Serial Number, and click on it. This will lead you to the account collections page, where you can find the Serial Number associated with that token.
  4. Now, in Metamask, go to the NFTs tab and click on 'Import NFT.'
  5. Input the token address in the 'Address' text box and the Serial Number you just found in the 'Token ID' text box.
  6. Click 'Import,' and you'll see your NFT successfully imported into Metamask.

If you still have any question, please don't hesitate to ask!

P.S. Our Testnet recently underwent quarterly maintenance, resulting in a complete reset of the entire Testnet network. All tokens have been wiped off, and all accounts have been updated with new account IDs and keys. We recommend revisiting your Hedera Portal to review and verify your account information.

yonac1 commented 8 months ago

Thanks for the answer @quiet-node , quick question, In Hedera Mainnet, are the users will have to also import manually the NFT as you mentioned or it will automatically will be in their NFT Tab inside the metamask wallet just like on HashPack or on Ethereum Network on Metamask. and if it manually, are you doing something about it? Customers that using Hedera Metamask inside our dapp can't see their NFT on their wallet Tab as I mentioned.

quiet-node commented 8 months ago

Hi @yonac1, appreciate your prompt response! Currently, within the Hedera ecosystem, the only automated method for importing tokens into Metamask is through Hashscan.io (the Mirror-Node Explorer). Presently, this process is designed exclusively for ERC20 tokens, leading the Mirror-Node Explorer to incorrectly categorize NFTs as fungible assets in your wallet. I've documented this issue in a new ticket on the Mirror-Node Explorer repo. I'm actively collaborating with the Mirror-Node Explorer team to address this, and the fix will be implemented soon. Once resolved, you and your DApp users won't need to manually import tokens; they can simply visit Hashscan to accomplish this.

Moreover, your team has the option to incorporate a similar importing tokens flow directly within your DApp using Metamask's wallet_watchasset feature. For more details, please refer to the official documentation. If your team finds this approach appealing, it offers an additional avenue for a seamless token import experience.

yonac1 commented 8 months ago

@quiet-node Thank You Very Much!

quiet-node commented 8 months ago

@yonac1 you're very welcome! We are working on this problem and we will push in the fix soon!

quiet-node commented 7 months ago

Hello @yonac1, in this PR the mirror-node-explorer team and I have successfully fixed this bug. You can now associate, dissociate tokens (fungible and non-fungible). You can also import the tokens into your wallets. A couple of notes:

Again, thanks for your time opening this ticket! Please feel free to let me know if you have any questions!