{"id":430,"date":"2021-06-08T10:52:50","date_gmt":"2021-06-08T02:52:50","guid":{"rendered":"https:\/\/www.paralism.com\/info\/docs\/paralism-%e6%99%ba%e8%83%bd%e5%90%88%e7%ba%a6%e5%bc%80%e5%8f%91%e6%89%8b%e5%86%8c\/%e6%99%ba%e8%83%bd%e5%90%88%e7%ba%a6%e8%af%ad%e8%a8%80%e4%bb%8b%e7%bb%8d\/%e7%a8%8b%e5%ba%8f%e6%a0%b7%e4%be%8b\/"},"modified":"2021-06-08T11:17:22","modified_gmt":"2021-06-08T03:17:22","slug":"%e7%a8%8b%e5%ba%8f%e6%a0%b7%e4%be%8b","status":"publish","type":"docs","link":"https:\/\/www.paralism.com\/info\/docs\/paralism-%e6%99%ba%e8%83%bd%e5%90%88%e7%ba%a6%e5%bc%80%e5%8f%91%e6%89%8b%e5%86%8c\/%e6%99%ba%e8%83%bd%e5%90%88%e7%ba%a6%e8%af%ad%e8%a8%80%e4%bb%8b%e7%bb%8d\/%e7%a8%8b%e5%ba%8f%e6%a0%b7%e4%be%8b\/","title":{"rendered":"\u7a0b\u5e8f\u6837\u4f8b"},"content":{"rendered":"\n<p><strong>\u5408\u7ea6\u5e93\u6837\u4f8b\uff1a<\/strong>\u5b9a\u4e49\u4e00\u4e2a\u5408\u7ea6\u7c7b\uff0c\u5e76\u5bfc\u51fa\u8be5\u7c7b\u4f5c\u4e3a\u5408\u7ea6\u5e93\uff0c\u4f9b\u5176\u5b83\u667a\u80fd\u5408\u7ea6\u4ee3\u7801\u8c03\u7528\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Student2 { \/\/\u5b9a\u4e49\u4e00\u4e2a\u7c7bStudent2 \n  constructor(name, sex, age) {\n    this.name = name;\n    this.sex = sex;\n    this.age = age;\n  }\n  toString() { \/\/\u81ea\u5b9a\u4e49\u683c\u5f0f\u5316\u8f93\u51fa\uff0c\u53ef\u4f9b\u6267\u884c\u7ed3\u679c\u94fe\u4e0a\u5b58\u50a8\n    return 'The Student v2 is ' + this.name + ', and sex is ' + this.sex + ',age is ' + this.age;\n  }\n}\nexport {Student2}  \/\/\u58f0\u660eStudent2\u53ef\u88ab\u5176\u5b83\u5408\u7ea6\u4ee3\u7801\u5bfc\u5165\u4f7f\u7528\uff0c\u5173\u952e\u8bed\u53e5\u3002\u5982\u679c\u7f3a\u5931\uff0cStudent2\u65e0\u6cd5\u88ab\u5176\u4ed6\u5408\u7ea6\u5bfc\u5165\u4f7f\u7528\u3002<\/code><\/pre>\n\n\n\n<p><strong>\u6ce8\uff1a<\/strong>\u5408\u7ea6\u5e93\u7f16\u8bd1\u540e\u7684\u5b57\u8282\u7801\u90e8\u7f72\u4e0a\u94fe\u53d1\u5e03\u4e4b\u540e\uff0c\u53d1\u5e03\u8005\u5c06\u83b7\u5f97\u8be5\u5408\u7ea6\u5e93\u7684\u533a\u5757\u94fe\u5730\u5740\uff08\u8d85\u5757\u94fe\u533a\u5757\u5730\u5740\u4e09\u5143\u7ec4\u548c\u533a\u5757\u54c8\u5e0c\uff09\uff0c\u8c03\u7528\u5408\u7ea6\u53ef\u4ee5\u901a\u8fc7\u8be5\u533a\u5757\u5730\u5740\u5bfc\u5165\u5408\u7ea6\u5e93\u3002<\/p>\n\n\n\n<p><strong>\u5408\u7ea6\u8fc7\u7a0b\u6837\u4f8b\uff1a<\/strong>\u5bfc\u5165\u5df2\u90e8\u7f72\u5728\u533a\u5757\u94fe\u4e0a\u7684\u5408\u7ea6\u5e93\uff0c\u8c03\u7528\u6267\u884c\u521b\u5efaStudent2\u5b9e\u4f8b\uff0c\u8c03\u7528\u53e6\u4e00\u4e2a\u667a\u80fd\u5408\u7ea6\u8fc7\u7a0b\uff0c\u6700\u540e\u8f93\u51fa\u8fd0\u7b97\u7ed3\u679c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>contract.importas( \/\/\u5bfc\u5165\u8981\u8c03\u7528\u7684\u5408\u7ea6\u5e93\n  &#91;443,1,1], \n  \"d1cad57bab030f3e897f322242e8706591f3d1aff0757a555115372859cd762d\", \n  \"StudentEx\"\n);\n\nlet st1 = new StudentEx.Student2('Tom','male', 18);\nlet st2 = contract.call(&#91;3,2,6], '');\/\/\u8c03\u7528\u533a\u5757&#91;3,2,6]\u4e2d\u7684\u5408\u7ea6\u8fc7\u7a0b\nst1.toString() + \"\\n\" + st2.toString();\/\/\u6267\u884c\u7ed3\u679c\u683c\u5f0f\u5316\u8f93\u51fa<\/code><\/pre>\n\n\n\n<p><strong>\u6ce8\uff1acontract<\/strong>\u5408\u7ea6\u7c7b\u7528\u4e8e\u5408\u7ea6\u4ee3\u7801\u7684\u6a21\u5757\u5316\u7ec4\u7ec7\uff0c\u662f\u8d85\u5757\u94fe\u667a\u80fd\u5408\u7ea6\u8bed\u8a00\u7684\u57fa\u7840\u7c7b\u4e4b\u4e00\uff0c\u5b83\u63d0\u4f9b<strong>importas<\/strong>\u65b9\u6cd5\u5bfc\u5165\u5408\u7ea6\u5e93\uff0c<strong>call<\/strong>\u65b9\u6cd5\u8c03\u7528\u5176\u5b83\u5408\u7ea6\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p>contract\u7c7b\u7684\u58f0\u660e\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class contract {\n  JSValue importas(\n    vector&lt;int&gt; tripleaddr, \n    const std::string&amp; localblkhash, \n    const string&amp; modulename\n  );\n  JSValue call(\n    vector&lt;int&gt; tripleaddr, \n    const std::string&amp; localblkhash\n  );\n};<\/code><\/pre>\n\n\n\n<p><strong>\u6ce8\uff1a<\/strong>\u5176\u4e2d\uff0c<strong>importas<\/strong>\u65b9\u6cd5\u7684\u53c2\u6570\u4e2d\uff0c<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>tripleaddr\u4e3a\u8d85\u5757\u94fe\u4e2d\u5b50\u94fe\u533a\u5757\u7684\u4e09\u5143\u7ec4\u5730\u5740\uff0c\u65b9\u6cd5\u4ece\u6307\u5b9a\u7684\u533a\u5757\u4e2d\u83b7\u53d6\u5408\u7ea6\u6a21\u5757\u5bfc\u5165\u5230\u5f53\u524d\u5408\u7ea6\u4e2d\u4f9b\u540e\u7eed\u8c03\u7528\u4f7f\u7528\u3002<\/li><li>localblkhash\u662f\u4e09\u5143\u7ec4\u5730\u5740\u5bf9\u5e94\u7684\u533a\u5757hash\uff0c\u7528\u4e8e\u533a\u5757\u6821\u9a8c\uff0c\u4e5f\u53ef\u4ee5\u7559\u7a7a\u3002<\/li><li>modulename\u662f\u5bfc\u5165\u5408\u7ea6\u5e93\u7684\u522b\u540d\uff0c\u53ef\u4efb\u610f\u8bbe\u5b9a\u4e3a\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u89e3\u51b3\u591a\u4e2a\u5408\u7ea6\u5e93\u95f4\u53ef\u80fd\u7684\u540d\u5b57\u51b2\u7a81\uff0c\u907f\u514d\u6267\u884c\u7ed3\u679c\u5f02\u5e38\u3002<\/li><\/ul>\n\n\n\n<p>\u5176\u4e2d\uff0c<strong>call<\/strong>\u65b9\u6cd5\uff0c\u7528\u4e8e\u76f4\u63a5\u8fd0\u884c\u6307\u5b9a\u533a\u5757\u4e2d\u7684\u5408\u7ea6\u8fc7\u7a0b\uff1b<\/p>\n\n\n\n<p>\u6b64\u5916\uff0c\u5408\u7ea6\u8fc7\u7a0b\u6267\u884c\u5b8c\u6210\u540e\uff0c\u6267\u884c\u7ed3\u679c\u53ef\u901a\u8fc7\u8bed\u53e5st1.toString() + &#8220;\\n&#8221; + st2.toString();\u5b9e\u73b0\u683c\u5f0f\u5316\u8f93\u51fa\uff0c\u5e94\u7528\u7a0b\u5e8f\u53ef\u901a\u8fc7Paralism\u8282\u70b9\u63a5\u53e3\u5c06\u5408\u7ea6\u8fc7\u7a0b\u63d0\u4ea4\u5230Paralism\u8282\u70b9\u7684\u865a\u62df\u673a\u4e2d\u8fd0\u884c\uff0c\u63d0\u4ea4\u7684\u5408\u7ea6\u8fc7\u7a0b\u5b57\u8282\u7801\u548c\u683c\u5f0f\u5316\u8f93\u51fa\u7684\u6267\u884c\u7ed3\u679c\u5728\u6267\u884c\u5b8c\u6210\u540e\u5c06\u7531\u8282\u70b9\u81ea\u52a8\u63d0\u4ea4\u4e0a\u94fe\u5b58\u50a8\u3002<\/p>\n","protected":false},"featured_media":0,"parent":429,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-430","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/www.paralism.com\/info\/wp-json\/wp\/v2\/docs\/430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.paralism.com\/info\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.paralism.com\/info\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/www.paralism.com\/info\/wp-json\/wp\/v2\/comments?post=430"}],"version-history":[{"count":1,"href":"https:\/\/www.paralism.com\/info\/wp-json\/wp\/v2\/docs\/430\/revisions"}],"predecessor-version":[{"id":449,"href":"https:\/\/www.paralism.com\/info\/wp-json\/wp\/v2\/docs\/430\/revisions\/449"}],"up":[{"embeddable":true,"href":"https:\/\/www.paralism.com\/info\/wp-json\/wp\/v2\/docs\/429"}],"next":[{"title":"\u5f00\u53d1\u73af\u5883\u51c6\u5907","link":"https:\/\/www.paralism.com\/info\/docs\/paralism-%e6%99%ba%e8%83%bd%e5%90%88%e7%ba%a6%e5%bc%80%e5%8f%91%e6%89%8b%e5%86%8c\/%e6%99%ba%e8%83%bd%e5%90%88%e7%ba%a6%e8%af%ad%e8%a8%80%e4%bb%8b%e7%bb%8d\/%e5%bc%80%e5%8f%91%e7%8e%af%e5%a2%83%e5%87%86%e5%a4%87\/","href":"https:\/\/www.paralism.com\/info\/wp-json\/wp\/v2\/docs\/431"}],"wp:attachment":[{"href":"https:\/\/www.paralism.com\/info\/wp-json\/wp\/v2\/media?parent=430"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.paralism.com\/info\/wp-json\/wp\/v2\/doc_tag?post=430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}