为什么我没有收到BOOL对象?结果是否包含在我收到的这个奇怪的对象中?
它不是返回bool结果,而是返回一个奇怪的对象,如:
{" TX":" 0x753a987d79c90cb9c71fc312d14472d3d179cb6760708062485c906eb15cc7b1""收据" {" transactionHash":" 0x753a987d79c90cb9c71fc312d14472d3d179cb6760708062485c906eb15cc7b1&#34 ;, " transactionIndex":0," blockHash":" 0x892b62649ea689cdd3e47bd4ac49b6a35fcf414ef10d6a1ccdeb473cb1821233"" blockNumber":413," gasUsed":40486 " cumulativeGasUsed":40486" contractAddress":空,"日志":[{" logIndex":0," transactionIndex& #34;:0," transactionHash":" 0x753a987d79c90cb9c71fc312d14472d3d179cb6760708062485c906eb15cc7b1"" blockHash":" 0x892b62649ea689cdd3e47bd4ac49b6a35fcf414ef10d6a1ccdeb473cb1821233"" blockNumber" :413,"地址":" 0x391737864a8dcdc7b790877dd1b06cfb99067272""数据":" 0x0000000000000000000000000000000000000000000000000000000000000001""主题":[& #34; 0x14d54973c509ce10520c1e0be443c7340095855c124ddda2a3627d4fa542d8 51"" 0x0000000000000000000000000000000000000000000000000000000000000001&#34],"类型":"开采"}],"状态":1},&#34 ;日志":[{" logIndex":0," transactionIndex":0," transactionHash":" 0x753a987d79c90cb9c71fc312d14472d3d179cb6760708062485c906eb15cc7b1"&# 34; blockHash":" 0x892b62649ea689cdd3e47bd4ac49b6a35fcf414ef10d6a1ccdeb473cb1821233"" blockNumber":413,"地址":" 0x391737864a8dcdc7b790877dd1b06cfb99067272""类型& #34;:"开采""事件":"升级"" ARGS" {" _tokenId&#34 ;: " 1"" _upgradeType":" 1"}}]}
答案 0 :(得分:0)
事务无法将值返回给启动事务的客户端。当客户端启动事务时,您提供的回调将被触发两次。一旦提交事务但在被挖掘之前(事务哈希)。第二个是在开采交易(收据)之后。有关使用web3js 1.0的示例,请参阅this(对于web3js 0.20.x和web3j,它类似)。
但是,当从另一个合同调用时,您可以从非常量函数返回。这两个函数在挖掘时都会在同一个EVM中执行,因此在那里返回一个值。
如果需要将事务中的值返回给客户端,则需要1)将值存储到合同状态,然后在挖掘事务后调用<li id="ember1645" class="message-line chat-line ember-view"><!----> <div>
<span class="timestamp float-left">6:24</span>
<!----><!----> <span class="badges float-left">
<!----> </span>
<span style="color:#FF0000" class="from" data-ember-action="" data-ember-action-1646="1646">getsomelight</span><span class="colon">:</span>
<span style="" class="message">
No stream today?
</span>
<!----><!----> </div><!----></li>
函数以检索值您的客户,或2)通过event登录并在您的客户端设置一个监听器。