This is a very early work in progress, but I figured I’d start the convo earlier than later. These contracts serve as a trusted entity that temporarily owns ERC20 tokens on behalf of multiple parties.
I deliberately require the guarantor (client) to transfer tokens over to the escrow for ownership as apposed to giving it an allowance. We want to ensure that the funds will be there for the time of payment.
There is a concept of “reserved” in
ERC20Escrow. This is the maximum credit that an account can use and is different than the actual balance of that account in the ERC20 ledger. The ERC20RefundableEscrow keeps track of how much of the total budget is ALLOWED to be transferred to an individual account. This provides a nice scalable system for a company to limit a budget on a per-employee basis or as a single account for the whole company. You don’t want one dude stealing the entire budget then heading down to Mexico…
ERC20RefundableEscrow#transfer()takes an amount argument and updates “reserved”. This functionality allows an account to get paid in portions instead of paying the full amount in one shot. This is needed in many real-world situations and can easily be overwritten by
Primaryif the implementer wants it.
“reserved” will allow the ability to refund a prorated amount to a client while holding onto the wages of an account that has not yet “withdrawn” their tokens. That functionality will be implemented later.
Important Question: Does anyone know of a way where we can have a callback function that is called when a deposit is made to a ERC20 ledger for the address of ERC20Escrow?
I’m looking for suggestions. Next on my list is to allow for refunds and add more tests. I will also add an extension to this where an arbitrator (lawyer) or arbitrators (lawyers) must first approve the funds to be released to either side of the relationship.