Open rayeaster opened 3 years ago
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, thanks, that worked for me! Another way would be to use https://moralis.io/ . Working with this node, fixed the issue above for me.
Glad it helped!
Hello, @patpatwithhat : can you tell me how do you initialize the dYdX client with the Moralis API Key please ? Thanks !
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 indeed, this is what I miss, Moralis endpoints. It seems it is not a free service. Thanks for your answer anyway.
@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'}
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!
Any plan to provide alteranative so we could use
Infura
orAlchemy
RPC nodes? Thankssee also at https://community.infura.io/t/eth-signtypeddata-is-currently-working/2626/3