我得到这个错误,当我尝试使客户端连接到DYDX。我已经包含了所有必要的API_keys和主机。Error connecting to client: 'Eth' object has no attribute 'defaultAccount'
下面是创建到Dydx的客户端连接的代码
from dydx3 import Client
from web3 import Web3
from constants import (
HOST,
DYDX_API_KEY,
DYDX_API_SECRET,
DYDX_API_PASSPHRASE,
ETH_PRIVATE_KEY,
STARK_PRIVATE_KEY,
HTTP_PROVIDER
)
def connect_dydx():
# Create client connection
client = Client(
host=HOST,
api_key_credentials={
"key": DYDX_API_KEY,
"secret": DYDX_API_SECRET,
"passphrase": DYDX_API_PASSPHRASE
},
stark_private_key=STARK_PRIVATE_KEY,
eth_private_key=ETH_PRIVATE_KEY,
web3=Web3(Web3.HTTPProvider(HTTP_PROVIDER)),
)
# Confirm Client
account = client._private.get_account()
account_id = account.data["account"]["id"]
quote_balance = account.data["account"]["quoteBalance"]
print("Connection Successful")
print("Account ID: ", account_id)
print("Quote Balance: ", quote_balance)
return client
这是针对main.py
的
from connection import connect_dydx
if __name__ == "__main__":
# Connect to client
try:
client = connect_dydx()
except Exception as e:
print(e)
print("Error connecting to client: ", e)
exit(1)
我已经尝试更新包和库,但还没有任何工作。
1条答案
按热度按时间jgovgodb1#
你有没有试过默认的例子:https://github.com/dydxprotocol/dydx-v3-python/blob/master/examples/onboard.py