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.
_amount
indepositEscrow()
is greater thansellerRefund + buyerRefund
.Shane 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.