How to check if token has transaction charge(i.e token is deflationary) - ethereum

Before making a transaction via web3 i wanted to check if token is deflationary. Do we have any common method for erc20 token contracts to check whether they are deflationary or not. I checked the abi for several defalationary tokens but thay don't seem to have any common method amongst them

There is no standard that would define a general way to recognize a deflationary token.
The logic can be processed in many ways:
Part of the transfer() and transferFrom() functions
A separate burn() function
executable by an authorized address
executable by each token owner allowing them to burn their own tokens
can use any name - burnFrom(), removeTokens(), lowerSupply(), ...

Related

Multiple ERC20 tokens in a DeFi platform

I'm building a DeFi application on Ethereum, and I would like to implement the Deposit function. Everything works fine between ETH and a ERC20 token that I built, but I would like to add some tokens like aToken for AAVE or cTokens for Compound that the user will receive after a Deposit call.
So the question is: is it possible to add a function in my smart contract to create multiple tokens without creating a smart contract for each of them? If not, I have to create a different contract for each token I want to add in my app or there is a best method to do it?
Yes this is possible. You can transfer the tokens to the user's address after the Compound Protocol mint operation. This can be made generic using the ERC-20 transfer interface. Be sure to account the amounts users are due and beware of the reentrancy vulnerability.

ERC-721: How to determine which Tokens an Address Own

If you are using the ERC-721 standard, what is the prefer method determining which tokens the address owns in a DAPP.
Currently I'm request all the Transfer Events for an address and basically sorting them into transfer in and transfer out, and then using that to determine which tokens the user owns.
Is there a simpler way I missed.
Transfer events may be emitted also by contracts that are not ERC-721 tokens, or some noname tokens that you might not be interested in.
The actual token ownership is stored in the tokens contracts (and not the DAPP contract).
So your current approach is pretty much as straightforward as it can get, if you want to automatically keep track of all tokens that the address currently owns (and some false positives as well).
Note: This is also similar to the approach of Etherscan, which listens to all Transfer event logs and if the sender contract is listed in their database of tokens, they use the event log data to update balances of the sender and recipient.
If you're willing/able to create and maintain a list of tokens that you want to follow, I'd recommend a simpler approach:
Define the list of followed token contract addresses (e.g. ECF or RARI)
For each of these token contracts, call balanceOf(<your_dapp_address>) that returns amount of tokens that the <your_dapp_address> currently owns.

How to make automatic LP providing after time lock

I am learning solidity and want to create a contract that will lock token for Uniswap LP. What I've created is:
List item
on token creation I am creating uniswap pair with that token
I am creating a Timelock for token amount assigned to creator address
now on release() method I would like to automatically add liquidity with eth value that has been sent and token that was locked
Problem here is that to add LP to uniswap token needs to be approved and from what I see the only way to approve token is to first send this token to creator address.
Is it possible to make it automatic so that we don't need to trust contract creator to add LP after it has been released to him?
You can have non-standard ERC-20 token that allows perform approve for Uniswap contract addresses on special conditions (e.g. before a certain time or similar).
You would directly update allowances table in your token. You do not need to use approve() from ERC-20 because it is your token.

Can I stop someone from transferring an ERC-721 token based on the smart contract I created?

I do not have much experience with Solidity programming. I want to create a smart contract for a new digital asset, say Cryptodoggies. I want to know if there is a way to prevent users from being able to resell/transfer their cryptodoggies.
You could have a variable (boolean I think would be more suitable) on your contract and use it in an access modifier for the transfer function so that the transfer function would require for this variable to be true. Then by making this variable false (by a function accessible only to you) you can stop users from transferring coins. Of course, this modifier would have to be used for every function that enables users to transfer tokens.
It would be something like that pausable ERC-20 from openzeppelin. You can find it here.

ERC20 token , transferfrom crashes , what would be the consequences?

We have created an ERC20 token for TGE/ICO .
In our testing we have found that transferFrom function does not work and crashes
rest all the functions are working properly . the tokens are already deployed on mainnet
what impact will this have apart from user not able to transfer on someone's behalf ?
Also will this impact later when the token comes on exchange in anyway ? or user is only going to use transfer function?
What do you mean by "crashes"? Are transactions rolled back and the resulting state correct or are tokens lost/irretrievable as a result of using the function?
Either way, as a user I would not want to purchase your token. If one of the ERC20 functions doesn't work properly, I certainly wouldn't have trust that the contract is secure. The impact will be that you will have irate customers who won't want your token. Users will expect to be able to use the transferFrom function since you're advertising your token as an ERC20 compliant token. I'd also think that no exchange will accept your token.