safe-global / safe-transaction-service

Keeps track of transactions sent via Safe contacts and confirmed transactions. It also keeps track of Ether and ERC20 token transfers to Safe contracts.
MIT License
193 stars 264 forks source link

delegate API: lack of documentation for how to sign #1663

Closed d10r closed 1 year ago

d10r commented 1 year ago

I'm stuck trying to specify a delegate using the API endpoint POST `/v1/delegates . All attempts end up with the error message:

{"nonFieldErrors":["Signature does not match provided delegator=0x30B125d5Fc58c1b8E3cCB2F1C71a1Cc847f024eE"]}

It's essentially the same problem reported by somebody else >1 year ago here: https://ethereum.stackexchange.com/questions/127433/gnosis-safe-create-delegate-key-api-400

I found a test case for the endpoint here, but it doesn't create an actual signature, thus doesn't help figuring out what's expected. Since the transaction service is written in Python, I also checked Python's way of signing, but that only adds question marks.

Please provide some clarification in the endpoint description, in the tests or in the docs about how to create a valid signature.

DefiDebauchery commented 1 year ago

Here are some older, but still-mostly-relevant documentation on delegates and signing:

https://github.com/safe-global/safe-docs/blob/devportal/docs/tutorial_tx_service_set_delegate.md

The only caveat is that the path is /v1/delegates as you noted, and now has an extra delegator field. Other than adding the delegator address to the payload, my code is the exact same from the above document.


After you get that squared away and have the delegate set, if you need help signing, here are some additional docs on that: https://github.com/safe-global/safe-docs/blob/devportal/docs/tutorial_tx_service_initiate_sign.md (Note: You can skip the gas parts, since they'll simply be calculated on execution)

But essentially you are building the Safe Transaction Hash (the same hash used to differentiate each Safe Transaction, based on the payload data) and use that delegate account's private key to sign that message as outlined in the document.

d10r commented 1 year ago

thx, that indeed looks useful, will try.

d10r commented 1 year ago

works. Looks like the Python libs have a different default way of signing than the JS libs.