问题标签 [web3py]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
1112 浏览

python - 如何获取气体量 web3py?

我可以得到 gas 价格,但我怎么才能得到 gas 数量呢?我觉得这是文档中没有正确涵盖的内容。为了让我发送交易(合约调用),我需要构建它,但是当我构建它时,我需要给它 gas 价格和 gas 数量。如果我不知道如何估算气体量,我该如何给它提供气体量?

例如,这是我批准合同调用的代码。

我可以给它一些任意数字,但这不是一个真正的解决方案。在我在网上看到的每个示例中,都输入了一些任意的气体量,但没有解释他们是如何得到它的。

0 投票
1 回答
873 浏览

python-3.x - SendRawTransaction 返回哈希,但没有交易

我想做一些交易。喜欢这里提到的

sendRawTransaction 返回我交易的哈希值。但是没有任何交易。我的待处理事务计数为 0。当我使用该 hash 调用 getTransaction 方法时,结果是

可能是什么原因?

0 投票
1 回答
1939 浏览

python - web3.py swapExactTokensForTokens 交易失败

我正在尝试调用路由器合约的 swapExactTokensForTokens,我需要将 tokenA 交换为 tokenB。这是交易的代码:

我在交易中收到以下错误:

交易截图

0 投票
1 回答
8221 浏览

transactions - 如何使用 Python 与币安智能链合约进行交互

我首先尝试使用 python 发送交易:

给我以下错误: ValueError: {'code': -32000, 'message': 'invalid sender'}


现在,我正在尝试与合同交互 - 调用方法并提供输入,但我不确定如何实现这一点。

0 投票
0 回答
296 浏览

python - Web3:OverflowError:Python int 太大而无法转换为 C ssize_t

当试图调用一些视图函数时,对于一些大量的输入值我得到了错误

溢出错误:Python int 太大而无法转换为 C ssize_t

例如,波纹管产生错误:(输入值为2*10^24)

pancakeContract.functions.getAmountsIn(20000000000000000000000000, [w3.toChecksumAddress('0xe9e7cea3dedca5984780bafc599bd69add087d56'), w3.toChecksumAddress('0xbb4cdb9cbd36b01bd71cbaebf2de08')171cbaebf2de08d]d

合同 ABI 可以在这里找到:

https://bscscan.com/address/0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F#code

0 投票
0 回答
166 浏览

python - web3.isConnected = False

我已经完成了所有必要的步骤,并且 web3.py 的安装工作正常,但是当谈到这个功能时,即使我已经完成了所有应该做的事情,它也会一直说是假的。我什至三次检查了大声笑。

0 投票
1 回答
61 浏览

solidity - 如何与solidity函数交互并从不同的地址进行交易?

所以我有一个我已经定义然后编译的solidity合约:

当我这样做时,Voting.all_functions()我得到:

这是我定义的功能。我现在要做的是与来自默认帐户以外的发件人的这些功能进行交互。我不知道该怎么做。我是否需要编译另一份合同(这似乎不是正确的选择),但似乎每当我这样做时Voting.something,它指的是那里的默认帐户,所以制作新合同是我唯一能想到的,但这似乎也是错误的然后我将实例化一个新合同。

我想做类似的事情:

但我明白了TransactionFailed: execution reverted: b''

0 投票
0 回答
657 浏览

python-3.x - Web3 读取合约 Python

你能告诉我,我如何调用合同中的函数https://bscscan.com/address/0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F#readContract

我用蟒蛇

但是我收到错误 web3.exceptions.BadFunctionCallOutput: Could not transact with/call contract function, 合约部署是否正确并且链同步?

我该做什么?

0 投票
1 回答
190 浏览

ethereum - 使用“--allow-insecure-unlock”运行geth

我正在尝试通过连接到本地 geth 节点的 web3.py 接口发送事务。阅读了一些关于为什么使用 RPC 不好的评论后,我仍然想知道在端口 8545 关闭时使用 -rpc 选项是否不安全。根据这篇文章(https://www.zdnet.com/article/hackers-ramp-up-attacks-on-mining-rigs-before-ethereum-price-crashes-into-the-gutter/),漏洞只是在暴露的端口上,但是由于我基本上是在与本地网络上的节点通信,所以这应该不是问题吧?

0 投票
2 回答
1520 浏览

python - ContractLogicError while using web3.py

I'm trying to learn more about dapps by using Python's web3 module. Web3 connects to Ganache just fine, I can see my account by using web3.eth.accounts[0] and I can retrieve my contract. However when I try to call a function from my contract I get the following: web3.exceptions.ContractLogicError: execution reverted: VM Exception while processing transaction: revert

Here is my python code:

And here is my contract:

Any help in understanding the error would be appreciated.