æè¿ããããã¯ãã§ãŒã³ãæå·é貚ãã¹ããŒãã³ã³ãã©ã¯ããããã³é¢é£æè¡ãäžå¿ã«åäŸã®ãªãèªå€§å®£äŒãå¢ããŠããŸãã æãæ zyã§ååçãªçºæ°ã§ããããããã沌å°ããããããã©ã³ãããããŠãããšããæããããŸãã ITããµãŒãã¹ãå°å£²ãçµæžã®å®æ¥çã®åéã§æŽå²ãšçµéšãæã€èšå€§ãªæ°ã®æ°èäŒæ¥ãäŒæ¥ãã掻åã«ãããã¯ãã§ãŒã³ãå°å ¥ããããšèããŠããã100,000以äžã®äŒæ¥ããã§ã«ãããè¡ã£ãŠããŸãã
Initial Coin Offeringã¡ã«ããºã ã¯ãã¯ã©ãŠããã¡ã³ãã£ã³ã°ãžã®æ°ããªé¢å¿ã®æ³¢ã«è²¢ç®ããã ãã§ãªãããã®å©ãã«ãã£ãŠåŒãä»ããããæè³ã®éãå¢ãããã ãã§ãªããæå·é貚ãšãããã¯ãã§ãŒã³ãã¯ãããžãŒãžã®é¢å¿ãåºæ¿ããŸããã ä»æ¥ããã®åéã®æ°ããæ¬ å¡ã«åºãããããšãå€ããªããäžè¬çã«ICOãå®æœããç¹ã«ã¹ããŒãã³ã³ãã©ã¯ããéçºããããã®æ¯æŽãæ±ããŠããŸãã
æ®å¿µãªãããä»æ¥ã§ã¯ãã®åéã®å°é家ãéåžžã«äžè¶³ããŠããŸãããå®éã«ã¯ã¹ããŒãã³ã³ãã©ã¯ãã®éçºããã»ã¹ã¯äžèŠãããšæããããããã¯ããã«åçŽã§ãã ã¹ãã·ã£ãªã¹ãã®äžè¶³ã®åé¡ã¯ããããã¯ãã§ãŒã³ãã¯ãããžãŒãæå·é貚ãããã³ã€ã³ã®åœ¢ã§å€§è¡ãŠãŒã¶ãŒã«å±ããã¹ããŒãã³ã³ãã©ã¯ãããã£ãšåŸã«ãããã¯ãã§ãŒã³ã«ãã£ãŠãããšããäºå®ã«çŽæ¥èµ·å ããŠããŸãã å人çã«ã¯ãã¹ããŒãã³ã³ãã©ã¯ãã®éçºã«é¢ããè³æããŸã éåžžã«å°ãªããšããäºå®ã«ã¯ããŸãé©ããŸããã§ããã
äžæ¹ããããã¯ãã§ãŒã³ããŒã¹ã®ããžã¿ã«ç®¡èœãæ§ç¯ããããã°ã©ãã³ã°ã¹ãã«ãæããªãäžè¬ãŠãŒã¶ãŒåãã®ã¹ããŒãã³ã³ãã©ã¯ããäœæããããã»ã¹ãç°¡çŽ åããäŒç€Ÿã®ãã¯ãã«ã«ãã£ã¬ã¯ã¿ãŒãšããŠããã¯ãããžãŒãç解ããããã«è¯ããªãæè¡å°é家ã®å¿ èŠæ§ãæããŠããŸã-圌女ãšã®ä»äºã®çµéšã
ãã®èšäºã§ã¯ãã¹ããŒãã³ã³ãã©ã¯ãã®éçºã«å ¥ãããã®ãããå€ãå®éã«ã¯éåžžã«äœãããšã瀺ããæ°ããéçºè ããã®åéã«åŒãä»ããããšããŸãã ãã¡ããã人çã®ãã¹ãŠããã¬ãŒãã³ã°è³æã®ããã«åçŽã§ããããã§ã¯ãããŸããããŸããã¹ããŒãã³ã³ãã©ã¯ãã®éçºã«ã¯å€ãã®åŸ®åŠãªç¹ããããŸãã ããã«ãããããããããã¯å€ãã®äººã«éŠŽæã¿ã®ããJavaScriptãå«ãä»ã®ãã¯ãããžãŒã«ãåœãŠã¯ãŸããŸããããã«ãããååãšããŠãå®çšçãªçµéšã察åŠã«åœ¹ç«ã¡ãŸããããã¯ãéçºè ãããââã°ã©ãã³ã°ãèšèšãå®éšããã¹ããéåžžã¯åŸäºããŠããŸãã
ãã®ã¬ãã¹ã³ã§ã¯ãéçºãéå§ããããã«å¿ èŠãªãã¹ãŠã®ããŒã«ãšãã¬ãŒã ã¯ãŒã¯ãã€ã³ã¹ããŒã«ããSolidityèšèªã§æåã®ERC20ããŒã¯ã³ãäœæããã³ã³ãã€ã«ããããŒã«ã«ãããã¯ãã§ãŒã³ã§å ¬éããããã€ãã®ãã¹ããäœæããŠå®è¡ããŸãã ãã¬ãŒã ã¯ãŒã¯truffleã䜿çšããŸããããã¯ã移è¡ç®¡çãã³ã³ãã€ã«ãäŸåé¢ä¿ç®¡çãããã³ãã¹ãã«åœ¹ç«ã¡ãŸãã ãŸãã OpenZeppelinãã¬ãŒã ã¯ãŒã¯ã䜿çšããŸãã ãã®ãã¬ãŒã ã¯ãŒã¯ã«ã¯ã Solidityèšèªã§æžãããäžé£ã®å¥çŽãšã©ã€ãã©ãªãå«ãŸããŠããããããã®æçšæ§ãšå®å šæ§ããã§ã«èšŒæãããŠããŸãã
ã¯ããã«ããã¬ãŒã ã¯ãŒã¯ããªã¥ããã€ã³ã¹ããŒã«ããŸãããã ãããè¡ãã«ã¯ããã¬ãŒã ã¯ãŒã¯ã®ããã¥ã¡ã³ãã«ç§»åããããã§ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®ã€ã³ã¹ããŒã«æé ãèŠã€ããŸãã ã€ã³ã¹ããŒã«åŸããããžã§ã¯ãçšã®ãã©ã«ããŒãäœæããŸãã ç§ã®å Žåããã®ãã©ã«ããŒã¯ãjcr-tokenããšããååã«ãªããŸãããã®åŸãã¿ãŒããã«ã§äœæãããããžã§ã¯ããã©ã«ããŒãéãã
truffle init
ã³ãã³ãã䜿çšããŠãããžã§ã¯ããåæåããŸãã
次ã«ããæ°ã«å ¥ãã®ããã¹ããšãã£ã¿ãŒã§ãããžã§ã¯ããéããŸãïŒç§ã¯Atomã䜿çšããŠããŸãïŒã ãããžã§ã¯ãã®æ§é ãèŠãŠã¿ãŸãããã æåã¯ãã«ãŒããã£ã¬ã¯ããªã«3ã€ã®ãã©ã«ããŒããããŸãã
- ã¹ããŒãã³ã³ãã©ã¯ãã®ãœãŒã¹ã³ãŒããæ ŒçŽããããã«èšèšãããã³ã³ãã©ã¯ãã
- ç§»è¡ ããããã¯ãã§ãŒã³ã«å¥çŽãå ¬éããããã«äœ¿çšããã移è¡ãã¡ã€ã«ãå«ã¿ãŸã;
- å¥çŽã®ãã¹ããå«ããã¹ãã ãã¹ãã¯SolidityãšJavaScriptã®äž¡æ¹ã§äœæã§ããããšã«æ³šæããããšãéèŠã§ããäœããç解ã§ããªãå Žåã§ãå¿é ããå¿ èŠã¯ãããŸãããåéšåã«ã€ããŠè©³ãã説æããå¥çŽã移è¡ããã¹ãã®äœææ¹æ³ãåŠã³ãŸãã
ãæ°ã¥ããããããŸããããããªã¥ãã¯ãã§ã«ããã€ãã®ç°¡åãªã¹ããŒãã³ã³ãã©ã¯ããäœæããŠããŸãã ãããã䜿çšããŠã€ã³ã¹ããŒã«ããã¹ãããŸãã
ã³ã³ãã©ã¯ããšå¯Ÿè©±ããŠãã¹ããäœæããã«ã¯ããŸããããã¯ãã§ãŒã³ã§å ¬éããå¿ èŠããããŸãã ç§ãã¡ã®å Žåããããã®ç®çã®ããã«testrpcãšåŒã°ãã軜ãã€ãŒãµãªã¢ã ã¯ã©ã€ã¢ã³ãã䜿çšããããšããå§ãããŸãã éåžžã®ã€ãŒãµãªã¢ã ãããã¯ãŒã¯ã¯ã©ã€ã¢ã³ãã®åäœããšãã¥ã¬ãŒãããã ãã§ãããã¯ããã«é«éã«åäœããæ¶è²»ãããªãœãŒã¹ãå°ãªããããåªããéçºããŒã«ã«ãªããŸãã ã€ã³ã¹ããŒã«åŸãã¿ãŒããã«ã§
testrpc
ãšå ¥åããã ãã§ãç¬èªã®éçºãããã¯ãã§ãŒã³ãéå§ã§ããŸãã
æ£åžžã«èµ·åãããšããããã¯ãã§ãŒã³ã®ãã¹ããšããŒãã衚瀺ãããŸãã ãããžã§ã¯ãã®ã«ãŒããã£ã¬ã¯ããªã«ãã `truffle.js`ãã¡ã€ã«ãéããŸãã ãã®ãã¡ã€ã«ã«ã¯ããããžã§ã¯ãã®æ§æãå«ãŸããŠããŸãã æ§æå ã®ãã¹ããšããŒãããå®è¡äžã®testrpcã®ãã¹ããšããŒããšäžèŽããŠããããšã確èªããŠãã ããã
ã§ã¯ã
truffle compile
å ¥åããŠãã¹ããŒãã³ã³ãã©ã¯ããã³ã³ãã€ã«ããŠã¿ãŸãããã ãã®æé ã«ããããã«ããã£ã¬ã¯ããªã«ãã¡ã€ã«ãçæãããŸãã ã³ã³ãã€ã«ãåããŠå®è¡ãããšããã£ã¬ã¯ããªãèªåçã«äœæãããŸãã ãã«ãã¢ãŒãã£ãã¡ã¯ãã¯ãã®ãã©ã«ããŒã«é 眮ãããŸãã ãããã«ã€ããŠã¯å°ãåŸã§èª¬æããŸãã
å¥çŽããã¹ãããã«ã¯ã
truffle test
ãŸãã JavaScriptãŸãã¯ä»ã®èšèªã®åäœãã¹ãã«ç²ŸéããŠããå Žåã¯ãã¹ããŒãã³ã³ãã©ã¯ãããã¹ãããæ¹æ³ãæ¢ã«ç¥ã£ãŠããŸãã ãããã¯ãã§ãŒã³ã®ãšã©ãŒã®äŸ¡æ Œã¯éåžžã«é«ãããããã¹ãã«ã¯ç¹ã«æ³šæããŠãã ããïŒ ãã¹ããå®è¡ããåã«ã³ã³ãã©ã¯ããããªã³ã³ãã€ã«ããå¿ èŠãããããŸããã`test`ã³ãã³ãããããèªåçã«è¡ãããã§ãã
æåŸã«ãtestrpcãããã¯ãã§ãŒã³ã§å¥çŽãå ¬éãã移è¡ãå®è¡ããã«ã¯ã
truffle migrate
ãŸãã
ãã®åŸããã«ãã¿ãŒããã«ã«ã³ãã³ãã®åºåã衚瀺ãããtestrpcã¯ã©ã€ã¢ã³ãã«ã€ãã³ãã®åºåã衚瀺ãããŸãã ããã§ãšãããããŸãïŒ æåã®ã¹ããŒããããã¯ãã§ãŒã³ãããã¯ãŒã¯ãšãã¥ã¬ãŒã¿ãŒå¥çŽãå ¬éããŸããã
ããé«åºŠãªã³ã³ãã©ã¯ããäœæããã«ã¯ãOpenZeppelinãã¬ãŒã ã¯ãŒã¯ã䜿çšããŸããããã«ã¯ãããã€ãã®éåžžã«äŸ¿å©ãªã©ã€ãã©ãªãã€ã³ã¿ãŒãã§ã€ã¹ãæ¢è£œã®ã³ã³ãã©ã¯ããå«ãŸããŠããŸãã Solidityèšèªã¯ç¶æ¿ããµããŒãããŠãããæ¢åã®ã³ã³ãã©ã¯ãã®æ©èœãç°¡åã«æ¡åŒµã§ããããšã«æ³šæããŠãã ããã ããã«ãããã¢ãŒããã¯ãã£ãçèãã倧ããªæ©äŒãéãããŸãã
ãæ°ã«å ¥ãã®äŸåé¢ä¿ãããŒãžã£ãŒïŒnpmãyarnãªã©ïŒã䜿çšããŠãä»ã®JavaScriptã©ã€ãã©ãªãšåãããã«OpenZeppelinãã€ã³ã¹ããŒã«ã§ããŸãã 詳现ã«ã€ããŠã¯ãgithubã®OpenZeppelinãããžã§ã¯ãããŒãžãŸãã¯ãã®Webãµã€ããåç §ããŠãã ããã
ãã®ãããç¬èªã®ã¹ããŒãã³ã³ãã©ã¯ãã®éçºãéå§ããããã«å¿ èŠãªãã®ããã¹ãŠã€ã³ã¹ããŒã«ããŸããã ãããŠãããã»ã©é£ãããªãã£ãã§ãããïŒ
ããã§ã¯ãããã¹ããšãã£ã¿ã«é²ã¿ããããžã§ã¯ããã¡ã€ã«ãèŠãŠã¿ãŸãããã ããªã¥ããåæåäžã«ããã€ãã®åºæ¬çãªã³ã³ãã©ã¯ãããã§ã«äœæããŠããããšã«æ°ä»ããããããŸããã 移è¡ãã¡ã€ã«ãé€ããããããã¹ãŠã®ãã¡ã€ã«ãåé€ããŸãããã äœåãªã³ã³ãã©ã¯ããã©ã€ãã©ãªããã¹ããåé€ãã移è¡ããããã€ãã®ã³ãŒããåé€ããŸãã
ã«ã¹ã¿ã ã¹ããŒãã³ã³ãã©ã¯ãã®ã³ãŒãã䜿çšããŠãæ°ãããœãªãããã¡ã€ã«ãäœæããŸãã Jincor ICOãå®è¡ããããã«JCRãšããããŒã¯ã³ãäœæããŸããã€ãŸãããã¡ã€ã«ã«JCR.solãšããååãä»ããŸãã
Solidityã¯ãããªãæ°ãããã€ãããã¯ãªããã°ã©ãã³ã°èšèªã§ãã ããã«ããç¹å®ã®äžäŸ¿ãçããŸããããã®1ã€ã¯é »ç¹ãªå€æŽã§ããããã®äžéšã¯åŸæ¹äºææ§ãç Žå£ããæ¢ã«å ¬éãããŠããå¥çŽã§åé¡ãåŒãèµ·ããå¯èœæ§ããããŸãã ãããé²ãã«ã¯ãSolidityèšèªã³ã³ãã€ã©ã®ããŒãžã§ã³ãæå®ããå¿ èŠããããŸãã å人çã«ã¯ã `^ 0.4.11`ã䜿çšããŸãã
ãã㧠`^`ã¯ãå³å¯ã«æå®ãããããŒãžã§ã³0.4.11ã§ã¯ãªããæ°ãããã€ããŒããŒãžã§ã³ãšãã°ä¿®æ£ã«ãæºè¶³ããŠããããšãæå³ããŸãã npmã§è¡ãããã«ãã¯ããã«æè»ãªããŒãžã§ã³ç®¡çãã¿ãŒã³ãå®çŸ©ã§ããŸãã
ãã§ã«è¿°ã¹ãããã«ãOpenZeppelinã©ã€ãã©ãªã®äžéšã®ã³ã³ãã©ã¯ãã䜿çšããŠãè»èŒªãåçºæããã®ã§ã¯ãªããã³ãã¥ããã£ã®ãã¹ããã©ã¯ãã£ã¹ãå«ã¿ãå®æçã«ã»ãã¥ãªãã£ç£æ»ãå®æœãããäœæ¥çšã®å®å šãªãã©ã¯ãã£ã¹ã䜿çšããŸãã
ã³ã³ãã©ã¯ããã€ã³ããŒãããã«ã¯ãããŒã¯ãŒã `import`ã䜿çšããåŒçšç¬Šã§ã€ã³ããŒããããã¡ã€ã«ãžã®ãã¹ã瀺ãå¿ èŠããããŸããããšãã°ã次ã®ããã«ããŸãã`import" zeppelin-solidity / contracts / token / MintableToken.sol ";`
OpenZeppelinã®ããã¥ã¡ã³ããæåããæåŸãŸã§èªã¿ãã¹ããŒãã³ã³ãã©ã¯ãã®å®è£ ã確èªããŠãã©ã®ããã«æ©èœããããæ確ã«ææ¡ããããšã匷ããå§ãããŸãã ããã«ã調æ»äžã«ã³ãŒãèšèšã®äŸãèŠãããšãã§ããæ°ããå¥çŽãæžãããã®ã€ã³ã¹ãã¬ãŒã·ã§ã³ãèŠã€ããããšãã§ããŸãã ãœãŒã¹ã¯node_modulesãã£ã¬ã¯ããªã«ãããŸãã
ä»æ¥äœ¿çšããMintableããŒã¯ã³ãèŠãŠã¿ãŸãããã ç§ã®å©ããªãã«ãœãŒã¹ã³ãŒããšããã¥ã¡ã³ãã«æ £ããããšãã§ããã®ã§ãããã§ã¯è©³çŽ°ã«æ·±ãæãäžããŸããã æãéèŠãªãã®ã ãã説æããŸãã
ãMintableããŒã¯ã³ã¯OwnableãStandardããŒã¯ã³ãã§ããããšãããããŸãã ãisãããŒã¯ãŒãã¯ãJavaãŸãã¯PHPã®ãextendsããšã»ãŒåãããšãæå³ããŸãã MintableããŒã¯ã³ã³ã³ãã©ã¯ãã¯ã2ã€ã®ã€ãã³ãã1ã€ã®ãããªãã¯ããããã£ã2ã€ã®ä¿®é£Ÿåãããã³2ã€ã®é¢æ°ãè¿œå ããŸãã ããã«ãããããŒã¯ã³ãçºè¡ããæ©èœãæ§æãããŸãã æšæºããŒã¯ã³ã¯ã以åã«ååŸããèš±å¯ãæã€å¥ã®ãŠãŒã¶ãŒã«ä»£ãã£ãŠããŒã¯ã³ã転éããæ©èœãè¿œå ããŸãã åºæ¬ããŒã¯ã³ã¯ãããŒã¯ã³è»¢éãšãã©ã³ã¹ãã§ãã¯ãå®çŸ©ããERC20Basicã€ã³ã¿ãŒãã§ã€ã¹ã®åãªãå®è£ ã§ãã Ownableã³ã³ãã©ã¯ãã¯onlyOwner修食åãè¿œå ããŸããããã¯éåžžããµãŒãããŒãã£ã®é¢æ°åŒã³åºããå¶éããããã«äœ¿çšãããŸãã
次ã«ãå¥çŽã®ãœãŒã¹ã«æ»ããå°ãå€æŽããŸãã å¿ èŠãªãã¹ãŠã®å¥çŽãã€ã³ããŒãããåŸãç¬èªã®å¥çŽJCRãåŒã³åºããŸãã å¥çŽãã¡ã€ã«ãšååã«åãååãä»ããŠãã ããã
å¥çŽã§ã¯ãå ¬éãããŠããååãèšå·ãå°æ°ç¹ä»¥äžã®æ¡æ°ïŒEthereumã®å Žåã¯18ã«çããïŒãå®çŸ©ããŸãã
contract JCR is MintableToken { string public name = "Jincor Token"; string public symbol = "JCR"; uint public decimals = 18; }
次ã«ãã³ã³ã¹ãã©ã¯ã¿ã³ãŒããèšè¿°ããŸãã ã³ã³ã¹ãã©ã¯ã¿ãŒã¯ãã³ã³ãã©ã¯ãã®ããã«åŒã³åºãããåãªãé¢æ°ã§ãããã³ã³ãã©ã¯ããªããžã§ã¯ããã€ã³ã¹ã¿ã³ã¹åããããšããã€ãŸãæ°ããã€ã³ã¹ã¿ã³ã¹ãäœæããããšãã«åŒã³åºãããŸãã ããã¯åæåã³ãŒãã®ããã®éåžžã«è¯ãå Žæã§ãã å人çã«ã¯ãæå®ãããæ°ã®ããŒã¯ã³ãçºè¡ãããã¹ãŠã®ããŒã¯ã³ãå¥çŽäœæè ã®æ®é«ã«è»¢éã§ããå¥çŽãäœæããŸãã ãããè¡ãã«ã¯ãã³ã³ã¹ãã©ã¯ã¿ã«amountåŒæ°ãè¿œå ããå¥çŽã®äœæè ãææè ãšããŠæå®ããæå®ãããæ°ã®ããŒã¯ã³ãææè ã®ãŠã©ã¬ããã«çºè¡ããŸãã
function JCR(uint256 _amount) { owner = msg.sender; mint(owner, _amount); }
çµæã®JCR.solãã¡ã€ã«ïŒgithubã§ãå ¥æå¯èœïŒ
pragma solidity ^0.4.11; import "zeppelin-solidity/contracts/token/MintableToken.sol"; contract JCR is MintableToken { string public name = "Jincor Token"; string public symbol = "JCR"; uint public decimals = 18; function JCR(uint256 _amount) { owner = msg.sender; mint(owner, _amount); } }
次ã«ãååŸãããã®ãã³ã³ãã€ã«ããŠã¿ãŸãããã ãããè¡ãã«ã¯ããtruffle compileããšå ¥åããŸãã ãã«ããã©ã«ããŒã調ã¹ãŠãåºåã§åŸããããã®ã確èªããŸãããã æåã«ç®ãåŒãã®ã¯ãERC20ããMintableããã³JCRã«äœ¿çšããããã¹ãŠã®å¥çŽã®ã¢ãŒãã£ãã¡ã¯ããåãåã£ãããšã§ãã ã¢ãŒãã£ãã¡ã¯ãã¯JSONãã¡ã€ã«ã«ä¿åãããŸãã ãããã®JSONãã¡ã€ã«ã«ã¯ãã³ã³ãã©ã¯ãã®ååãApplication Binary InterfaceïŒabiïŒãã€ãŒãµãªã¢ã ä»®æ³ãã·ã³ã§åŸã§èµ·åããããã€ããªã³ãŒããããã³è¿œå æ å ±ãå«ãŸããŠããŸãã
ã¢ãŒãã£ãã¡ã¯ãã䜿çšããŠãã¹ããŒãã³ã³ãã©ã¯ãããããã¯ãã§ãŒã³ã«å ¬éã§ããŸãã ãã ããæåããè¯ããã®ã«æ £ããŠã移è¡ãè¿œå ããããšã§ãã®ã«ãŒãã³ããã»ã¹ãããã«èªååããããšããå§ãããŸãã çºè¡ãããããŒã¯ã³ã®æ°ãã³ã³ã¹ãã©ã¯ã¿ã«æž¡ãå¿ èŠãããããšãèŠããŠããŸããïŒ ç§»è¡ã¯ããã®ãããªæäœã«é©ããå Žæã§ãã 2_deploy_contracts.jsãã¡ã€ã«ãéããŠãã³ãŒããè¿œå ããŸãããã 140äžããŒã¯ã³ãçºè¡ããŸãã
deployer.deployã¡ãœããã䜿çšããŠç§»è¡ã¹ã¯ãªããã§ã³ã³ãã©ã¯ããå ¬éã§ããŸãããã®ã¡ãœããã«ã¯ãæåã®åŒæ°ãšããŠãã«ãã¢ãŒãã£ãã¡ã¯ããæž¡ãããã®åŸã«åãé åºã§ã³ã³ãã©ã¯ãã³ã³ã¹ãã©ã¯ã¿ãŒã«æž¡ãããåŒæ°ãæž¡ããŸãã ãã®å ŽåãåŒæ°ã¯1ã€ã ã-1,400,000ã§ãæ®ãã¯ããªã¥ããåŠçããŸãã å±éããã»ã¹ãããç°¡åã§æ¥œãããã®ã«ããããã«ãã¢ã«ãŠã³ãã®ããã¯ã解é€ã§ããŸãïŒã¢ã«ãŠã³ãã«ä»£ãã£ãŠã¢ã¯ã·ã§ã³ãå®è¡ã§ããŸãïŒã ãããè¡ãã«ã¯ãtestrpcãèµ·åãããšãã«ãåŒæ° `-u 0`ãè¿œå ããŸã
var JCR = artifacts.require("./JCR.sol"); module.exports = function(deployer) { const tokenAmount = 1400000; deployer.deploy(JCR, tokenAmount); };
æ°ãã移è¡ãéå§ããæ©èœãããã©ããã確èªããŸãã ãããïŒ æ¬¡ã«ãããŒã¯ã³ãæåŸ ã©ããã«æ©èœããããšã確èªããå¿ èŠããããŸãã ãããè¡ãããã«ãJavaScriptã§ããã€ãã®ãã¹ããäœæããŸãã ãtruffle create testããšãã¹ã察象ã®ã³ã³ãã©ã¯ãã®ååãå ¥åããŠããã¹ãã§JavaScriptãã¡ã€ã«ãçæããŸãã ãã¹ãã¯Solidityã§ãäœæã§ããŸãããããã«ã€ããŠã¯åŸã§èª¬æããŸãã
PHPãªã©ã®ä»ã®ããã°ã©ãã³ã°èšèªã§ãã¹ããäœæããçµéšãããããšãé¡ã£ãŠããŸãã ã¢ã«ãšãã£ã€ã®ãã¬ãŒã ã¯ãŒã¯ã«æ¢ã«åºäŒã£ãããšããããªããããªã¥ãããããã䜿çšããŠããã®ã§ããã¹ãŠã¯ããªãã«éŠŽæã¿ãããããã«æããŸãã 詳现ã«ã€ããŠã¯ãå ¬åŒããã¥ã¡ã³ããã芧ãã ããã
æåŸã«ãå¥çŽã®äœææã«ææè ãæ£ããæ°ã®ããŒã¯ã³ãåãåããããŒã¯ã³è»¢éæ©èœãæåŸ ã©ããã«åäœããããšã確èªããŠã¿ãŸãããã
var JCR = artifacts.require("./JCR.sol"); contract('JCR', function(accounts) { it("Create 1 400 000 tokens at the owner account", function(done) { JCR.deployed().then(function(instance) { return instance.balanceOf.call(accounts[0]); }).then(function(balance) { assert.equal(web3.toWei(balance.valueOf(), 'ether'), web3.toWei(1400000, 'ether'), "1400000 wasn't in the first account"); }); done(); }); it('Should transfer tokens correctly', function(done){ var token; var amount = 10; var account_one = accounts[0]; var account_two = accounts[1]; var acc_one_before; var acc_one_after; var acc_two_before; var acc_two_after; JCR.deployed().then(function(instance){ token = instance; return token.balanceOf.call(account_one); }).then(function(balanceOne) { acc_one_before = balanceOne.toNumber(); return token.balanceOf.call(account_two); }).then(function(balanceTwo) { acc_two_before = balanceTwo.toNumber(); return token.transfer(account_two, amount, {from: account_one}); }).then(function() { return token.balanceOf.call(account_one); }).then(function(balanceOne){ acc_one_after = balanceOne.toNumber(); return token.balanceOf.call(account_two); }).then(function(balanceTwo){ acc_two_after = balanceTwo.toNumber(); assert.equal(acc_one_after, acc_one_before - amount, "Token transfer works wrong!"); assert.equal(acc_two_after, acc_two_before + amount, "Token transfer works wrong!"); }); done(); }); });
ä»æ¥ã¯ä»¥äžã§ãã 次ã®ã¬ãã¹ã³ã§ã¯ãããçŸå®çãªç°å¢ã§å¥çŽããã¹ãããããŒã¯ã³ã®è²©å£²ã«é¢ããICOå¥çŽãäœæããŸãã
ãšããã§ïŒ ãã®èšäºã®ãããªçã¯ã2ã€ã®éšåã§YouTubeã§å ¥æã§ããŸãã
1. éçºã®æºå
2. ããŒã¯ã³ã³ã³ãã©ã¯ãã®äœæ
ã³ãŒãã¯githubã§å ¥æã§ããŸã