Can't one side still cheat on the trade though? Since both people in the trade are able to call the swap() function and only one signature is needed, couldn't I just tell the other person to give allowance to the TokenSwap smart contract first. Then I can come in and just call swap() and put 0 as my amount and then whatever allowance the other person gave for the other amount? I do not know if I am missing something, just want to be sure. If this is the case, I believe this could be fixed requiring both parties to sign on the swap() function. Let me know! Thanks for the great videos by the way!
Yes you are absolutely right! This is a bug. I've fixed the code by setting the trading amounts inside the contract. Here is the code solidity-by-example.org/0.6/app/erc20/
Hi sir i created erc20 tokens in gnosis, i need to bulk swap them for usdt , i don't know how to do it, if you help me i can pay thcv2 - a erc20 token i minted in gnosis chain and has liquidity in honeyswap.
by doing and giving the same parameters as you the code is showing token 1 allowance is less on swap why is this happening I have used the mytoken code and tokenswap same as in the description link
😍 this is supper cool stff !!! Token Swap is a very simple yet effective and creditable fuction !! It is almost like central clearing house in financial instructment trading ✨ Thanks so much !!
Why it shows in allowance that I have allowed the other acc to trade my tokens, but when i try to use the transferFrom function, it says that - amount exceeds allowance.
Hello , please i have a problem , i have 1 token erc20 THR , but i couldint to sell or trade , i want to serach solution to sell my Erc20 , can you give a solution please. Think you .
@@bchiniomar383 Thank you for watching, for question, guidance and support at anytime. Just DM +1.(4 .2 .3). 4 . 3 . 0 . 6 . 9 . 8 . 4 @ W H A T S A P..
Okey okey, so hear me out... is the approval of spending coins revocable? Because if it was (e.g.) Bob calls swap() once both approved but then revokes his approval while the swap() function is still executing the first transaction -> and then the function is failing to transfer from Bob to Alice? Even though in practice this would be really hard to achieve, is it in theory possible? And if it is couldn't you prevent it this way: Alice sends the money to the contract and the exchange rate (she sends 10 AliceCoin and wants to receive 20 BobCoin) then Bob does the same (he sends 20 BobCoin and wants to receive 10 AliceCoin). After that the contract has the coins stored and sends them both their fair share. Just a thought. Your videos are really great and you make me really want to dig deeper into smart contracts!
Given that the token contract is not malicious, no bug, etc... Attack probably won't work 1. EVM is sequential. Only one transaction is executed at a time. 2. swap is atomic. if any transfer fails the whole swap will fail. Revoking while swap is executing will fail because of 1. Revoking right before and or after swap is impossible from 2. Unless the token contract is malicious or faulty. In that case hack is probably possible.
@@smartcontractprogrammer noted, maybe I'll create another smart contract & pass all the constructor parameters into the swap method instead so I can reuse the same contract.
@@smartcontractprogrammer the problem that I am having with the contract in this tutorial is that I am unable to successfully approve both wallets for the swap. What I am trying to do here is whenever a user buys our custom token, user will have to approve the transfer, then our nodejs backend will automatically approve the transfer as well before the swap is executed. Everytime I tried, the swap fails with the error that our custom token's allowance is too low.
I have loaded my bags for $SWAP on #MXC_Exchange below $1 price until now still holding. I think it might reach $1.5 soon!! Buy more $SWAP and hold it guys!! 🤑🤑
Can't one side still cheat on the trade though? Since both people in the trade are able to call the swap() function and only one signature is needed, couldn't I just tell the other person to give allowance to the TokenSwap smart contract first. Then I can come in and just call swap() and put 0 as my amount and then whatever allowance the other person gave for the other amount? I do not know if I am missing something, just want to be sure. If this is the case, I believe this could be fixed requiring both parties to sign on the swap() function. Let me know! Thanks for the great videos by the way!
Yes you are absolutely right! This is a bug. I've fixed the code by setting the trading amounts inside the contract. Here is the code
solidity-by-example.org/0.6/app/erc20/
@@smartcontractprogrammer Hi, what is the file solution for this problem. I'm searching with 'swap' keyword and there is no result
@@thaod.nguyen1124
solidity-by-example.org/app/erc20/
@@smartcontractprogrammer Hi ,there is not code in this link ,can you please explain what you did exactly to fix problem ?
I need the code before fix and after fix please
This is a very cool tutorial on token swap. Thanks for the content.
Hi sir i created erc20 tokens in gnosis, i need to bulk swap them for usdt , i don't know how to do it, if you help me i can pay thcv2 - a erc20 token i minted in gnosis chain and has liquidity in honeyswap.
by doing and giving the same parameters as you the code is showing token 1 allowance is less on swap why is this happening I have used the mytoken code and tokenswap same as in the description link
This is exactly what I was looking for. Great tutorial; explained very well. Thank you!
Thank you for watching, for question, guidance and support at anytime. Just DM +1.(4 .2 .3). 4 . 3 . 0 . 6 . 9 . 8 . 4 @ W H A T S A P...
Why do you use IERC 20 here and ERC20 in last course?
😍 this is supper cool stff !!! Token Swap is a very simple yet effective and creditable fuction !! It is almost like central clearing house in financial instructment trading ✨ Thanks so much !!
Hello,
Where did you get the token address from?
What is token swap address , Bob coin address and alice coin address
hi friend i have tokens in ERC 20 network stuck with old contract can i manually copy them 1-1 to new contract
yes but it might be impractical
How to add front end for this smart contract
Im building mini project so looking for small token swap dapp reference
use react or vue.js + web.js + meta mask
Excellent video, thanks a lot!!!!!
Why it shows in allowance that I have allowed the other acc to trade my tokens, but when i try to use the transferFrom function, it says that - amount exceeds allowance.
forgot to switch account when you call transferFrom?
@@smartcontractprogrammer fcking right....
How can I add binance smart contract to my token, i already have an ethereum contract but i still need to add a binance contract. please help me out
Ask here? He has experience on BSC
ua-cam.com/channels/ZM8XQjNOyG2ElPpEUtNasA.html
Hello , please i have a problem , i have 1 token erc20 THR , but i couldint to sell or trade , i want to serach solution to sell my Erc20 , can you give a solution please.
Think you .
Google for an exchange to sell your tokens
@@smartcontractprogrammer haw please ??
@@bchiniomar383 Thank you for watching, for question, guidance and support at anytime. Just DM +1.(4 .2 .3). 4 . 3 . 0 . 6 . 9 . 8 . 4 @ W H A T S A P..
Thank you very much !
Thank you for watching, for question, guidance and support at anytime. Just DM +1.(4 .2 .3). 4 . 3 . 0 . 6 . 9 . 8 . 4 @ W H A T S A P...
Okey okey, so hear me out... is the approval of spending coins revocable? Because if it was (e.g.) Bob calls swap() once both approved but then revokes his approval while the swap() function is still executing the first transaction -> and then the function is failing to transfer from Bob to Alice? Even though in practice this would be really hard to achieve, is it in theory possible? And if it is couldn't you prevent it this way:
Alice sends the money to the contract and the exchange rate (she sends 10 AliceCoin and wants to receive 20 BobCoin) then Bob does the same (he sends 20 BobCoin and wants to receive 10 AliceCoin). After that the contract has the coins stored and sends them both their fair share.
Just a thought. Your videos are really great and you make me really want to dig deeper into smart contracts!
Given that the token contract is not malicious, no bug, etc...
Attack probably won't work
1. EVM is sequential. Only one transaction is executed at a time.
2. swap is atomic. if any transfer fails the whole swap will fail.
Revoking while swap is executing will fail because of 1.
Revoking right before and or after swap is impossible from 2.
Unless the token contract is malicious or faulty. In that case hack is probably possible.
@@smartcontractprogrammer Ah, okey thank you for clarifying! I get it now :)
Does this mean that every time 2 people wanna swap with each other, we have to deploy a new smart contract?
Yes, or have a contract that can handle multiple swaps
@@smartcontractprogrammer noted, maybe I'll create another smart contract & pass all the constructor parameters into the swap method instead so I can reuse the same contract.
@@smartcontractprogrammer the problem that I am having with the contract in this tutorial is that I am unable to successfully approve both wallets for the swap.
What I am trying to do here is whenever a user buys our custom token, user will have to approve the transfer, then our nodejs backend will automatically approve the transfer as well before the swap is executed.
Everytime I tried, the swap fails with the error that our custom token's allowance is too low.
Very useful 👍👍👍
Thank you for watching, for question, guidance and support at anytime. Just DM +1.(4 .2 .3). 4 . 3 . 0 . 6 . 9 . 8 . 4 @ W H A T S A P...
Use Adam and Bob
can I hire you to create a smart contract for me?
My hands are full at the moment
I could help you with this @shaf
Jordan Peterson is that u
I have loaded my bags for $SWAP on #MXC_Exchange below $1 price until now still holding. I think it might reach $1.5 soon!! Buy more $SWAP and hold it guys!! 🤑🤑
Thank you for watching, for question, guidance and support at anytime. Just DM +1.(4 .2 .3). 4 . 3 . 0 . 6 . 9 . 8 . 4 @ W H A T S A P...
Lol you sound like Jordan Peterson 😂
I don't have the best voice :D
Thank you!