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

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.

Related

How to get the Total Supply of Tokens from BscScan (API) as a number only

The current API in BscScan provides this endpoint: https://api.bscscan.com/api?module=stats&action=tokensupply&contractaddress=0x1443bA071482a6Ba6062884939e45fFeD44e03e6&apikey=9P19798YXKRSGAIZTKF5YH6WWKZP2X9JN2
This results in this {"status":"1","message":"OK","result":"5000000000000000"}
Coinmarketcap wants a number only, they want to see 5000000000000000
How would I write the endpoint to provide only 5000000000000000 without the other data?
I have read up but found nothing.

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

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.

How do I modify my smart contract code so I'm the only one who can sell tokens? Everyone else send their tokens to me to exchange for either ETH, etc

So I have a token that has about 103 users. What I need to do is restrict the ability to sell those tokens to just myself the developer, so the other users can redeem their tokens for ETH or MATIC by sending to me. The alternative would be to just write a new smart contract, including this function and moving all users to the new platform. How would I write that new contract?
The first, you can't change code of deployed contract in Ethereum.
The second, look at ERC-20 and ERC-721 (NFT) standarts, its already have functionality you need.

About Solidity Transferfrom and Approve Functions

I actually need a very simple smart contract using the following functions "transferfrom" and "approve".
I just need a smart contract that will be able to request approval to spend a token ( example -- bake ) from a wallet if the user calls the "approve" function.
It will also be able to withdraw the particular token from the user's wallet to the "address to" set by the contract's onwer, if the onwer calls the "transferfrom" function.
There's a design limitation of the ERC20 standard that disallows approval through a contract in between.
The user always needs to invoke the approve() function on the token contract directly - not through your contract.

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)