I just finished reading which explains how to build a Dapp with Metamask sending Ethereum to a smart contract (Reference: https://medium.com/@merunasgrincalaitis/the-ultimate-end-to-end-tutorial-to-create-and-deploy-a-fully-descentralized-dapp-in-ethereum-18f0cf6d7e0e). Metamask doesn't seem to support ERC20 tokens, so how can you transfer these ERC20 tokens within a Dapp instead of Ether?
[Ethereum] How do Dapps work with ERC20 tokens
dappserc-20
Related Solutions
This is non-trivial, although possible.
Architecture with a separate account isn't the problem per se. (The DAO had it to separate income from current holdings, as I understand it.) The main issue is that you can't simply iterate through every token holder, or you'll hit the block gas limit after enough token holders. (The question you linked to is about this.)
The pattern more commonly used, withdrawals, is where the user specifically asks for money, and at that time the contract pays them. While this makes sense in most situations, such as an auction contract where the users have individual balances, what does it mean if rewards accumulate to tokens? Is the reward calculated when the user withdraws, based on the time since last withdrawal? Then an attacker withdraws, sends tokens to another address, and repeats.
I am not sure exactly how the DAO avoided this, as I did not understand the math involved. Which leads to the following point.
Security-wise, there's all sorts of small mistakes that can lead to disaster. Notably, The DAO heist itself was due one such small mistake in this category... in withdrawRewardFor()
as it happened.
The DAO had expert programmers and a paid security audit, and they still missed this. I would be incredibly cautious about this entire area. I'm not saying it's impossible, just risky.
Status is a good start to develop a Ethereum mobile dapp.
Status is an open source messaging platform and mobile browser to interact with decentralized applications that run on the Ethereum Network.
Decentralized Apps at your fingertips: With Status your mobile device becomes a light client node on the Ethereum Network, enabling you to access Ethereum’s entire ecosystem from anywhere.
Smarter private messaging: Status is more than a messenger. Send payments and smart contracts to friends from within chats, and enjoy encrypted messaging by default, using a peer-to-peer protocol that doesn’t rely on centralized servers.
Status app (Ethereum Mobile gateway) is currently in alpha and can be tested on Android and iPhone.
Please find below a quick tutorial how to deploy a dapp on Status.Let's imagine you have a dapp (ReactNative, Ionic, ...) running on {DAPP_URL}
Download Status on your phone and configure an account
Install status-dev-cli
npm i -g status-dev-cli
In status console, enter
/debug
. That will give you your device IP address {DEVICE_IP}From your machine, make sure you can see you device and status:
status-dev-cli scan
(status must be running)Last step, consist in registering the dapp in status:
status-dev-cli add "{\"whisper-identity\": \"my-dapp\", \"dapp-url\": \"{DAPP_URL}\", \"name\": \"MyDAPP\"}" --ip {DEVICE_IP}
You can now refresh you status app and you will see appear MyDapp in the list. The browser will launch you dapp and it can interact (web3) with the Ethereum blockchain and smart contracts.
By default, status run on the testnet network. You can switch to another node (private, testrpc or mainnet) with the following command status-dev-cli switch-node {NODE_URL} --ip {DEVICE_IP}
Documentation: Here
Some examples: Me and other devs have recently attended to the Status hackaton. This blog post (Winners Announcement) will illustrate some of the projects developed in a one-week period.
Best Answer
A dapp is only an user interface that let the user easily interact with the contract. You could just make a nice UI and use an ERC-20 token, no need to create another contract if your goal is letting people use an ERC20 token (transfer, check balance etc)