这是一个很难解释的问题,我会尽我所能的:
我写了一份更新房产所有权的合同。我有一个卖方(所有者),买方和其他一些功能。
但我希望这份合同是临时合同。由于卖方部署了它,买方(例如)有30秒的时间来签署合同。如果买方不及时签署合同,合同将做一些事情(例如自毁)。签名是将bool属性从false更改为true。
我写了一个修饰符来解释我的目标:
modifier upTo30Seconds
{
if( now-timeOfContractCreation > 30)
{
if(isContractPayed && buyerSign == false)
{
emit notifyCancelOffer(address(this), buyerAddress , oldOwnerAddress); //notifyCancelOffer
selfdestruct(buyerAddress); //Destruct the contract and return ether to the buyer
}
}
_;
}
//'timeOfContractCreation' is another property, initialized in the constructor, and its means the time of deployment (since 01/01/1970)
//'now' is a solidity method which returns the time passed in seconds since 01/01/1970 这个修饰符在函数调用中效果很好,但我希望这些操作是自动执行的。
我的需求有点类似于线程运行。有没有可能使用solidity来实现呢?
发布于 2019-11-20 22:14:11
在没有交易的情况下,不可能自动更改合同状态/数据。但您可以在接收下一个事务时检查时间戳,如果它从创建起已经超过30秒,则忽略它并运行自销毁。
另外,请注意,以太坊中的时间戳不是创建事务的实际时间戳,而是该块的时间戳。
https://stackoverflow.com/questions/58956054
复制相似问题