我想在契约中从我的节点发送两个以太到我的invest()方法。但我不知道用蟒蛇怎么做。
稳固性:
function invest() payable {
value = msg.value / 1000000000000000000;
counter += value;
if(value >0 && value < 3){
lastdonation = msg.sender;
if(counter % 5 == 0){
winner = msg.sender;
winnerbool =true;
message = "congratulation you won 3 Ether";
//if he wins he will get the 3 Ether;
winner.send(msg.value);
}else{
bank.send(msg.value);
winnerbool= false;
message = "No luck. Try it again";
}
}
else{
message = "Transaktion not possible. it is just possible to input
integer ether of one or two.";
}
}我已经有合同的例子了。效果很好。但是,我现在怎样才能调用我的投资()方法,它是应付的,并给合同两个乙醚?
Python:
def clean1():
button1.config(text="Send 1 Ether")
fContract.invest({from: "0x3eC35e7525cDd47c76da8D8BcAA945a64e55096B",
value= "1000000000000000"})
if fContract.functions.Winner().call():
window.after(10, winner)
else:
window.after(10, lose)
button1 = Button(window, text="Send 1 Ether",bg="DodgerBlue4", fg="white",
command=readone)
button1.grid(row=2, column=0)
button1.config(height = 4 , width = 23 )我想做同样的东西,就像云彩正在做的一样。将2以太发送到invest()方法。
百里香薄雾

有人能帮忙吗?
发布于 2018-06-25 12:47:03
使用web3py,您可以访问契约中的函数,我认为这就是您要做的事情。从您的代码中,我得到契约实例是fcontract。
你可以:
fcontract.functions.invest().transact({'from':'you account address','value': web3.toWei(2,'ether')})注意:在执行上面的行之前,请记住解锁您的帐户。
希望这能有所帮助
https://ethereum.stackexchange.com/questions/52020
复制相似问题