使用Python/web3.py传输ERC721令牌

发布于 2025-01-22 15:10:24 字数 414 浏览 5 评论 0原文

我一生无法找到整个Interweb上的任何文章,这些文章谈论使用Web3.py在钱包之间传递ERC-721令牌。铸造,整天都是,整天的气盘是的,但是钱包转移到钱包,不。我在这里错过了什么吗?为什么在此问题上缺乏对话。无论如何,如果您可以将我指向正确的方向或回答我的问题,那就太神奇了。我会告诉您到目前为止我尝试过的事情,但是答案却一无所有,因为我什至不知道从哪里开始。据我所知,...

contract_call = contract.functions.transfer(destination_address, value)
unsigned_txn = contract_call.buildTransaction({'chainId': 1, 'gasPrice': 
w3.toWei(100, 'gwei')})

但这似乎并不是我想要的。

I can not for the life of me find any article on the entire interweb that talks about using web3.py to transfer ERC-721 tokens between wallets. Minting, yes all day long, airdrop yes all day long, but wallet to wallet transfer, nope. Am I missing something here, is it not possible? Why is there such a lack of dialogue on this matter. Anyways, if you could point me in the right direction or answer my question, that would be amazing. I would tell you what I have tried so far, but the answer is nothing because I do not even know where to start. As far as I got was ...

contract_call = contract.functions.transfer(destination_address, value)
unsigned_txn = contract_call.buildTransaction({'chainId': 1, 'gasPrice': 
w3.toWei(100, 'gwei')})

But this does not appear to be what I am looking for.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一生独一 2025-01-29 15:10:24

经过大量阅读的方式,我终于做到了,希望有一天对某人有帮助。

的问题几乎是使用交易的文档的

任何

这里

地方。

mint_txn = NFT_CONTRACT.functions.transferFrom(FROM, TO, 8).buildTransaction(
    {
        'from': FROM,
        'nonce': nonce,
        'gas': 1000000,
        'gasPrice': w3.toWei("70", "gwei"),

    }
)

signed_txn = w3.eth.account.sign_transaction(mint_txn, 
private_key=PRIVATE_KEY)
w3.eth.send_raw_transaction(signed_txn.rawTransaction)

After way to much reading I finally got it done, I hope this helps somebody one day.

The problem here is almost anywhere there is documentation it says to use transact( not buildTransaction when buildTransaction IS the correct way of doing this.

Make sure you have your contract initialised properly

transferFrom arguments FROM, TO, TOKEN_ID

FROM being the wallet that owns the NFT. TO who you are transferring the NFT to. PRIVATE_KEY being the key to the FROM wallet.

mint_txn = NFT_CONTRACT.functions.transferFrom(FROM, TO, 8).buildTransaction(
    {
        'from': FROM,
        'nonce': nonce,
        'gas': 1000000,
        'gasPrice': w3.toWei("70", "gwei"),

    }
)

signed_txn = w3.eth.account.sign_transaction(mint_txn, 
private_key=PRIVATE_KEY)
w3.eth.send_raw_transaction(signed_txn.rawTransaction)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文