主流大模型写代码全军覆没:根据助记词查询钱包余额

257 天前
 landOfHeavens

根据钱包(区块链)助记词查询钱包的余额(可以是 btc ,eth 等)

试了一下 gpt-4 、Claude-Opus 、谷歌 gemini-pro 、通义千问、百度灵码,结果全部翻车。没一个正常的,出现

的错误发给它,反复修改几遍还是无法正常运行。

选取部分错误

Traceback (most recent call last):
  File "/root/pyu.py", line 3, in <module>
    from eth_account.hdaccount import mnemonic_to_private_key
ImportError: cannot import name 'mnemonic_to_private_key' from 'eth_account.hdaccount' (/usr/local/lib/python3.10/dist-packages/eth_account/hdaccount/__init__.py)

Traceback (most recent call last):
  File "/root/e1.py", line 10, in <module>
    if web3.isConnected():
AttributeError: 'Web3' object has no attribute 'isConnected'. Did you mean: 'is_connected'?
Traceback (most recent call last):
  File "/root/e2.py", line 35, in <module>
    wallet_address = wallet.get_address(0, 0)
AttributeError: 'Wallet' object has no attribute 'get_address'
Traceback (most recent call last):
  File "/root/e3.py", line 27, in <module>
    wallet = bip44.Wallet(seed)
  File "/usr/local/lib/python3.10/dist-packages/bip44/wallet.py", line 20, in __init__
    self._seed = Mnemonic(language).to_seed(mnemonic, passphrase)
  File "/usr/local/lib/python3.10/dist-packages/mnemonic/mnemonic.py", line 234, in to_seed
    mnemonic = cls.normalize_string(mnemonic)
  File "/usr/local/lib/python3.10/dist-packages/mnemonic/mnemonic.py", line 96, in normalize_string
    utxt = txt.decode("utf8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9e in position 0: invalid start byte
Traceback (most recent call last):
  File "/root/b1.py", line 30, in <module>
    balance = get_wallet_balance_from_mnemonic(mnemonic)
  File "/root/b1.py", line 5, in get_wallet_balance_from_mnemonic
    private_key = Web3.to_checksum_address(Web3.accounts.privateKeyFromMnemonic(mnemonic))
AttributeError: type object 'Web3' has no attribute 'accounts'
1200 次点击
所在节点    分享发现
3 条回复
zhutianjingtu
257 天前
😂
HojiOShi
257 天前
😂
zeusho871
257 天前
是这个库更新太快了吧。。。你得问问版本 或者看看代码 他们调用的 api 是对的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1031356

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX