0

My question is if I'm not implementing ERC-20 methods in my contract, but I'm using already deployed ERC-20 contract methods in my contract, so can we say this will be ERC-20 compliant contract?

contract MyContract is Owned {
  event Created (
    uint256 tradeId,
    uint256 createdAt,
    uint256 expiredAt,
    address originatorAddress,
    address benificiaryAddress,
    string expectedToken,
    uint256 receivedQty);
  event Released(uint256 tradeId);

  struct Escrow {
    uint256 tradeId;
    uint256 createdAt;
    uint256 expiredAt;
    address originatorAddress;
    address benificiaryAddress;
    string expectedToken;
    uint256 receivedQty;
  }

  mapping (uint256 => Escrow) public escrows;
  mapping(address => mapping(address => uint256)) public escrowBalance;
  uint256 feePercent;
  address feeAddress;
  // ------------------------------------------------------------------------
  // Constructor
  // ------------------------------------------------------------------------
  constructor() public {
  //  escrowBalance[msg.sender][this] = 1000000000;
  // myToken = ERC20interface(erc20Address)
  }

  function createEscrow( uint256 _tradeId,
    uint256 _expiredAt,
    address _benificiaryAddress,
    string _expectedToken,
    uint256 _receivedQty, 
    address token)payable external
  {   
    uint256 tokenBalance = ERC20Interface(token).balanceOf(msg.sender);
    require(tokenBalance >=_receivedQty, "Insufficient balance.");

    escrows[_tradeId] = Escrow(_tradeId, now, now + _expiredAt, msg.sender, _benificiaryAddress, _expectedToken, _receivedQty);

    ERC20Interface(token).transferFrom(msg.sender, this, _receivedQty);   
    emit Created (_tradeId, now, now + _expiredAt, msg.sender, _benificiaryAddress, _expectedToken, _receivedQty);
  }

  function releaseToken(uint256 _tradeId, address token) external {
    Escrow storage escrow = escrows[_tradeId];
    ERC20Interface(token).transfer(escrow.benificiaryAddress, escrow.receivedQty);
    emit Released(_tradeId);
    delete escrows[_tradeId];
  }   
}
4
  • Please show your contract. Dec 4, 2019 at 11:05
  • github.com/Love3119/Escrow please check this link only see mycontract class Dec 4, 2019 at 11:53
  • Please post ALL the relevant code and ONLY the relevant code in PLAINTEXT (copy-pastable). Dec 4, 2019 at 11:55
  • please check above code Dec 4, 2019 at 12:38

1 Answer 1

0

ERC-20 (a.k.a. EIP-20) defines standard interface all token contracts are supposed to implement. Your contract does not implement this interface, so your contract is not compliant. However, your contract is not a token contract (it does not introduce its own tokens, but just uses existing tokens), so your contract is not supposed to implement ERC-20 interface, and thus is not supposed to be compliant.

Just think about some regulation all trucks must comply with. If you produce bicycles, rather than trucks, then your production most probably does not comply with this regulation, but this is not a problem at all.

1
  • so right now my contract is not erc20 compliant? Dec 5, 2019 at 4:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.