-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On-chain order generation by smart contracts #7
Comments
Hi, whats the eta for this? |
Instead of keeping a separate mapping, we could also designate Any entry in the This isn't a great separation of concern, however it does reduce the gas cost of the initial fill:
|
Although that would be an efficiency gain, it's a bit inconsistent with how we've been special casing |
@retotrinkler this will be included in the next version, but we are still deciding on the other features that will be added. |
What is the status of this? I'm considering doing an EIP for an ecosystem-wide smart contract where contracts can 'sign a hash'. The interface looks like this:
and this would be an initial implementation:
Then from contracts like the 0x Exchange you would directly check whether a contract has signed a hash, as an alternative for ecrecover when the code size of an address is greater than 0.
I feel like this is better than making a specific implementation just for 0x. In terms of gas costs, it would be slightly more expensive than just checking in the contract, as you need to add the cost for a |
Interesting. What do you think is the benefit of standardizing this? It seems to me that signatures are typically used for application/protocol specific messages, so putting them in a global scope might not be that useful. The other problems I see are:
|
What I think is important is having a global way for contracts to signal they approve something, the equivalent as signing an arbitrary payload with a private key. The type of payloads being signed would defer depending on the protocol, in the same way that ECDSA signatures work the same independently of the data being signed. Another more limited advantage of keeping it generic, is that data could be 'signed' before knowing on what application/protocol it is relevant for. As well as signing data that isn't relevant to any protocol, like expressing conformity to an agreement by 'signing' its hash. Regarding costs, it would be as cheap for the order maker, taking the order would add around 700 gas (IMO not a deal-breaker for its benefits). |
700 gas doesn't seem like a big deal, but that does make the maker's order slightly less attractive to a taker (and in general we want to cut out any extra gas from transactions that happen frequently). I do see value in standardizing this, but my preference would be to first check the internal 0x mapping and fall back to the global signature contract. This would mean that the global contract can have false negatives, but I think that's going to be hard to avoid anyways. |
I think that is a good compromise :) If 'order signatures' can't be cancelled on the 0x mapping nor the global signing contract, then just seeing that a the hash is present in either of those could be enough to know that the order has been approved. You could even make it a public function such as |
@abandeali1 Is there any reference implementation for this strategy where we can define the approveOrder, isValidSignature and isOrderApproved? |
@izqui The current PR for signature generalization is not |
Summary
Up until now, the focus of discussion has been on how to generate an order on behalf of a contract off-chain. However, there is a definite value in allowing a contract to generate an order on-chain (e.g a DAO voting on the creation of an order).
Motivation
Currently, there is no way for smart contracts to generate orders (see issue #1 ).
Specification
The following additions can be added to the Exchange contract:
Then, when verifying an order signature, we check:
Rationale
This allows any contract to approve an order on-chain in place of a signature.
The text was updated successfully, but these errors were encountered: