stablecoin-fun
stablecoin-fun copied to clipboard
I'm sorry, did you test it at all?
You must have a mistake somewhere. If the value is 1 or more when you dipit, there will be an error. And if the value is 0, then you just can't deposit coins
Nope, this project was just a mock and there never was a plan to make it into production ready code. There's only a simulation script running against forked state which checks for sucessfull execution with deposit/fund. You can deposit and fund fine.
I'm sorry I misinterpreted the error. The mistake is that a person must first allow a contract such as ETH to spend his money to that contract.
This can only be done personally by the person through the ETH contract. It won't go through the transaction if you don't do this.
If you don't do this, the contract will give an error in the gas calculation and the amount of gas will be high, If you specify a small amount of gas yourself and execute the transaction, then the commission for debiting ETH will not pass and the stabel coin will be credited.
More precisely, the eth coin will not be credited, but your contract coins will be credited.
I tested on the BSC network, but they are the same. Both there and there for external coin entry. confirmation for coin withdrawal must be done personally by the wallet on the contract of that coin.
The only thing that happens in tranzation is that it allows you to spend coins that are on the contract, not on a person's wallet.
he problem with sending ERC-20 to any contract is that the contract is not aware of that transaction. There's no function that's called when the tokens are received, so it's not possible to assign that balance to a specific sender. This is why things like decentralised exchanges use approve and transferFrom. In this case a contract can transfer user's tokens itself, in which case it knows that the user has that number of tokens.
More recent token standards like ERC-721 (non-fungible tokens), and ERC-777 solve this problem with hooks. An ERC-777 token contract for example calls the receiving contract before the tokens are sent. If the receiving contract does not implement the token receiver hook, the transaction is reverted. This way it's possible to: 1) assign a token balance to a user on transfer and 2) prevent tokens being sent to a contract that does not support it.
i.e. before sending ERC-20 coins to the contract the person has to do it himself: ( your contract ) amount ( the amount he will transfer)
and only after that transferFrom