I am learning node JS developing a crypto currency exchanger as a homework project where user can deposit ERC-20 token and Ethereum. I am generating unique ethereum deposit address for every user, where they can deposit ERC-20 token and ethereum. but after sometime I want to move the received ethereum and ERC-20 token to another address (cold wallet).
If someone only send ERC-20 token to the address and no etherum, then how I'll get ethereum to pay as gas fee to transfer the received ERC-20 token to cold wallet?
If suppose, I am first paying etherum (for gas fee) from cold address to the user address, and then using that etherum to transfer received ERC-20 token, will it work at mass level ? means if 10000 users do the same thing at the same time, will not it create a problem ? or is there any better solution for this?
If there's no eth in that account, you can't take the ERC-20 token out.
Transfer some eth to the address and then get ERC-20 token out is the only way. The problem is how to save the gas as far as you can.
You can write a batch transfer contract to send eth to several hundred addresses in one go (the ceiling is determined by block gas limit), batch transfer saves gas. Then you can collect the ERC-20 tokens.
Of course, you can charge your user for compensation.
Related
I would like to have some enlightment on ERC20 token: If i create a token (let's say MTK ) to be use by a community and i send some of the tokens to each member of the community, does those members have to get ETH in order to use the MTK or they Can use the token whitout the need of having ETH?
I am thinking about using the admin address to get the necessary amount of ETH ( or other ERC20 token compatible crypto currencies) so that if that the that admin account will pay all occuring transactions fees (if needed).Therefore members won't have to deal with ETH and just use the community token.
If it is an ERC20 token on the public mainnet network, someone (else) needs to pay for gas fees executing a transaction, there is no way to circumvent gas costs on L1/mainnet entirely.
What you are looking for are "meta-transactions" or "feeless" transactions: https://ethereum.stackexchange.com/questions/38479/how-to-make-someone-else-pay-for-gas
I would like to transfer ERC20 tokens from a wallet who don't own ETH to another wallet who own ETH and who can pay gas fee.
Do you know if it is possible to made a transfer of ERC20 tokens and to let the receiver wallet pay fees ?
TLDR: Not possible, unless the token contract explicitly allows it. Or unless the token holder is also the block producer.
Transaction fees are paid in ETH (or generally, native currency of the network - for example BNB on Binance Smart Chain, MATIC on Polygon, ...). So in most cases, you need to pay ETH to execute either the transfer() function if you want to send the tokens from your address, or the approve() function if you want someone else to transfer tokens from your address.
Very few token contracts implement delegated transfer mechanism on top of the ERC20 standard. There's currently no standardized way to perform a delegated transfer, so each contract might have a different implementation. The token holder uses their private key to sign a predetermined message saying how many tokens they want to transfer to which address. The message also usually contains a nonce or a timestamp to prevent signature replay attack. Token holder passes the message offchain to the transaction sender, and then the transaction sender executes a function of the token contract built specifically for delegated transfers (note that the transaction sender pays the fee to execute this function). The contract validates the signature, and performs the transfer. Again, most token contracts do not implement this mechanism.
One more exception from the rule is a block producer. When you create a new block, you can fill it with transactions not only from the mempool but also with your own transactions. You can build a transaction with 0 gas price, and then include it in the block that you're producing. This way you're also able to send tokens for free.
I am new to the Ethereum network. I want to develop a wallet (on JavaScript and Node.js) for USDT based on the ERC20 token on the Ethereum network.
Can it be built on JavaScript and Node.js?
Also USDT is a tether-based cryptocurrency whose value is about equal to US$1. So for example, USDT on the ERC20 network works on Ether addresses. So if I send 1 ETH to that address then will it be automatically converted to current ETH value to USDT? (i.e, approximately 273$)?
I am learning Ether on Ether's documentation, so do I need anything else to learn and create a USDT and ETH wallet?
Yes, it can be built using JavaScript and Node.js.
And if you send 1 ETH (US$273) to some other address, you will receive 1 ETH, not 273 USDT. The value is not converted automatically. You'll have to exchange your 1 ETH against 273 USDT.
Everyone can create ethereum token by solidity codes but don't know how can this token integrate as payment gateway in ecommerce website.
For real project . This token need frontend web wallet /android wallet and integration to every website as payment.
Plz suggest me .how can find this way.
What need more to study.
Token is not a payment gateway. If i understand your question correctly, you are asking, how can you interact with a token that you have created through Solidity from frontend. One use case would be how people can use the token that you have created to purchase some item. For this the users should already be holding the tokens. This can be bought from an ICO or from an exchange. Basically there's a couple of functions in ERC20 token i.e., approve() and transfer() that will approve apps like exchanges to perform transactions on behalf of the owner of the token. Once the users have those tokens they can purchase items from it. Again, you have to write the logic how and what you expect users to do.
ERC20 Token is works likes Currency.And solidity is a programming language. which we used for write the smart contract. if you want to invoke your function then you need to create wallet account ,after that you can do transaction using with web3js. you can get ether for testing purpose from faucet.Basically these are functions in ERC20 token i.e., approve() and transfer() that will perform transactions
I don't suggest using ERC20 tokens as payment method.
Ethereum network is not fast enough,you need 30 confirmations to make sure you received the token, some times the delay can be 1 day
Cost is high, when you transfer token ,usually you have a smart contract, it costs lots of gas
Ether price is not stable, it drops 90% of value from Jan 2018 to Dec 2018. it will be hard for estore to maintain profit.
However if you still want to do that, yes, you can create your own gateway using tokens as your accepted currency.
Users can deposit on Binance, for example, various ERC20 tokens, but later then those tokens should be transferred to the Binance cold wallet(wallet used for withdrawing) how those tokens are transferred when the newly generated address doesn't contain any ether(for transferring contracts), it doesn't make any sense for me that Binance sends some ether for every newly generated address.
it doesn't make any sense for me that Binance sends some ether for every newly generated address.
That's exactly what they do. If you do happen to deposit ether, they will leave a little bit ~$5 or so in the address when moving the ether to their cold wallet to pay for future token transactions. If you transfer only tokens, they will transfer some ETH before moving it.