Yes, technically the _spender can take up to 999999999999999000000000000000000 of your tokens. Unfortunately, this is common practice, as it makes token transactions of this nature more user-friendly.
For example, once you have called approve() with this amount, you can now make many transactions without having to call approve() again, which technically ...
Adding a token to MetaMask (or any other wallet interface for that matter) does not "claim" the tokens. It simply tells MetaMask to look at that specific token for any balance. You can always receive tokens on your address, and add it to MetaMask later on in order to see your balance.
Eth and Btc are not tokens, they are full-fledged blockchain coins: Eth is the native asset (coin) in Ethereum blockchain and Btc is the native asset in Bitcoin blockchain.
To truly exchange an asset from one blockchain to another requires currently some centralized entity: some entity has to guarantee the trust between the blockchains. Typically this is a ...
The estimation wont work if the from account doesn't have the tokens, since the call would fail. You need to put the tokens you're estimateGasing for into the from address, or use a wallet that already has the tokens as the from address
In ERC20, you need to first approve the token for the contract providing the service.
Then you can use transferFrom function of ERC20 Token within your service contract to use the approved amount of tokens.
This explains it in more detail - https://medium.com/coinmonks/ethereum-payable-token-and-how-it-works-3bf3349a6a77
Here's how I understood the underlying questions:
"How to calculate total profit/loss on a single investment?" (Meaning by "investment" a single purchase of some amount of ERC20 token. The sum of your separate p/l's will yield your net p/l.)
"Is there an API out there that does this for me?"
I would argue that the latter is ...
You are adding a space in your function which is producing a different method signature.
> provider.eth.abi.encodeFunctionSignature('approve(address, uint256)')
If you remove the space, it should work!
Have a look at the code you shared. There's only one line with a revert. And this is also the cause for your revert. The releaseTime you send of 1599557854 is already in the past, you can use https://www.unixtimestamp.com/ for conversions.
You're currently trying to send tokens from the contract itself, rather than from _token_supplyer (which I assume is what you intended to do). The first parameter of transferFrom specifies the address to send the tokens for, so if you set it to address(this), the token tries to send tokens from the contract, but fails because you didn't set the allowance or ...
If the contract does not have a built-in way to send funds from it (like a function that will send the Ether or self destruct), there is no way to retreive the Ether from the contract. Looking at the contract code on Etherscan, there doesn't seem to be a way to do this.
I have no idea what's USDT-ERC, but if you want users to be able to buy or sell USDT with ETH as the base currency, the easiest option is to embed Uniswap on your website: