-
Notifications
You must be signed in to change notification settings - Fork 169
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
Working with EIP-3009, transferWithAuthorization #146
Comments
Updated assumed flow:
Currently working on creating a correctly formatted TypedData object. Wrestling with creating |
Hello @danielnordh, I think it's easier if you just use a JSON template and generate the message with a JSON string as we do in the tests. Constructing this JSON Is very verbose. |
Thanks @DarthMike, the changes in #148 should probably take care of that issue 👍 |
OK I think I solved my problem for now, mostly using your suggested JSON solution but with some added convenience functions and structs. Sharing rough concept here for anyone else trying to achieve the same thing. Flow
Structs
Helper method for jsonData
For generating random nonce
|
Hi, |
Here's an overview of how I used this in our code to make a USDC transfer:
|
What does JSONDecoder() do ? |
Check out this overview in JS: You need to turn your JSON into data, example from the link above:
|
I installed the EIP-712 node module: And now I'm getting this error: node_modules/eip-712/lib/cjs/eip-712.js:90 TypeError: Cannot read properties of undefined (reading 'EIP712Domain') I noticed in one of your examples, you cast the data to UTF8. Is this the problem? |
It could be. |
For anyone else struggling with this. I finally found some useful information: How to make EIP712 typed data object: https://medium.com/@ashwin.yar/eip-712-structured-data-hashing-and-signing-explained-c8ad00874486 Problems & Solutions.. https://ethereum.stackexchange.com/questions/74027/eip712-implementation-for-web3-1-0 https://ethereum.stackexchange.com/questions/129707/get-signature-for-tuple-input-for-eip712 eth_signTypedData and signTypedData_v4 function only exists in the canary (dev version) of web3: You need to use this metamask module: eth-sig-util and the function: https://metamask.github.io/eth-sig-util/latest/functions/signTypedData.html I see the light at the end of the tunnel... |
To help anyone else who stumbles here: This will probably save you about 2 nights of sleep... const buffer1 = Buffer.from(user_privateKey.substring(2,66), "hex"); |
I'm trying to get our client to support EIP-3009, to let us submit transactions on our users' behalf.
Specifically USDC's 'transferWithAuthorization' function.
My assumptions for how the flow should go:
Data
object that conforms to the function protocol described here. Not sure which existing web3.swift functions I can leverage here. Their javascript example below. (Do I include the type definitions in the data, or just the actual data - domain, primaryType, message?)Data
object, hopefully usingfunc sign(data: Data) throws -> Data
(Will the result allow for extracting the v, r, s values?)transferWithAuthorization
function with all the parametersIf you have any thoughts on errors in this flow, or ideas for how to best support EIP-3009 @DarthMike let me know.
I haven't been able to find much info on this, particularly in Swift. Not sure it has been done before.
Happy to submit any work I do here back to the repo.
The text was updated successfully, but these errors were encountered: