{"id":1205,"date":"2019-05-25T11:16:39","date_gmt":"2019-05-25T03:16:39","guid":{"rendered":"http:\/\/lovewut.pw\/?p=1205"},"modified":"2019-05-25T11:16:39","modified_gmt":"2019-05-25T03:16:39","slug":"%e8%8e%b7%e5%8f%96%e5%90%88%e7%ba%a6%e8%bf%94%e5%9b%9e%e5%80%bc%e7%9a%84%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/bloo.heing.fun\/?p=1205","title":{"rendered":"\u83b7\u53d6\u5408\u7ea6\u8fd4\u56de\u503c\u7684\u65b9\u6cd5"},"content":{"rendered":"<p>1. solidity\u7684\u5408\u7ea6\u4e2d\uff0c\u8bbe\u5b9a\u51fd\u6570\u4e3aview\u7c7b\u578b\uff0c\u5982<\/p>\n<pre>function getAgent(address _agentAddress) public view returns(address _parentAddress, address _grandpaAddress){\r\n    require(agents[_agentAddress].isUsed, \"address_none\");\r\n\r\n    return (agents[_agentAddress].parentAddress, agents[_agentAddress].grandpaAddress);\r\n}<\/pre>\n<p>\u8fd9\u6837\u901a\u8fc7web3j\u751f\u6210\u7684java\u51fd\u6570\u4e3a<\/p>\n<pre>public RemoteCall&lt;Tuple2&lt;Address, Address&gt;&gt; getAgent(Address _agentAddress) {\r\n    final Function function = new Function(\"getAgent\", \r\n            Arrays.&lt;Type&gt;asList(_agentAddress), \r\n            Arrays.&lt;TypeReference&lt;?&gt;&gt;asList(new TypeReference&lt;Address&gt;() {}, new TypeReference&lt;Address&gt;() {}));\r\n    return new RemoteCall&lt;Tuple2&lt;Address, Address&gt;&gt;(\r\n            new Callable&lt;Tuple2&lt;Address, Address&gt;&gt;() {\r\n                @Override\r\n                public Tuple2&lt;Address, Address&gt; call() throws Exception {\r\n                    List&lt;Type&gt; results = executeCallMultipleValueReturn(function);\r\n                    return new Tuple2&lt;Address, Address&gt;(\r\n                            (Address) results.get(0), \r\n                            (Address) results.get(1));\r\n                }\r\n            });\r\n}<\/pre>\n<p>\u63a5\u7740\uff0c\u4f7f\u7528\u7684\u8bdd\u5982\u4e0b\uff1a<\/p>\n<pre>RemoteCall&lt;Tuple2&lt;Address, Address&gt;&gt; tuple2RemoteCall = MainContractController.mainContract.getAgent(_agentAddress);\r\nTuple2&lt;Address, Address&gt; addressAddressTuple2 = tuple2RemoteCall.send();<\/pre>\n<p>2. \u5982\u679c\u51fd\u6570\u4e0d\u80fd\u662fView\u7c7b\u578b\uff0c\u5219solidity\u4e2d\u53ea\u80fd\u901a\u8fc7emit\u4e8b\u4ef6\u4e86\u3002<\/p>\n<p>emit eventName(&#8230;)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. solidity\u7684\u5408\u7ea6\u4e2d\uff0c\u8bbe\u5b9a\u51fd\u6570\u4e3aview\u7c7b\u578b\uff0c\u5982 function getAgent(address [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[56,55,49],"class_list":["post-1205","post","type-post","status-publish","format-standard","hentry","category-36","tag-dapp","tag-solidity","tag-web3j"],"_links":{"self":[{"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=\/wp\/v2\/posts\/1205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1205"}],"version-history":[{"count":1,"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=\/wp\/v2\/posts\/1205\/revisions"}],"predecessor-version":[{"id":1206,"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=\/wp\/v2\/posts\/1205\/revisions\/1206"}],"wp:attachment":[{"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bloo.heing.fun\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}