Are there any unconventional standards for ERC20 tokens on Ethereum? - ethereum

My question is pretty straightforward: is there anything unconventional that most of erc20 tokens have in common that I should be concerned of? For example, USDT token is Upgradable, but I doubt it's conventional. If I simply deploy an erc20 token with contract body like this:
contract SomeToken is ERC20 {
constructor() ERC20("TKN", "Some Token") {}
}
is it sufficient for it to become a cryptocurrency just as USDT or any other?

is it sufficient for it to become a cryptocurrency just as USDT or any other?
Yes

Related

How to "keep" USDT tokens inside a smart contract?

I wanted to ask if its possible to have a USDT tokens (like the standard smart contract's balance in Ether) inside my smart contract, and if it was possible to than swap it with the Ether inside the smart contract's balance (if possible using Uniswap; swapping both from ETH to USDT and viceversa).
Thanks.
Yes, it is entirely possible to store ERC20 token in any contract, since the balance of ERC20 token is only defined as a mapping of mapping(address => uint256) in the ERC20 contract.
However, since transferring ERC20 requires either you as the owner or you having the approval to transfer, you will need to give yourself, or the address executing transactions, allowance to transfer the ERC20 "stored" in the contract address, or otherwise, the ERC20 token will be stuck inside the contract.
For the swapping part, you can look into the interfaces of Uniswap and have your smart contract call to Uniswap for the swap.

Can you make an ERC1155 contract receive an ERC721 token?

I've got an ERC1155 contract and I want it to receive an ERC721 token and give other tokens in exchange for that. Can I somehow add ERC721 Receiver interface?
Yes you can do that. It would be best to start looking here at OpenZeppelins documentation on it: https://docs.openzeppelin.com/contracts/2.x/api/token/erc721#IERC721Receiver
In your method that accepts ERC721 tokens, you will need to make sure that the sender approves your contract to transfer tokens on their behalf or else the transaction will fail.
In conjunction with IERC721Receiver you have to use the safeTransferFrom method for this to work properly.
hope this helps.

How to approve Token to self-deployed contract

My ultimate purpose is to swap some tokens across pancakeswap babyswap apeswap atomicly. So I build a contract(called ContractA) to run a bunch of swaps in a transaction. I transfer some USDT token into ContractA. But ContractA is not approved to transfers USDT by the USDT contract.
I known how to approve Metamask address to transfer USDT, but how to do it for a Contract?
In order to control an ERC20 token from a smart contract, first you need to create an instance of it. To do that, first you need to import ERC20 to your contract, and then just create an ERC20 type function giving it the token address you want to manage. It would be something like this:
// Some code...
import "#openzeppelin/contract/token/ERC20/ERC20.sol";
// Some more code...
contract exampleContract {
// Example of an ERC20 token instance
ERC20 USDTToken = ERC20("USDT Contract Address Here");
// Approve USDT
USDTToken.approve(address(this), _amount);
}
Then you will be able to manage the token, always following the ERC20 standard, as you want.
Hope you find this information useful :)

Can a normal ethereum address receive an USDC token?

I want to receive some USD coin, for this special wallet is required or can any ethereum address receive it?
Yes, it is possible as USDC follows the ERC20 standard, so you don't need a special wallet for it.
ERC20-tokens have an "abi", which defines the functions that ERC20-tokens use. The abi on https://etherscan.io/address/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48#code is for a Proxy Contract and is not ERC20 compliant, as it does not define a "transfer" function.
To still be able to send USDC tokens from an address, you simply gotta define the transfer function in the abi when creating the transaction. You could even just take the minimal ERC20 abi and delete the USDC abi altogether.

Sending tokens from Ethereum ERC 20 smart contract

As the title suggests - is it possible to send tokens from an ERC20 smart contract address, or is this unit not accessible?
Practical explanation:
A noob misunderstands some instructions and sends some tokens instead to his address to a smart contract address erc20. Is it possible for the programmers of the tokens, to recover those tokens, or are their hands "tied" and none has access to those tokens anymore?
Both contract accounts and external accounts (controlled by humans) have all the same inherent powers. Each can do what the other can.
If you send some ERC-20 token to a contract, it can in theory send it elsewhere, providing it has that functionality already built into-it.