【发布时间】:2021-06-12 05:43:32
【问题描述】:
所以我有一个我已经定义然后编译的solidity合约:
voting_contract_compiled = compile_contract('Voting')
voting_deployment_tx_receipt, Voting = deploy_contract(w3, voting_contract_compiled, 10)
当我Voting.all_functions() 时,我得到:
[<Function getNumVoters()>,
<Function getStatus()>,
<Function getWinner()>,
<Function isVotingOpen()>,
<Function totalVotesFor(int256)>,
<Function validateAndCacheVote()>,
<Function voteForCandidate(int256)>,
<Function votesReceived(int256)>]
这是我定义的函数。我现在要做的是与来自默认帐户以外的发件人的这些功能进行交互。我不知道该怎么做。我是否需要编译另一份合同(这似乎不是正确的选择)但似乎每当我做Voting.something 时,它指的是那里的默认帐户,所以制作新合同是我唯一能想到的事情,但这也是考虑到我会实例化一个新合同,这似乎是错误的。
我想做这样的事情:
account1 = {'from': w3.eth.accounts[1], 'value': w3.toWei(1, 'ether')}
Voting.functions.voteForCandidate(1).transact(account1)
但我得到TransactionFailed: execution reverted: b''。
【问题讨论】:
标签: solidity web3 ether web3py