V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
landOfHeavens
V2EX  ›  分享发现

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

  •  
  •   landOfHeavens · 258 天前 · 1201 次点击
    这是一个创建于 258 天前的主题,其中的信息可能已经有所发展或是发生改变。

    根据钱包(区块链)助记词查询钱包的余额(可以是 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'
    
    3 条回复    2024-04-10 18:20:45 +08:00
    zhutianjingtu
        1
    zhutianjingtu  
       258 天前
    😂
    HojiOShi
        2
    HojiOShi  
       258 天前
    😂
    zeusho871
        3
    zeusho871  
       258 天前
    是这个库更新太快了吧。。。你得问问版本 或者看看代码 他们调用的 api 是对的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5163 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 05:43 · PVG 13:43 · LAX 21:43 · JFK 00:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.