There is an escrow smart contact which at the end needs to send the escrow balance back to both seller and buyer. Here is the contract (without all the details)
pragme ^0.7.0;
interface ERC20Token {...};
contract MyEscrow {
address payable seller;
address payable buyer;
uint256 sellerRefund;
uint256 buyerRefund;
address addressToken;
function depositEscrow(uint256 _amount) external returns (bool) {
ERC20Token(addressToken).transferFrom(msg.sender, address(this), _amount); //<<==msg.sender approved before calling depositEscrow()
//do something else
}
function refundEscrow() sellerOnly external returns (bool) {
ERC20Token(addressToken).transfer(seller, sellerRefund);
ERC20Token(addressToken).transfer(buyer, buyerRefund);
//do something
}
}
Before putting the code into test, is the refundEscrow going to work as expected? Here is the example online which only sends refund to msg.sender. In the code above, the difference is that refund is sent to 2 recipients instead.
_amountindepositEscrow()is greater thansellerRefund + buyerRefund. – Shane Fontaine Dec 30 '20 at 00:01Shane Fontaine, one thing puzzles me was that msg.value can not be used to represent value of ERC20 token. msg.value can only be used forether. sent with transaction. – user938363 Dec 30 '20 at 02:27