ValueError: STARK public/private key mismatch
jbae49 opened this issue · 1 comments
jbae49 commented
Hi, I'm new to this dydx API, I'm trying to use ganache but it keeps saying that my STARK pubic and private keys are somehow incorrect even though I copied and pasted from the inspect > applications > ... and then put "0x" in front of those key pairs as well.
'''Example for onboarding an account and accessing private endpoints.
Usage: python -m examples.onboard
'''
from dydx3 import Client
from dydx3.constants import API_HOST_ROPSTEN
from dydx3.constants import NETWORK_ID_ROPSTEN
from web3 import Web3
# Ganache test address.
ETHEREUM_ADDRESS = '0xd4b01a60AD225C6Ab3CDF6145b4659E89a5DD15f'
ETH_PRIVATE_KEY = '0dadadcd18bac4a0244326d60569180d5637806ddfbadd2b67b8baedb618c041'
# Ganache node.
WEB_PROVIDER_URL = 'http://127.0.0.1:8545'
NETWORK_ID_GANACHE = '1337'
HOST_GANACHE = '127.0.0.1'
stark_key_pair_with_y_coordinate = {"walletAddress":"...(my metamask mainnet wallet address)...","publicKey":"0x06...","publicKeyYCoordinate":"0x000...","privateKey":"0x...","legacySigning":False,"walletType":"METAMASK"}
(publicKey, publicKeyYCoordinate, privateKey) = (
stark_key_pair_with_y_coordinate['publicKey'],
stark_key_pair_with_y_coordinate['publicKeyYCoordinate'],
stark_key_pair_with_y_coordinate['privateKey']
)
client = Client(
network_id=NETWORK_ID_GANACHE,
host=HOST_GANACHE,
default_ethereum_address=ETHEREUM_ADDRESS,
web3=Web3(Web3.HTTPProvider(WEB_PROVIDER_URL)),
eth_private_key=ETH_PRIVATE_KEY,
eth_send_options=None,
stark_private_key=privateKey,
stark_public_key=publicKey,
stark_public_key_y_coordinate=publicKeyYCoordinate,
web3_account=None,
web3_provider=None,
api_key_credentials={'key':'8d3382a4-...', 'secret': '7S...'},
crypto_c_exports_path=None,
)
# Onboard the account.
onboarding_response = client.onboarding.create_user(
stark_public_key=publicKey,
stark_public_key_y_coordinate=publicKeyYCoordinate,
)
print('onboarding_response', onboarding_response)
# Query a private endpoint.
accounts_response = client.private.get_accounts()
print('accounts_response', accounts_response)
GaruChenk commented
Remove the stark_private_key parameter from your Client function, then call
client.onboarding.derive_stark_key()
to get stark key credentials.