Here's an intuition. The simplest transaction in Ethereum costs 21000 gas and looks like this:
{from: '0x from', to: '0x to', value: web3.toWei(1, "ether")}
When you're depositing to
the exchange, the exchange can watch for transactions that are sent to
this deposit address. For example, for block 99 they could use web3.eth.getBlock(99, true, ...)
, and for each transaction object check if to
equals the deposit address, and the value
(amount of Ether in wei) that was sent. Relatively straightforward for the exchange to see what you've deposited.
But if you are using a contract to make a deposit, the to
is no longer the deposit address that the exchange gave you. The to
is the address of your contract, and in the transaction there will be an additional data
field. This data
provides instructions to the contract, to execute code, which may then transfer the Ether to the deposit address. The exchange has to also execute the code, if it wants to be sure that it received funds from such execution. (An exchange could use web3.eth.getBalance to monitor balances of deposit addresses, but if it wants to know exactly where the funds came from, it has to execute the code of all transactions.)
That's an overview and to read more, the Ethereum Wiki has links to other material such as the Yellow Paper, and White Paper. Reading this StackExchange for highly voted questions and answers, with tags like transactions and gas is also helpful.
Technically, transactions are only initiated by humans: a contract invoking another contract is a message call
(as defined in the Yellow Paper) not a transaction. Only the transaction is recorded on the blockchain because all further execution can be derived from the transaction.
For why withdrawing from an exchange to a contract wallet/account is not straightforward, it's because more gas is needed than the basic 21000 gas. Different contracts could consume different amounts of gas, and sufficient gas must be provided by the exchange otherwise the transaction does not take effect: the funds remain will remain with the exchange.
It's completely possible. If the exchange creates a separate contract for ERC-20s for each user, they can know when that user deposits an ERC-20. They'd likely then send all the tokens to a central wallet, and keep most of it in cold storage of course.
The sad thing about the ERC-20 standard is that there's no way to trigger code on deposit of an ERC-20, e.g. yes I can send ERC-20 to the contract that the exchange created for me, but that contract can't automatically forward the tokens to another contract in the same transaction. Of course the exchange can just detect when it receives tokens and create another transaction to move the tokens. This is the main purpose of the ERC-223 standard that is in the works, allowing a tokenFallback function to execute if the receiving function is a contract and implements tokenFallback.
Best Answer
Tether.to is building Ethereum(ERC20) based tether. Which is always begged back to real fiat deposit. 1 USD Tether is always equal to 1 USD. I think Every currency should follow the USDT and build fiat tether. I'm building Rupee tether. Advantages of ERC20 Tether is, we can use existing Ethereum smart contract platform. The potential is so huge.
Recebt blog about ERC20 tether