v3-client
v3-client copied to clipboard
API key not found
const main = async () => {
let client = new DydxClient(HTTP_HOST, {
web3: web3,
apiTimeout: 3000,
networkId: 1,
})
client.starkPrivateKey = await client.onboarding.deriveStarkKey(address)
client.apiKeyCredentials = await client.onboarding.recoverDefaultApiCredentials(address)
const keys = await client.private.getApiKeys();
console.log(keys);return; // "msg": "API key not found"
}
This is full code and I always get "API key not found". I do not have any idea to solve this problem... For solving this problem, I try to login in with my METAMASK on the website. After I do the recovery step by step, it always showed "API key not found" like the code above.
I face this problem for a long time, please anyone help me...
no one can answer me the question...????????
let api_key_response = await client.ethPrivate.createApiKey(
address
)
let api_keys = await client.private.getApiKeys()
NOT WORKING..............................................for a VERY LONG TIME....
"msg": "API key not found"
let user = await client.private.getUser()
console.log(user)
"msg": "API key not found"
await client.private.getAccount(address)
"msg": "API key not found"
I WANT MY MONEY BACK
I was able to perform successful onboarding with this code
client = new DydxClient(HTTP_HOST, {
web3,
apiTimeout: 3000,
networkId: 3
})
const userExists = await client.public.doesUserExistWithAddress(
address,
);
console.log(userExists)
if (!userExists.exists) {
const keyPairWithYCoordinate = await client.onboarding.deriveStarkKey(
address,
);
client.starkKey = keyPairWithYCoordinate.publicKey
client.starkKeyYCoordinate = keyPairWithYCoordinate.publicKeyYCoordinate
console.log("Creating user...")
const newUser = await client.onboarding.createUser(
address
)
console.log(newUser)
}
const apiCreds = await client.onboarding.recoverDefaultApiCredentials(address)
client.apiKeyCredentials = apiCreds
console.log(client.apiKeyCredentials)
const timestamp = new Date().toISOString()
const signature = client.private.sign({
requestPath: '/ws/accounts',
method: 'GET',
isoTimestamp: timestamp,
})
const msg = {
type: 'subscribe',
channel: 'v3_accounts',
accountNumber: '0',
apiKey: apiCreds.key,
signature,
timestamp,
passphrase: apiCreds.passphrase
}