Bscscan or metamask API to check how much USDT is sent based on Transaction Hash - api

We are trying to look for an API on either Bscscan or metamask to check the value of USDT sent directly from metamask. We have tried the docs from bscscan but they only show BNB values, we are trying to check transfers that involved BEP-20 USDT.

Related

Checking that nft is selling on opensea

I want to know some information using Opensea API that some NFT token is selling, but can't find info which api method can give so data. I tried to use events api method which displays all events info of token but can't find the difference between token which is selling and not. For example on the first picture token is selling, on the second one the token isn't
You can use opensea's api call retrieve assets. This will give you information about an asset and whether or not it is currently listed. As long as you have an api key, it will tell you if the asset is listed, and the details of that order. Hope it helps!

Etherscan API: get the list of the Non-Fungible Token Transfers with API

this https://etherscan.io/tokentxns-nft can be a good example of what I would get from Etherscan API, a list with all the transfers related to a specific NFT collection. Moreover, I would include the ETH exchanged for every transfer, a list of target fields below:
Txn Hash
Age
From
To
TokenID
Token
ETH value exchanged in this transfer
is there any API in Etherscan that can let me collect that information?
You can use this API endpoint for Ropsten Network. It will provide you all the details with tokenID and other requirements you listed above.
https://api-ropsten.etherscan.io/api?module=account&action=tokennfttx&address=<your_Contract_Address>&startblock=0&endblock=latest&sort=asc&apikey=<your_API_key>
I am using Ropsten API because my contract is deployed on Ropsten Testnet. You can adjust block with your starting block.

what's the purpose of the approve function in erc 20

I'm new in solidity and erc20, so I read ERC20 description on the openzeppelin and find this function which isn't clear for me.
approve(spender, amount)
What's the purpose of allowing to the spender spend my token, instead of send my tokens to the spender directly?
You can change the approved amount or revoke it altogether (only the unspent amount). But you cannot take back an already sent transfer.
A common use case for the approve() function is trading on a DEX (decentralized exchange). You approve the DEX contract address to spend your USDT tokens for example. And when you want to buy an XYZ token (against USDT), the DEX simply pulls the already approved USDT from your address and sends you the XYZ tokens.
Approve is a function used to give permission the spender can be anyone an exchange or EOA to withdraw as many times from your token contract up to the _value.
You can check this reference here
As others said, Approve function can give permission to the spender to pulls the amount of token in your address. It can be used in: DEX (decentralized exchange) or in Custody services.
In custody services, after you approve the custody provider to take your token, whenever your wallet receives token, the custody provider is able to transfer your token into some internal wallets and keep them save for you. (It's just like how the traditional banks work)

Verify user is owner of an NFT via MetaMask connection? Make sure connected users public eth address is the same as of the NFT?

I need to verify on my own domain/server the user which has connected his MetaMask wallet is the owner of a specific NFT in order to allow him special functions? Basically, I want to give the user access to an area that only the owner of this NFS would have.
My original NFT is sold in opensea but I can't use the opensea hidden-area option to just give the user a hidden password since the next owner (after reselling) and the old owner would have the same password and old owners could still access like this. But I need that only the current owner has access.
My user/visiter can already connect with MetaMask at my own domain and I get the public ETH address of the active account but since this is only javascript and my backend is PHP I can't just post the MetaMask info to my PHP backend since this would be easy to trick/hack.
How can I make sure the current connected MetaMask Account is the same as the NFT owner (which I know) and allow to access a URL only for this user?
My current state is that the user connects his MetaMask and I use opensea API to check who is currently the owner of the NFT. I can compare both eth addresses but the flaw in this is obviously that I use ajax to send the MetaMask public address to my backend which is only for testing since this is of course zero save!
Thank you in advance for any idea, help, tip I can get.
PS: My backend is PHP
After hours and days of researching, I found a solution that works for me.
Here are the needed steps.
Use the MetaMask API to let the user connect with your site. This is pretty easy and good explained in the MetaMask API.
Once you want to verify the MetaMask owner is the legit owner of an NFT you need first query OpenSea (or another place) the current owner of the NFT. In my case, I use the OpenSea API for my specific NFTs. Once you got the owner you are ready to verify.
On your site you need to ask the user to sign a custom message with MetaMask. There are different options to do that. More about this here: MetaMask Signing. I send for example a short text message with a unique code that I first created in my PHP Backend. Doing that I also save the code and custom message into my MySQL.
Once the user has signed you get the signing code which you can send back to your PHP backend via ajax etc. without a problem. Only the owner of the Account which you requested in the signing code is able to sign with the correct account.
Once you got the signing code in your PHP Backend you can use Fast Elliptic Curve Cryptography in PHP and php-ecrecover to check the code against the unique code you created before and the message the user signed. As a response, you get the Signer Account ETH Address and you are ready to compare. If the Signers ETH Address is the same as the NFT owner you are ready to go and you can consider the signer the owner of the NFT.
I believe this is safe to use but I am not an expert on that. In my case, this only authorize an NFT owner for a certain closed area in my community page and there are not really high risks involved but maybe somebody raises some security thoughts on that. However, I found that other NFT pages and even Opensea work similarly.
I hope this points someone in the right direction, I lost quite some time figuring this out because most solutions are Node.js etc. but not with PHP backends.

How can I receive a payment notification when I receive Bitcoin in a wallet on Coinbase?

I am building a bitcoin payment processor based on Coinbase. I will receive Bitcoin from end users.
Coinbase lets wallet owners receive notifications of various events via a webhook.
Which event will be generated when a user sends Bitcoin to my Coinbase wallet addresses?
And how can I know from that notification webhook whether the transaction has been confirmed or not? If confirmed, how many times it has been confirmed?
I know there are transaction APIs, but I also need a response from the webhook, because this information is important.
I have got clear understanding after making payment.
I thought Coinbase will call my webhook each time when transaction get confirmed, But they call only once.
And the event responnsible for new payment is wallet:addresses:new-payment. Which is available in their post data
{"id":"5a6956f9-94bb-5c15-99f3-a90347674","type":"wallet:addresses:new-payment" ....