v3-client icon indicating copy to clipboard operation
v3-client copied to clipboard

eth_signTypedData not supported by Infura & AlchemyAPI

Open rayeaster opened this issue 3 years ago • 8 comments

Any plan to provide alteranative so we could use Infura or Alchemy RPC nodes? Thanks

(node:5748) UnhandledPromiseRejectionWarning: Error: Unsupported method [eth_signTypedData]. See available methods at https://docs.alchemy.com/alchemy/documentation/apis
at SignOnboardingAction.ethSignTypedDataInternal  (xxxxx\@dydxprotocol\v3-client\build\src\eth-signing\signer.js:68:19)

see also at https://community.infura.io/t/eth-signtypeddata-is-currently-working/2626/3

rayeaster avatar Sep 28 '21 07:09 rayeaster

It works with Infura. The problem is that you can't get stark private key from the API itself. Login to the trading dashboard, connect your wallet, and open the "Application" tab in the browser console. You will be able to get "API Key Pair" and "Stark Key Pair" from the local storage section. Use those for initializing the client object. It will work then.

crazyoptimist avatar Dec 01 '21 19:12 crazyoptimist

@CrazyOptimist, thanks, that worked for me! Another way would be to use https://moralis.io/ . Working with this node, fixed the issue above for me.

patpatwithhat avatar Feb 12 '22 08:02 patpatwithhat

Glad it helped!

crazyoptimist avatar Feb 12 '22 08:02 crazyoptimist

Hello, @patpatwithhat : can you tell me how do you initialize the dYdX client with the Moralis API Key please ? Thanks !

svax974 avatar Nov 17 '22 16:11 svax974

Hey, you can go for an approach like this:

        const web3 = new Web3(process.env.MORALIS)
        
        const host = networkId === 1 ? HTTP_HOST_MAINNET : HTTP_HOST_ROPSTEN
        DYDXConnector._client = new DydxClient(
            host,
            {
                apiTimeout: 3000,
                networkId: networkId,
                web3: web3,

                starkPrivateKey: keyPair,
                apiKeyCredentials: apiCreds
            }

        );

Or maybe you can have a look here in my project: https://github.com/patpatwithhat/dydx_nodejs_connector That's also available as an npm package.

Btw you need an moralis endpoint with an adress like this: https://asdf123.usemoralis.com:2053/server

patpatwithhat avatar Nov 17 '22 16:11 patpatwithhat

@patpatwithhat indeed, this is what I miss, Moralis endpoints. It seems it is not a free service. Thanks for your answer anyway.

svax974 avatar Nov 17 '22 16:11 svax974

@patpatwithhat how did you manage to get it working, if you mind me asking?

I've managed to sign, but then I am stuck with transferring it to endpoint to pass it to web3 library.

from moralis import auth

api_key = '8ExCSTkEbKH233qewaef0jtIqyNOYPTSm23qefaefxmGcT5KmFJeCVgWSDKzY'
body = {
    "domain": "defi.finance", 
    "chainId": "1", 
    "address": "0x08EAaE620392dEB7C6339651d4c36f5F7de82b23", 
    "statement": "Please confirm", 
    "uri": "https://defi.finance/", 
    "expirationTime": "2020-01-01T00:00:00.000Z", 
    "notBefore": "2020-01-01T00:00:00.000Z", 
    "resources": ['https://docs.moralis.io/'], 
    "timeout": 15, 
}

result = auth.challenge.request_challenge_evm(
    api_key=api_key,
    body=body,
)

result is returning this str:

{'id': 'k1wzcuMzHhqCmz6lq', 'message': 'defi.finance wants you to sign in with your Ethereum account:\n0x08EAaE62039bdEB7C6339671d4c36f5F7de82b27\n\nPlease confirm\n\nURI: https://defi.finance/\nVersion: 1\nChain ID: 1\nNonce: qwfOUBQ8cFJJrYmSc\nIssued At: 2023-02-07T13:45:36.152Z\nExpiration Time: 2020-01-01T00:00:00.000Z\nNot Before: 2020-01-01T00:00:00.000Z\nResources:\n- https://docs.moralis.io/', 'profileId': '0x4f9983d3c678733c09556f7469fff7051d82f7fd408dbd064a57cf76435c12f4'}

5x12 avatar Feb 07 '23 13:02 5x12

This looks like u are building a web request. Didn't try it that way. I used node.js. Are you even trying to use DYDX?

If you read your str: 'message': 'defi.finance wants you to sign in with your Ethereum account:\n0x08EAaE62039bdEB7C6339671d4c36f5F7de82b27\n\nPlease confirm\n\nURI: https://defi.finance/\n I would say, you have to open https://defi.finance and confirm something. Dunno, what that page is.

Also, I wouldn't recommend you share API keys at all!

patpatwithhat avatar Feb 07 '23 15:02 patpatwithhat