diff --git "a/docs/Polygon-ENS-Domain/ja/section-1/lesson-1_\343\203\255\343\203\274\343\202\253\343\203\253\347\222\260\345\242\203\343\201\247\343\202\244\343\203\274\343\202\265\343\203\252\343\202\242\343\203\240\343\203\215\343\203\203\343\203\210\343\203\257\343\203\274\343\202\257\343\202\222\347\253\213\343\201\241\344\270\212\343\201\222\343\202\210\343\201\206.md" "b/docs/Polygon-ENS-Domain/ja/section-1/lesson-1_\343\203\255\343\203\274\343\202\253\343\203\253\347\222\260\345\242\203\343\201\247\343\202\244\343\203\274\343\202\265\343\203\252\343\202\242\343\203\240\343\203\215\343\203\203\343\203\210\343\203\257\343\203\274\343\202\257\343\202\222\347\253\213\343\201\241\344\270\212\343\201\222\343\202\210\343\201\206.md" index 7b04e843b..2e6edccbe 100644 --- "a/docs/Polygon-ENS-Domain/ja/section-1/lesson-1_\343\203\255\343\203\274\343\202\253\343\203\253\347\222\260\345\242\203\343\201\247\343\202\244\343\203\274\343\202\265\343\203\252\343\202\242\343\203\240\343\203\215\343\203\203\343\203\210\343\203\257\343\203\274\343\202\257\343\202\222\347\253\213\343\201\241\344\270\212\343\201\222\343\202\210\343\201\206.md" +++ "b/docs/Polygon-ENS-Domain/ja/section-1/lesson-1_\343\203\255\343\203\274\343\202\253\343\203\253\347\222\260\345\242\203\343\201\247\343\202\244\343\203\274\343\202\265\343\203\252\343\202\242\343\203\240\343\203\215\343\203\203\343\203\210\343\203\257\343\203\274\343\202\257\343\202\222\347\253\213\343\201\241\344\270\212\343\201\222\343\202\210\343\201\206.md" @@ -161,18 +161,10 @@ Give Hardhat a star on Github if you're enjoying it! ðâš https://github.com/NomicFoundation/hardhat ``` -> â ïž: 泚æ #1 +> â ïž: 泚æ > > Windows 㧠Git Bash ã䜿çšããŠããŒãããããã€ã³ã¹ããŒã«ããŠããå Žåããã®ã¹ããã (HH1) ã§ãšã©ãŒãçºçããå¯èœæ§ããããŸããåé¡ãçºçããå Žåã¯ãWindowsCMDïŒã³ãã³ãããã³ããïŒã䜿çšã㊠HardHat ã®ã€ã³ã¹ããŒã«ãå®è¡ããŠã¿ãŠãã ããã -> â ïž: 泚æ #2 -> -> `npx hardhat`ãå®è¡ãããªãã£ãå Žåã以äžãã¿ãŒããã«ã§å®è¡ããŠãã ããã -> -> ``` -> yarn add --dev @nomicfoundation/hardhat-toolbox -> ``` - ãã®æ®µéã§ããã©ã«ããŒæ§é ã¯äžèšã®ããã«ãªã£ãŠããããšã確èªããŠãã ããã ```diff @@ -191,50 +183,39 @@ Polygon-ENS-Domain + âââ test/ ``` -ããã§ã¯ã`contract`ãã£ã¬ã¯ããªå ã«çæããã`package.json`ãã¡ã€ã«ã以äžãåèã«æŽæ°ãããŸãããã +次ã«ãå®å šãªã¹ããŒãã³ã³ãã©ã¯ããéçºããããã«äœ¿çšãããã©ã€ãã©ãª **OpenZeppelin** ãè¿œå ããŸãã + +`packages/contract`ãã£ã¬ã¯ããªã«ããããšã確èªãã以äžã®ã³ãã³ããå®è¡ããŠãã ããã + +``` +yarn add @openzeppelin/contracts@^4.8.2 +``` + +[OpenZeppelin](https://github.com/OpenZeppelin/openzeppelin-contracts) ã¯ã€ãŒãµãªã¢ã ãããã¯ãŒã¯äžã§å®å šãªã¹ããŒãã³ã³ãã©ã¯ããå®è£ ããããã®ãã¬ãŒã ã¯ãŒã¯ã§ãã + +OpenZeppelinã«ã¯éåžžã«å€ãã®æ©èœãå®è£ ãããŠããã€ã³ããŒãããã ãã§å®å šã«ãã®æ©èœã䜿ãããšãã§ããŸãã + +ããã§ã¯ã`packages/contract`ãã£ã¬ã¯ããªå ã®`package.json`ãã¡ã€ã«ãæŽæ°ããŸããããäžèšã®ããã«`"private": true,`ã®äžã«`"scripts":{...}`ãè¿œå ããŠãã ãããããå©çšããã³ãã³ããèšå®ããŠãããŸãã ```diff { "name": "contract", "version": "1.0.0", -- "main": "index.js", -- "license": "MIT", "private": true, - "devDependencies": { - "@nomicfoundation/hardhat-chai-matchers": "^1.0.6", - "@nomicfoundation/hardhat-network-helpers": "^1.0.8", - "@nomicfoundation/hardhat-toolbox": "^2.0.2", - "@nomiclabs/hardhat-ethers": "^2.2.2", - "@nomiclabs/hardhat-etherscan": "^3.1.7", - "@typechain/ethers-v5": "^10.2.0", - "@typechain/hardhat": "^6.1.5", - "chai": "^4.3.7", - "ethers": "^6.1.0", - "hardhat": "^2.13.0", - "hardhat-gas-reporter": "^1.0.9", - "solidity-coverage": "^0.8.2", - "typechain": "^8.1.1" + "scripts": { + "run:script":"npx hardhat run scripts/run.js", + "deploy": "npx hardhat run scripts/deploy.js --network mumbai", + "test": "npx hardhat test" }, -+ "scripts": { -+ "test": "npx hardhat test" -+ } -} + "devDependencies": { ``` -äžèŠãªå®çŸ©ãåé€ããhardhatã®èªåãã¹ããå®è¡ããããã®ã³ãã³ããè¿œå ããŸããã - ### âïž å®è¡ãã ãã¹ãŠãæ©èœããŠããããšã確èªããã«ã¯ã以äžãå®è¡ããŸãã ``` -npx hardhat compile -``` - -次ã«ã以äžãå®è¡ããŸãã - -``` -npx hardhat test +yarn test ``` 次ã®ããã«è¡šç€ºãããŸãã diff --git "a/docs/Polygon-ENS-Domain/ja/section-1/lesson-2_\343\202\271\343\203\236\343\203\274\343\203\210\343\202\263\343\203\263\343\203\210\343\203\251\343\202\257\343\203\210\343\202\222\345\256\237\350\241\214\343\201\227\343\201\246\343\201\277\343\202\210\343\201\206.md" "b/docs/Polygon-ENS-Domain/ja/section-1/lesson-2_\343\202\271\343\203\236\343\203\274\343\203\210\343\202\263\343\203\263\343\203\210\343\203\251\343\202\257\343\203\210\343\202\222\345\256\237\350\241\214\343\201\227\343\201\246\343\201\277\343\202\210\343\201\206.md" index aa28b84a2..53a750541 100644 --- "a/docs/Polygon-ENS-Domain/ja/section-1/lesson-2_\343\202\271\343\203\236\343\203\274\343\203\210\343\202\263\343\203\263\343\203\210\343\203\251\343\202\257\343\203\210\343\202\222\345\256\237\350\241\214\343\201\227\343\201\246\343\201\277\343\202\210\343\201\206.md" +++ "b/docs/Polygon-ENS-Domain/ja/section-1/lesson-2_\343\202\271\343\203\236\343\203\274\343\203\210\343\202\263\343\203\263\343\203\210\343\203\251\343\202\257\343\203\210\343\202\222\345\256\237\350\241\214\343\201\227\343\201\246\343\201\277\343\202\210\343\201\206.md" @@ -9,9 +9,10 @@ Hardhatã䜿çšããå Žåããã¡ã€ã«æ§é ã¯éåžžã«éèŠã§ãã®ã§ã泚æããå¿ èŠããããŸãããã¡ã€ã«æ§é ãäžèšã®ããã«ãªã£ãŠããã°å€§äžå€«ã§ã ð ``` -contract - |_ contracts - |_ Domains.sol +packages +âââ contract + âââ contracts + âââ Domains.sol ``` 次ã«ãã³ãŒããšãã£ã¿ã§ãããžã§ã¯ãã®ã³ãŒããéããŸãã @@ -207,16 +208,7 @@ console.log("Contract deployed to:", domainContract.address); ### ðšÂ å®è¡ããŠã¿ãã -`packages/contract/package.json`ã®`script`éšåã以äžã®ããã«ç·šéããŠãã ããã - -```json -"scripts": { - "run:script":"npx hardhat run scripts/run.js", - "test": "npx hardhat test", - "deploy": "npx hardhat run scripts/deploy.js --network mumbai" - }, -``` -ãã®åŸãã¿ãŒããã«äžã§ãäžèšãå®è¡ããŠã¿ãŸãããã +ã¿ãŒããã«äžã§ãäžèšãå®è¡ããŠã¿ãŸãããã ``` yarn contract run:script diff --git "a/docs/Polygon-ENS-Domain/ja/section-1/lesson-3_\343\203\215\343\203\274\343\203\240\343\202\265\343\203\274\343\203\223\343\202\271\343\202\222\344\275\234\346\210\220\343\201\227\343\201\246\347\231\273\351\214\262\343\201\227\343\201\246\343\201\277\343\202\210\343\201\206.md" "b/docs/Polygon-ENS-Domain/ja/section-1/lesson-3_\343\203\215\343\203\274\343\203\240\343\202\265\343\203\274\343\203\223\343\202\271\343\202\222\344\275\234\346\210\220\343\201\227\343\201\246\347\231\273\351\214\262\343\201\227\343\201\246\343\201\277\343\202\210\343\201\206.md" index 327a22f92..ac12e5076 100644 --- "a/docs/Polygon-ENS-Domain/ja/section-1/lesson-3_\343\203\215\343\203\274\343\203\240\343\202\265\343\203\274\343\203\223\343\202\271\343\202\222\344\275\234\346\210\220\343\201\227\343\201\246\347\231\273\351\214\262\343\201\227\343\201\246\343\201\277\343\202\210\343\201\206.md" +++ "b/docs/Polygon-ENS-Domain/ja/section-1/lesson-3_\343\203\215\343\203\274\343\203\240\343\202\265\343\203\274\343\203\223\343\202\271\343\202\222\344\275\234\346\210\220\343\201\227\343\201\246\347\231\273\351\214\262\343\201\227\343\201\246\343\201\277\343\202\210\343\201\206.md" @@ -4,7 +4,6 @@ ### ðœãã¡ã€ã³ããŒã¿ããããã¯ãã§ãŒã³ã«ä¿åãã - ããŒã ãµãŒãã¹ã®ãã€ã³ãã¯ã人ã ãã€ã³ã¿ãŒãããäžã®ããªãåºæã®ååã«äŸ¿å©ã«ã¢ã¯ã»ã¹ããããšãã§ãããšããããšã§ãã [google.com](http://google.com)ãšå ¥åããŠGoogleã«ã¢ã¯ã»ã¹ããã®ãšåãããã«ããŠãŒã¶ãŒã¯ããªãã®ãã¡ã€ã³ããŒã ãé Œãã«ããªãã®æ å ±ã«ã¢ã¯ã»ã¹ããããšãã§ããŸãã @@ -21,23 +20,23 @@ pragma solidity ^0.8.17; import "hardhat/console.sol"; contract Domains { - // "mapping"ã§stringåã®åkeyãšaddressåã®åããŒã¿ãçŽä»ãã«ããŠæ ŒçŽããŸãããã®mappingãããã§ã¯"domains"ãšããŠå®çŸ©ããŠããŸãã - mapping(string => address) public domains; - - constructor() { - console.log("THIS IS MY DOMAIN CONTRACT. NICE."); - } - - // registeré¢æ°ã¯nameãšã¢ãã¬ã¹ãçŽä»ããŸãã - function register(string calldata name) public { - domains[name] = msg.sender; - console.log("%s has registered a domain!", msg.sender); - } - - // nameã«å¯Ÿå¿ããaddressãè¿ãã²ãã¿ãŒé¢æ°ãå®çŸ©ããŠãããŸãã - function getAddress(string calldata name) public view returns (address) { - return domains[name]; - } + // "mapping"ã§stringåã®åkeyãšaddressåã®åããŒã¿ãçŽä»ãã«ããŠæ ŒçŽããŸãããã®mappingãããã§ã¯"domains"ãšããŠå®çŸ©ããŠããŸãã + mapping(string => address) public domains; + + constructor() { + console.log("THIS IS MY DOMAIN CONTRACT. NICE."); + } + + // registeré¢æ°ã¯nameãšã¢ãã¬ã¹ãçŽä»ããŸãã + function register(string calldata name) public { + domains[name] = msg.sender; + console.log("%s has registered a domain!", msg.sender); + } + + // nameã«å¯Ÿå¿ããaddressãè¿ãã²ãã¿ãŒé¢æ°ãå®çŸ©ããŠãããŸãã + function getAddress(string calldata name) public view returns (address) { + return domains[name]; + } } ``` @@ -95,14 +94,14 @@ const main = async () => { const domainContractFactory = await hre.ethers.getContractFactory('Domains'); const domainContract = await domainContractFactory.deploy(); await domainContract.deployed(); - console.log("Contract deployed to:", domainContract.address); - console.log("Contract deployed by:", owner.address); + console.log('Contract deployed to:', domainContract.address); + console.log('Contract deployed by:', owner.address); - const txn = await domainContract.register("doom"); + const txn = await domainContract.register('doom'); await txn.wait(); - const domainOwner = await domainContract.getAddress("doom"); - console.log("Owner of domain:", domainOwner); + const domainOwner = await domainContract.getAddress('doom'); + console.log('Owner of domain:', domainOwner); } const runMain = async () => { @@ -135,17 +134,17 @@ const [owner, randomPerson] = await hre.ethers.getSigners(); ã³ã³ãã©ã¯ãããããã€ãã人ã®ã¢ãã¬ã¹ãåºåããŸãã ```javascript -console.log("Contract deployed by:", owner.address); +console.log('Contract deployed by:', owner.address); ``` æåŸã«ãããè¿œå ããŠããŸãã ```javascript -const txn = await domainContract.register("doom"); +const txn = await domainContract.register('doom'); await txn.wait(); -const domainOwner = await domainContract.getAddress("doom"); -console.log("Owner of domain:", domainOwner); +const domainOwner = await domainContract.getAddress('doom'); +console.log('Owner of domain:', domainOwner); ``` ãŸãã`doom`ãåŒæ°ãšããŠ`register`é¢æ°ãåŒã³åºããŸãã @@ -200,35 +199,37 @@ pragma solidity ^0.8.17; import "hardhat/console.sol"; contract Domains { - mapping(string => address) public domains; - - // stringãšstringãçŽä»ããæ°ããmappingã§ãã - mapping(string => string) public records; - - constructor() { - console.log("Yo yo, I am a contract and I am smart"); - } - - function register(string calldata name) public { - // ãã®ãã¡ã€ã³ããŸã ç»é²ãããŠããªãã確èªããŸãã - require(domains[name] == address(0)); - domains[name] = msg.sender; - console.log("%s has registered a domain!", msg.sender); - } - - function getAddress(string calldata name) public view returns (address) { - return domains[name]; - } - - function setRecord(string calldata name, string calldata record) public { - // ãã©ã³ã¶ã¯ã·ã§ã³ã®éä¿¡è ã§ããããšã確èªããŠããŸãã - require(domains[name] == msg.sender); - records[name] = record; - } - - function getRecord(string calldata name) public view returns(string memory) { - return records[name]; - } + mapping(string => address) public domains; + + // stringãšstringãçŽä»ããæ°ããmappingã§ãã + mapping(string => string) public records; + + constructor() { + console.log("Yo yo, I am a contract and I am smart"); + } + + function register(string calldata name) public { + // ãã®ãã¡ã€ã³ããŸã ç»é²ãããŠããªãã確èªããŸãã + require(domains[name] == address(0)); + domains[name] = msg.sender; + console.log("%s has registered a domain!", msg.sender); + } + + function getAddress(string calldata name) public view returns (address) { + return domains[name]; + } + + function setRecord(string calldata name, string calldata record) public { + // ãã©ã³ã¶ã¯ã·ã§ã³ã®éä¿¡è ã§ããããšã確èªããŠããŸãã + require(domains[name] == msg.sender); + records[name] = record; + } + + function getRecord( + string calldata name + ) public view returns (string memory) { + return records[name]; + } } ``` @@ -276,14 +277,14 @@ const main = async () => { const domainContractFactory = await hre.ethers.getContractFactory('Domains'); const domainContract = await domainContractFactory.deploy(); await domainContract.deployed(); - console.log("Contract deployed to:", domainContract.address); - console.log("Contract deployed by:", owner.address); + console.log('Contract deployed to:', domainContract.address); + console.log('Contract deployed by:', owner.address); - let txn = await domainContract.register("doom"); + let txn = await domainContract.register('doom'); await txn.wait(); - const domainAddress = await domainContract.getAddress("doom"); - console.log("Owner of domain doom:", domainAddress); + const domainAddress = await domainContract.getAddress('doom'); + console.log('Owner of domain doom:', domainAddress); } @@ -331,17 +332,17 @@ const main = async () => { const domainContractFactory = await hre.ethers.getContractFactory('Domains'); const domainContract = await domainContractFactory.deploy(); await domainContract.deployed(); - console.log("Contract deployed to:", domainContract.address); - console.log("Contract deployed by:", owner.address); + console.log('Contract deployed to:', domainContract.address); + console.log('Contract deployed by:', owner.address); - let txn = await domainContract.register("doom"); + let txn = await domainContract.register('doom'); await txn.wait(); - const domainAddress = await domainContract.getAddress("doom"); - console.log("Owner of domain doom:", domainAddress); + const domainAddress = await domainContract.getAddress('doom'); + console.log('Owner of domain doom:', domainAddress); // èªå以å€ã§ããŒã¿ãèšé²ããŠã¿ãŸãã - txn = await domainContract.connect(randomPerson).setRecord("doom", "Haha my domain now!"); + txn = await domainContract.connect(randomPerson).setRecord('doom', 'Haha my domain now!'); await txn.wait(); } @@ -368,7 +369,7 @@ yarn contract run:script **次ã®ã¹ã¯ãªããã®ç®æã§ãšã©ãŒãçºçããŸã** ```javascript -txn = await domainContract.connect(randomPerson).setRecord("doom", "Haha my domain now!"); +txn = await domainContract.connect(randomPerson).setRecord('doom', 'Haha my domain now!'); await txn.wait(); ``` diff --git "a/docs/Polygon-ENS-Domain/ja/section-1/lesson-4_\343\203\211\343\203\241\343\202\244\343\203\263\343\202\222\350\262\251\345\243\262\343\201\247\343\201\215\343\202\213\343\202\210\343\201\206\343\201\253\343\201\227\343\202\210\343\201\206.md" "b/docs/Polygon-ENS-Domain/ja/section-1/lesson-4_\343\203\211\343\203\241\343\202\244\343\203\263\343\202\222\350\262\251\345\243\262\343\201\247\343\201\215\343\202\213\343\202\210\343\201\206\343\201\253\343\201\227\343\202\210\343\201\206.md" index 370313cb7..608a1f581 100644 --- "a/docs/Polygon-ENS-Domain/ja/section-1/lesson-4_\343\203\211\343\203\241\343\202\244\343\203\263\343\202\222\350\262\251\345\243\262\343\201\247\343\201\215\343\202\213\343\202\210\343\201\206\343\201\253\343\201\227\343\202\210\343\201\206.md" +++ "b/docs/Polygon-ENS-Domain/ja/section-1/lesson-4_\343\203\211\343\203\241\343\202\244\343\203\263\343\202\222\350\262\251\345\243\262\343\201\247\343\201\215\343\202\213\343\202\210\343\201\206\343\201\253\343\201\227\343\202\210\343\201\206.md" @@ -25,47 +25,50 @@ pragma solidity ^0.8.17; // ã€ã³ããŒããå¿ããã«ã -import { StringUtils } from "./libraries/StringUtils.sol"; +import {StringUtils} from "./libraries/StringUtils.sol"; import "hardhat/console.sol"; contract Domains { - // ãããã¬ãã«ãã¡ã€ã³(TLD)ã§ãã - string public tld; + // ãããã¬ãã«ãã¡ã€ã³(TLD)ã§ãã + string public tld; - mapping(string => address) public domains; - mapping(string => string) public records; + mapping(string => address) public domains; + mapping(string => string) public records; - // constructorã«"payable"ãå ããŸãã - constructor(string memory _tld) payable { - tld = _tld; - console.log("%s name service deployed", _tld); - } + // constructorã«"payable"ãå ããŸãã + constructor(string memory _tld) payable { + tld = _tld; + console.log("%s name service deployed", _tld); + } - // domainã®é·ãã«ããäŸ¡æ Œãå€ãããŸãã - function price(string calldata name) public pure returns(uint) { - uint len = StringUtils.strlen(name); - require(len > 0); - if (len == 3) { // 3æåã®ãã¡ã€ã³ã®å Žå (éåžž,ãã¡ã€ã³ã¯3æå以äžãšãããŸããããšã®ã»ã¯ã·ã§ã³ã§è§ŠããŸãã) - return 0.005 * 10**18; // 5 MATIC = 5 000 000 000 000 000 000 (18ã±ã¿).ããšã§faucetããå°éãããé¢ä¿ 0.005MATICã - } else if (len == 4) { //4æåã®ãã¡ã€ã³ã®å Žå - return 0.003 * 10**18; // 0.003MATIC - } else { - return 0.001 * 10**18; // 0.001MATIC + // domainã®é·ãã«ããäŸ¡æ Œãå€ãããŸãã + function price(string calldata name) public pure returns (uint) { + uint len = StringUtils.strlen(name); + require(len > 0); + if (len == 3) { + // 3æåã®ãã¡ã€ã³ã®å Žå (éåžž,ãã¡ã€ã³ã¯3æå以äžãšãããŸããããšã®ã»ã¯ã·ã§ã³ã§è§ŠããŸãã) + return 0.005 * 10 ** 18; // 5 MATIC = 5 000 000 000 000 000 000 (18ã±ã¿).ããšã§faucetããå°éãããé¢ä¿ 0.005MATICã + } else if (len == 4) { + //4æåã®ãã¡ã€ã³ã®å Žå + return 0.003 * 10 ** 18; // 0.003MATIC + } else { + return 0.001 * 10 ** 18; // 0.001MATIC + } } - } - function register(string calldata name) public payable{ - require(domains[name] == address(0)); - uint _price = price(name); + function register(string calldata name) public payable { + require(domains[name] == address(0)); + uint _price = price(name); - // ãã©ã³ã¶ã¯ã·ã§ã³ãåŠçã§ããåã ãã®MATICããããç¢ºèª - require(msg.value >= _price, "Not enough Matic paid"); + // ãã©ã³ã¶ã¯ã·ã§ã³ãåŠçã§ããåã ãã®MATICããããç¢ºèª + require(msg.value >= _price, "Not enough Matic paid"); - domains[name] = msg.sender; - console.log("%s has registered a domain!", msg.sender); - } - // ä»ã®function ã¯å€æŽããã + domains[name] = msg.sender; + console.log("%s has registered a domain!", msg.sender); + } + + // ä»ã®function ã¯å€æŽããã } ``` @@ -117,7 +120,7 @@ _泚ïŒ**Mumbai ãªã©ãã¹ããããã§ã¯äŸ¡æ ŒãäžããŠãã³ãã㟠ä»ã«ã次ã®3ã€ãè¿œå ããŸããã -- `import{StringUtils}`ããã±ãŒãžãã€ã³ããŒãããŠããŸãã ããã«ã€ããŠã¯äžã§èª¬æããŠããŸãã +- `StringUtils`ããã±ãŒãžãã€ã³ããŒãããŠããŸãã ããã«ã€ããŠã¯äžã§èª¬æããŠããŸãã - æåå`tld`ããã¯ããã¡ã€ã³ã®æ«å°Ÿãèšé²ããŸã(äŸïŒ`.ninja`)ã @@ -133,24 +136,24 @@ _泚ïŒ**Mumbai ãªã©ãã¹ããããã§ã¯äŸ¡æ ŒãäžããŠãã³ãã㟠```javascript const main = async () => { - const domainContractFactory = await hre.ethers.getContractFactory("Domains"); - // "ninja"ããããã€æã«constructorã«æž¡ããŸãã - const domainContract = await domainContractFactory.deploy("ninja"); + const domainContractFactory = await hre.ethers.getContractFactory('Domains'); + // 'ninja'ããããã€æã«constructorã«æž¡ããŸãã + const domainContract = await domainContractFactory.deploy('ninja'); await domainContract.deployed(); - console.log("Contract deployed to:", domainContract.address); + console.log('Contract deployed to:', domainContract.address); // valueã§ä»£éããããšãããŠããŸãã - let txn = await domainContract.register("mortal", { - value: hre.ethers.utils.parseEther("0.01"), + let txn = await domainContract.register('mortal', { + value: hre.ethers.utils.parseEther('0.01'), }); await txn.wait(); - const address = await domainContract.getAddress("mortal"); - console.log("Owner of domain mortal:", address); + const address = await domainContract.getAddress('mortal'); + console.log('Owner of domain mortal:', address); const balance = await hre.ethers.provider.getBalance(domainContract.address); - console.log("Contract balance:", hre.ethers.utils.formatEther(balance)); + console.log('Contract balance:', hre.ethers.utils.formatEther(balance)); }; const runMain = async () => { @@ -244,67 +247,83 @@ import "hardhat/console.sol"; // ã€ã³ããŒãããã³ã³ãã©ã¯ããç¶æ¿ããŸããç¶æ¿ããã³ã³ãã©ã¯ãã®ã¡ãœããã䜿çšã§ããããã«ãªããŸãã contract Domains is ERC721URIStorage { - // OpenZeppelinã«ããtokenIdsã®è¿œè·¡ã容æã«ãªããŸãã - using Counters for Counters.Counter; - Counters.Counter private _tokenIds; - - string public tld; - - // NFTã®ã€ã¡ãŒãžç»åãSVG圢åŒã§ãªã³ãã§ãŒã³ã«ä¿åããŸãã - string svgPartOne = ''; - - mapping(string => address) public domains; - mapping(string => string) public records; - - constructor(string memory _tld) payable ERC721("Ninja Name Service", "NNS") { - tld = _tld; - console.log("%s name service deployed", _tld); - } + // OpenZeppelinã«ããtokenIdsã®è¿œè·¡ã容æã«ãªããŸãã + using Counters for Counters.Counter; + Counters.Counter private _tokenIds; - function register(string calldata name) public payable { - require(domains[name] == address(0)); + string public tld; - uint256 _price = price(name); - require(msg.value >= _price, "Not enough Matic paid"); + // NFTã®ã€ã¡ãŒãžç»åãSVG圢åŒã§ãªã³ãã§ãŒã³ã«ä¿åããŸãã + string svgPartOne = + '"; - // ããŒã ãšTLD(ãããã¬ãã«ãã¡ã€ã³)ãçµåããŸãã - string memory _name = string(abi.encodePacked(name, ".", tld)); - // NFTçšã«SVGã€ã¡ãŒãžãäœæããŸãã - string memory finalSvg = string(abi.encodePacked(svgPartOne, _name, svgPartTwo)); - uint256 newRecordId = _tokenIds.current(); - uint256 length = StringUtils.strlen(name); - string memory strLen = Strings.toString(length); + mapping(string => address) public domains; + mapping(string => string) public records; - console.log("Registering %s.%s on the contract with tokenID %d", name, tld, newRecordId); - - // JSON圢åŒã®NFTã®ã¡ã¿ããŒã¿ãäœæãæååãçµåãbase64ã§ãšã³ã³ãŒãããŸãã - string memory json = Base64.encode( - abi.encodePacked( - '{"name": "', - _name, - '", "description": "A domain on the Ninja name service", "image": "data:image/svg+xml;base64,', - Base64.encode(bytes(finalSvg)), - '","length":"', - strLen, - '"}' - ) - ); - - string memory finalTokenUri = string( abi.encodePacked("data:application/json;base64,", json)); - - console.log("\n--------------------------------------------------------"); - console.log("Final tokenURI", finalTokenUri); - console.log("--------------------------------------------------------\n"); - - _safeMint(msg.sender, newRecordId); - _setTokenURI(newRecordId, finalTokenUri); - domains[name] = msg.sender; + constructor( + string memory _tld + ) payable ERC721("Ninja Name Service", "NNS") { + tld = _tld; + console.log("%s name service deployed", _tld); + } - _tokenIds.increment(); - } + function register(string calldata name) public payable { + require(domains[name] == address(0)); + + uint256 _price = price(name); + require(msg.value >= _price, "Not enough Matic paid"); + + // ããŒã ãšTLD(ãããã¬ãã«ãã¡ã€ã³)ãçµåããŸãã + string memory _name = string(abi.encodePacked(name, ".", tld)); + // NFTçšã«SVGã€ã¡ãŒãžãäœæããŸãã + string memory finalSvg = string( + abi.encodePacked(svgPartOne, _name, svgPartTwo) + ); + uint256 newRecordId = _tokenIds.current(); + uint256 length = StringUtils.strlen(name); + string memory strLen = Strings.toString(length); + + console.log( + "Registering %s.%s on the contract with tokenID %d", + name, + tld, + newRecordId + ); + + // JSON圢åŒã®NFTã®ã¡ã¿ããŒã¿ãäœæãæååãçµåãbase64ã§ãšã³ã³ãŒãããŸãã + string memory json = Base64.encode( + abi.encodePacked( + '{"name": "', + _name, + '", "description": "A domain on the Ninja name service", "image": "data:image/svg+xml;base64,', + Base64.encode(bytes(finalSvg)), + '","length":"', + strLen, + '"}' + ) + ); + + string memory finalTokenUri = string( + abi.encodePacked("data:application/json;base64,", json) + ); + + console.log( + "\n--------------------------------------------------------" + ); + console.log("Final tokenURI", finalTokenUri); + console.log( + "--------------------------------------------------------\n" + ); + + _safeMint(msg.sender, newRecordId); + _setTokenURI(newRecordId, finalTokenUri); + domains[name] = msg.sender; + + _tokenIds.increment(); + } - // price, getAddress, setRecord, getRecord ãªã©ã®function ã¯å€æŽããŸããã + // price, getAddress, setRecord, getRecord ãªã©ã®function ã¯å€æŽããŸããã } ``` @@ -515,7 +534,7 @@ _setTokenURI(newRecordId, finalTokenUri); ### 𥞠NFT ãã¡ã€ã³ãããŒã«ã«ã§äœæãã -ã³ã³ãã©ã¯ããå®è¡ããæºåãã§ããŸãã! ããŒã«ã«ãããã¯ãã§ãŒã³ã§ãã³ãããŠã¿ãŸãããã +ã³ã³ãã©ã¯ããå®è¡ããæºåãã§ããŸãã! `yarn contract run:script`ãå®è¡ããããŒã«ã«ãããã¯ãã§ãŒã³ã§ãã³ãããŠã¿ãŸãããã ``` Compiled 13 Solidity files successfully @@ -535,7 +554,7 @@ Owner of domain mortal: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Contract balance: 0.1 ``` -`yarn contract run:script`ãå®è¡ããŸãã 倧ããªéãã¯ãã³ã³ãœãŒã«ã®åºåã§ãã ç§ã®å€èŠ³ã§ãïŒãã®ã¹ã¯ãªãŒã³ã·ã§ããã®URIã¯ççž®ããŠãããŸãïŒïŒ +倧ããªéãã¯ãã³ã³ãœãŒã«ã®åºåã§ãã ç§ã®å€èŠ³ã§ãïŒãã®ã¹ã¯ãªãŒã³ã·ã§ããã®URIã¯ççž®ããŠãããŸãïŒïŒ ![](/public/images/Polygon-ENS-Domain/section-1/1_4_4.png) diff --git "a/docs/Polygon-ENS-Domain/ja/section-1/lesson-5_Mumbai\343\201\253\343\203\207\343\203\227\343\203\255\343\202\244\343\201\227\343\202\210\343\201\206.md" "b/docs/Polygon-ENS-Domain/ja/section-1/lesson-5_Mumbai\343\201\253\343\203\207\343\203\227\343\203\255\343\202\244\343\201\227\343\202\210\343\201\206.md" index 8c8754cec..41a2129c9 100644 --- "a/docs/Polygon-ENS-Domain/ja/section-1/lesson-5_Mumbai\343\201\253\343\203\207\343\203\227\343\203\255\343\202\244\343\201\227\343\202\210\343\201\206.md" +++ "b/docs/Polygon-ENS-Domain/ja/section-1/lesson-5_Mumbai\343\201\253\343\203\207\343\203\227\343\203\255\343\202\244\343\201\227\343\202\210\343\201\206.md" @@ -122,28 +122,28 @@ MetaMaskãšHardhatã®äž¡æ¹ã§Polygonãããã¯ãŒã¯ã®èšå®ãå®äºãã ```javascript const main = async () => { - const domainContractFactory = await hre.ethers.getContractFactory("Domains"); - const domainContract = await domainContractFactory.deploy("ninja"); + const domainContractFactory = await hre.ethers.getContractFactory('Domains'); + const domainContract = await domainContractFactory.deploy('ninja'); await domainContract.deployed(); - console.log("Contract deployed to:", domainContract.address); + console.log('Contract deployed to:', domainContract.address); // domainããªãªãžãã«ã«ããŸãããïŒ - let txn = await domainContract.register("banana", { - value: hre.ethers.utils.parseEther("0.1"), + let txn = await domainContract.register('banana', { + value: hre.ethers.utils.parseEther('0.1'), }); await txn.wait(); - console.log("Minted domain banana.ninja"); + console.log('Minted domain banana.ninja'); - txn = await domainContract.setRecord("banana", "Am I a banana or a ninja??"); + txn = await domainContract.setRecord('banana', 'Am I a banana or a ninja??'); await txn.wait(); - console.log("Set record for banana.ninja"); + console.log('Set record for banana.ninja'); - const address = await domainContract.getAddress("banana"); - console.log("Owner of domain banana:", address); + const address = await domainContract.getAddress('banana'); + console.log('Owner of domain banana:', address); const balance = await hre.ethers.provider.getBalance(domainContract.address); - console.log("Contract balance:", hre.ethers.utils.formatEther(balance)); + console.log('Contract balance:', hre.ethers.utils.formatEther(balance)); }; const runMain = async () => { @@ -168,14 +168,14 @@ runMain(); `hardhat.config.js`ãã¡ã€ã«ãç·šéããŸãã ããã¯ãã¹ããŒãã³ã³ãã©ã¯ããããžã§ã¯ãã®ã«ãŒããã£ã¬ã¯ããªã«ãããŸãã ããã§ã¯ã䜿çšããŠãããããã¯ãŒã¯ãšç§å¯éµãè¿œå ããŸãã ```javascript -require("@nomicfoundation/hardhat-toolbox"); +require('@nomicfoundation/hardhat-toolbox'); module.exports = { - solidity: "0.8.17", + solidity: '0.8.17', networks: { mumbai: { - url: "YOUR_ALCHEMY_MUMBAI_URL", - accounts: ["YOUR_TEST_WALLET_PRIVATE_KEY"], + url: 'YOUR_ALCHEMY_MUMBAI_URL', + accounts: ['YOUR_TEST_WALLET_PRIVATE_KEY'], }, }, }; diff --git "a/docs/Polygon-ENS-Domain/ja/section-2/lesson-1_Wallet Connect\343\203\234\343\202\277\343\203\263\343\202\222\345\256\237\350\243\205\343\201\227\343\202\210\343\201\206.md" "b/docs/Polygon-ENS-Domain/ja/section-2/lesson-1_Wallet Connect\343\203\234\343\202\277\343\203\263\343\202\222\345\256\237\350\243\205\343\201\227\343\202\210\343\201\206.md" index 0ebc3d4ed..d94016172 100644 --- "a/docs/Polygon-ENS-Domain/ja/section-2/lesson-1_Wallet Connect\343\203\234\343\202\277\343\203\263\343\202\222\345\256\237\350\243\205\343\201\227\343\202\210\343\201\206.md" +++ "b/docs/Polygon-ENS-Domain/ja/section-2/lesson-1_Wallet Connect\343\203\234\343\202\277\343\203\263\343\202\222\345\256\237\350\243\205\343\201\227\343\202\210\343\201\206.md" @@ -10,7 +10,7 @@ _åœã¬ãã¹ã³ã¯ãããåèªã®åŠç¿ç¶æ³ã«ãã以åã®ãããžã§ äžåºŠç§ãã¡ããŠã©ã¬ããããŠã§ããµã€ããšæ¥ç¶ãããšãŠã§ããµã€ãã¯ç§ãã¡ã®ä»£ããã«ã¹ããŒãã³ã³ãã©ã¯ããšãããšãããŸããç§ãã¡ã**èš±å¯ããããš**ãè¡ã£ãŠãããŸãã -`src`ãã©ã«ãã®äžã®`App.js`ã«åãããŸãããã +`packages/client/src`ãã©ã«ãã®äžã®`App.js`ã«åãããŸãããã ãããããã³ããšã³ãã®åºç¹ãšãªããŸãã ã¡ã¿ãã¹ã¯ã«ãã°ã€ã³ãããšãèªåçã«`ethereum`ãšãããªããžã§ã¯ãããŠã£ã³ããŠã«ã€ã³ãžã§ã¯ããããŸãã @@ -20,12 +20,12 @@ _åœã¬ãã¹ã³ã¯ãããåèªã®åŠç¿ç¶æ³ã«ãã以åã®ãããžã§ **泚æïŒã¡ã¿ãã¹ã¯ã®ãã§ãŒã³éžæã§èªåã®æ¬æ¥ã®ç®çã®ãããã¯ãã§ãŒã³ä»¥å€ã®ãã§ãŒã³ãéžæããŠããç¶æ ã§ã`ethereum`ãªããžã§ã¯ãã¯ã€ã³ãžã§ã¯ããããŸããåŸã§ãããå®æã§ããã§ãããã** ```javascript -import React, { useEffect } from "react"; -import "./styles/App.css"; -import twitterLogo from "./assets/twitter-logo.svg"; +import React, { useEffect } from 'react'; +import './styles/App.css'; +import twitterLogo from './assets/twitter-logo.svg'; -// ã³ã³ãã©ã¯ã -const TWITTER_HANDLE = "_UNCHAIN"; +// å®æ° +const TWITTER_HANDLE = 'UNCHAIN_tech'; const TWITTER_LINK = `https://twitter.com/${TWITTER_HANDLE}`; const App = () => { @@ -35,10 +35,10 @@ const App = () => { const { ethereum } = window; if (!ethereum) { - console.log("Make sure you have MetaMask!"); + console.log('Make sure you have MetaMask!'); return; } else { - console.log("We have the ethereum object", ethereum); + console.log('We have the ethereum object', ethereum); } }; @@ -95,7 +95,7 @@ export default App; ``` ããã§ã¡ã¿ãã¹ã¯æ¡åŒµæ©èœãã€ã³ã¹ããŒã«ãããŠãããã®ããžãã¯ãäœæããŸããã -ããŒãžãæŽæ°ãããšãã©ãŠã¶ã®Devã³ã³ãœãŒã«ã«ã¯`We have the Ethereum object`ãšè¡šç€ºãããã§ãããïŒã¡ã¿ãã¹ã¯ãã€ã³ã¹ããŒã«æžã¿ã®å ŽåïŒã +ããŒãžãæŽæ°ãããšãã©ãŠã¶ã®Devã³ã³ãœãŒã«ã«ã¯`We have the ethereum object`ãšè¡šç€ºãããã§ãããïŒã¡ã¿ãã¹ã¯ãã€ã³ã¹ããŒã«æžã¿ã®å ŽåïŒã ããŒãžã奜ã¿ã«åãããŠã«ã¹ã¿ãã€ãºããŠã¿ãŠãã ããã[GIF ã®åèãµã€ã](https://giphy.com/)ã§ãã @@ -113,37 +113,37 @@ MetaMaskã¯ãç§ãã¡ãèš±å¯ãããŠã§ããµã€ãã«ã®ã¿æš©éãäžã ```javascript // useStateãè¿œå ã§ã€ã³ããŒãããŠããŸãã -import React, { useEffect, useState } from "react"; -import "./styles/App.css"; -import twitterLogo from "./assets/twitter-logo.svg"; +import React, { useEffect, useState } from 'react'; +import './styles/App.css'; +import twitterLogo from './assets/twitter-logo.svg'; -const TWITTER_HANDLE = "_UNCHAIN"; +const TWITTER_HANDLE = 'UNCHAIN_tech'; const TWITTER_LINK = `https://twitter.com/${TWITTER_HANDLE}`; const App = () => { //ãŠãŒã¶ãŒã®ãŠã©ã¬ããã¢ãã¬ã¹ãstate管çããŠããŸããåé ã®useStateã®ã€ã³ããŒããå¿ããªãã§ãã ããã - const [currentAccount, setCurrentAccount] = useState(""); + const [currentAccount, setCurrentAccount] = useState(''); const checkIfWalletIsConnected = async () => { const { ethereum } = window; if (!ethereum) { - console.log("Make sure you have metamask!"); + console.log('Make sure you have metamask!'); return; } else { - console.log("We have the ethereum object", ethereum); + console.log('We have the ethereum object', ethereum); } // ãŠãŒã¶ãŒã®ãŠã©ã¬ããããªã¯ãšã¹ãããŸãã - const accounts = await ethereum.request({ method: "eth_accounts" }); + const accounts = await ethereum.request({ method: 'eth_accounts' }); // ãŠãŒã¶ãŒãè€æ°ã®ã¢ã«ãŠã³ããæã£ãŠããå ŽåããããŸããããã§ã¯æåã®ã¢ãã¬ã¹ã䜿ããŸãã if (accounts.length !== 0) { const account = accounts[0]; - console.log("Found an authorized account:", account); + console.log('Found an authorized account:', account); setCurrentAccount(account); } else { - console.log("No authorized account found"); + console.log('No authorized account found'); } }; @@ -204,16 +204,16 @@ export default App; web3ã®äžçã§ã¯ããŠã©ã¬ããã®æ¥ç¶ã¯ããã°ãŠãŒã¶ãŒã®ããã°ã€ã³ããã¿ã³ã§ããMetaMaskã«ãªã¯ãšã¹ããéä¿¡ããŠããŠãŒã¶ãŒã®ãŠã©ã¬ãããžã®èªã¿åãå°çšã¢ã¯ã»ã¹ãèš±å¯ããŸãã ```javascript -import React, { useEffect, useState } from "react"; -import "./styles/App.css"; -import twitterLogo from "./assets/twitter-logo.svg"; +import React, { useEffect, useState } from 'react'; +import './styles/App.css'; +import twitterLogo from './assets/twitter-logo.svg'; -// ã³ã³ãã©ã¯ã -const TWITTER_HANDLE = "_UNCHAIN"; +// å®æ° +const TWITTER_HANDLE = 'UNCHAIN_tech'; const TWITTER_LINK = `https://twitter.com/${TWITTER_HANDLE}`; const App = () => { - const [currentAccount, setCurrentAccount] = useState(""); + const [currentAccount, setCurrentAccount] = useState(''); // connectWallet é¢æ°ãå®çŸ© const connectWallet = async () => { @@ -221,17 +221,17 @@ const App = () => { const { ethereum } = window; if (!ethereum) { - alert("Get MetaMask -> https://metamask.io/"); + alert('Get MetaMask -> https://metamask.io/'); return; } // ã¢ã«ãŠã³ããžã®ã¢ã¯ã»ã¹ãèŠæ±ããã¡ãœããã䜿çšããŸãã const accounts = await ethereum.request({ - method: "eth_requestAccounts", + method: 'eth_requestAccounts', }); // Metamask ãäžåºŠèªèšŒããã° Connected ãšã³ã³ãœãŒã«ã«è¡šç€ºãããŸãã - console.log("Connected", accounts[0]); + console.log('Connected', accounts[0]); setCurrentAccount(accounts[0]); } catch (error) { console.log(error); @@ -242,20 +242,20 @@ const App = () => { const { ethereum } = window; if (!ethereum) { - console.log("Make sure you have metamask!"); + console.log('Make sure you have metamask!'); return; } else { - console.log("We have the ethereum object", ethereum); + console.log('We have the ethereum object', ethereum); } - const accounts = await ethereum.request({ method: "eth_accounts" }); + const accounts = await ethereum.request({ method: 'eth_accounts' }); if (accounts.length !== 0) { const account = accounts[0]; - console.log("Found an authorized account:", account); + console.log('Found an authorized account:', account); setCurrentAccount(account); } else { - console.log("No authorized account found"); + console.log('No authorized account found'); } }; diff --git "a/docs/Polygon-ENS-Domain/ja/section-2/lesson-2_\343\203\211\343\203\241\343\202\244\343\203\263\343\202\222\343\203\237\343\203\263\343\203\210\343\201\227\343\202\210\343\201\206.md" "b/docs/Polygon-ENS-Domain/ja/section-2/lesson-2_\343\203\211\343\203\241\343\202\244\343\203\263\343\202\222\343\203\237\343\203\263\343\203\210\343\201\227\343\202\210\343\201\206.md" index e527bef58..5ac687606 100644 --- "a/docs/Polygon-ENS-Domain/ja/section-2/lesson-2_\343\203\211\343\203\241\343\202\244\343\203\263\343\202\222\343\203\237\343\203\263\343\203\210\343\201\227\343\202\210\343\201\206.md" +++ "b/docs/Polygon-ENS-Domain/ja/section-2/lesson-2_\343\203\211\343\203\241\343\202\244\343\203\263\343\202\222\343\203\237\343\203\263\343\203\210\343\201\227\343\202\210\343\201\206.md" @@ -5,38 +5,37 @@ ãŸãããŠãŒã¶ãŒã®ãã¡ã€ã³åãšä¿åããããŒã¿ãååŸããå¿ èŠãããã®ã§ããããå®è¡ããŸãããã ```javascript -import React, { useEffect, useState } from "react"; -import "./styles/App.css"; -import twitterLogo from "./assets/twitter-logo.svg"; -import { ethers } from "ethers"; +import React, { useEffect, useState } from 'react'; +import './styles/App.css'; +import twitterLogo from './assets/twitter-logo.svg'; +import { ethers } from 'ethers'; -// ã³ã³ãã©ã¯ã -const TWITTER_HANDLE = "_UNCHAIN"; +const TWITTER_HANDLE = 'UNCHAIN_tech'; const TWITTER_LINK = `https://twitter.com/${TWITTER_HANDLE}`; // ç»é²ããããã¡ã€ã³ã§ãã奜ã¿ã§å€ããŠã¿ãŸãããã -const tld = ".ninja"; -const CONTRACT_ADDRESS = "YOUR_CONTRACT_ADDRESS_HERE"; +const tld = '.ninja'; +const CONTRACT_ADDRESS = 'YOUR_CONTRACT_ADDRESS_HERE'; const App = () => { - const [currentAccount, setCurrentAccount] = useState(""); + const [currentAccount, setCurrentAccount] = useState(''); // state管çããããããã£ãè¿œå ããŠããŸãã - const [domain, setDomain] = useState(""); - const [record, setRecord] = useState(""); + const [domain, setDomain] = useState(''); + const [record, setRecord] = useState(''); const connectWallet = async () => { try { const { ethereum } = window; if (!ethereum) { - alert("Get MetaMask -> https://metamask.io/"); + alert('Get MetaMask -> https://metamask.io/'); return; } const accounts = await ethereum.request({ - method: "eth_requestAccounts", + method: 'eth_requestAccounts', }); - console.log("Connected", accounts[0]); + console.log('Connected', accounts[0]); setCurrentAccount(accounts[0]); } catch (error) { console.log(error); @@ -47,20 +46,20 @@ const App = () => { const { ethereum } = window; if (!ethereum) { - console.log("Make sure you have metamask!"); + console.log('Make sure you have metamask!'); return; } else { - console.log("We have the ethereum object", ethereum); + console.log('We have the ethereum object', ethereum); } - const accounts = await ethereum.request({ method: "eth_accounts" }); + const accounts = await ethereum.request({ method: 'eth_accounts' }); if (accounts.length !== 0) { const account = accounts[0]; - console.log("Found an authorized account:", account); + console.log('Found an authorized account:', account); setCurrentAccount(account); } else { - console.log("No authorized account found"); + console.log('No authorized account found'); } }; @@ -215,14 +214,14 @@ const mintDomain = async () => { } // ãã¡ã€ã³ã3æåã«æºããªããçãããå Žåã«ã¢ã©ãŒããåºããŸãã if (domain.length < 3) { - alert("Domain must be at least 3 characters long"); + alert('Domain must be at least 3 characters long'); return; } // ãã¡ã€ã³ã®æåæ°ã«å¿ããŠäŸ¡æ Œãèšç®ããŸãã // 3 chars = 0.05 MATIC, 4 chars = 0.03 MATIC, 5 or more = 0.01 MATIC const price = - domain.length === 3 ? "0.05" : domain.length === 4 ? "0.03" : "0.01"; - console.log("Minting domain", domain, "with price", price); + domain.length === 3 ? '0.05' : domain.length === 4 ? '0.03' : '0.01'; + console.log('Minting domain', domain, 'with price', price); try { const { ethereum } = window; if (ethereum) { @@ -234,7 +233,7 @@ const mintDomain = async () => { signer ); - console.log("Going to pop wallet now to pay gas..."); + console.log('Going to pop wallet now to pay gas...'); let tx = await contract.register(domain, { value: ethers.utils.parseEther(price), }); @@ -244,19 +243,19 @@ const mintDomain = async () => { // ãã©ã³ã¶ã¯ã·ã§ã³ãåé¡ãªãå®è¡ãããã確èªããŸãã if (receipt.status === 1) { console.log( - "Domain minted! https://mumbai.polygonscan.com/tx/" + tx.hash + 'Domain minted! https://mumbai.polygonscan.com/tx/' + tx.hash ); // domain,recordãã»ããããŸãã tx = await contract.setRecord(domain, record); await tx.wait(); - console.log("Record set! https://mumbai.polygonscan.com/tx/" + tx.hash); + console.log('Record set! https://mumbai.polygonscan.com/tx/' + tx.hash); - setRecord(""); - setDomain(""); + setRecord(''); + setDomain(''); } else { - alert("Transaction failed! Please try again"); + alert('Transaction failed! Please try again'); } } } catch (error) { @@ -293,7 +292,7 @@ const contract = new ethers.Contract(CONTRACT_ADDRESS, contractAbi.abi, signer); å¿ãããçŽå€±ãããããŠãå¿é ã¯ãããŸãããã³ã³ãã©ã¯ããåãããã€ããŠæ°ããã³ã³ãã©ã¯ãã¢ãã¬ã¹ãååŸããŠãã ããã ```javascript -console.log("Going to pop wallet now to pay gas..."); +console.log('Going to pop wallet now to pay gas...'); let tx = await contract.register(domain, { value: ethers.utils.parseEther(price), }); @@ -302,18 +301,18 @@ const receipt = await tx.wait(); // ãã©ã³ã¶ã¯ã·ã§ã³ãå®äºããã確èªããŸãã if (receipt.status === 1) { - console.log("Domain minted! https://mumbai.polygonscan.com/tx/" + tx.hash); + console.log('Domain minted! https://mumbai.polygonscan.com/tx/' + tx.hash); // domain,recordãã»ããããŸãã tx = await contract.setRecord(domain, record); await tx.wait(); - console.log("Record set! https://mumbai.polygonscan.com/tx/" + tx.hash); + console.log('Record set! https://mumbai.polygonscan.com/tx/' + tx.hash); - setRecord(""); - setDomain(""); + setRecord(''); + setDomain(''); } else { - alert("Transaction failed! Please try again"); + alert('Transaction failed! Please try again'); } ``` @@ -373,7 +372,7 @@ ABIãã¡ã€ã«ãšãããã®ããããããã¯Webã¢ããªãã³ã³ãã© ABIãã¡ã€ã«ã®å 容ã¯ãHardhatãããžã§ã¯ãã®JSONãã¡ã€ã«ã«ãããŸãã -åã®sectionã§äœæããããã¯ãšã³ãåŽ`contract`ãã£ã¬ã¯ããªãã芧ãã ããã +åã®sectionã§äœæããããã¯ãšã³ãåŽ`packages/contract`ãã£ã¬ã¯ããªãã芧ãã ããã `artifacts/contracts/Domains.sol/Domains.json` @@ -381,7 +380,7 @@ ABIãã¡ã€ã«ã®å 容ã¯ãHardhatãããžã§ã¯ãã®JSONãã¡ã€ã«ã«ã ïŒå šéžæã¯Ctrl+AïŒWindowsïŒ, Command+AïŒMacïŒã䜿çšãããšäŸ¿å©ã§ãïŒã -`src`ã®äžã«`utils`ãšãããã©ã«ãã«ã`contractABI.json`ãšããååã®ãã¡ã€ã«ãäœæããŸãã +`packages/client/src`ã®äžã«ãã`utils`ãšãããã©ã«ãã«ã`contractABI.json`ãšããååã®ãã¡ã€ã«ãäœæããŸãã ïŒãã©ã«ãããªãå Žåã¯äœæããŠãã ããïŒã @@ -396,7 +395,7 @@ ABIãã¡ã€ã«ã®å 容ãæ°ãããã¡ã€ã«ã«è²Œãä»ããŸãã 次ã®ããã«ãªããŸãã ```javascript -import contractAbi from "./utils/contractABI.json"; +import contractAbi from './utils/contractABI.json'; ``` ãã¹ãŠå®äºããŸããã diff --git "a/docs/Polygon-ENS-Domain/ja/section-3/lesson-1_\350\263\207\351\207\221\343\201\256\345\274\225\343\201\215\345\207\272\343\201\227\343\202\222\345\256\237\350\243\205\343\201\227\343\202\210\343\201\206.md" "b/docs/Polygon-ENS-Domain/ja/section-3/lesson-1_\350\263\207\351\207\221\343\201\256\345\274\225\343\201\215\345\207\272\343\201\227\343\202\222\345\256\237\350\243\205\343\201\227\343\202\210\343\201\206.md" index 9059209b0..133e7fe3e 100644 --- "a/docs/Polygon-ENS-Domain/ja/section-3/lesson-1_\350\263\207\351\207\221\343\201\256\345\274\225\343\201\215\345\207\272\343\201\227\343\202\222\345\256\237\350\243\205\343\201\227\343\202\210\343\201\206.md" +++ "b/docs/Polygon-ENS-Domain/ja/section-3/lesson-1_\350\263\207\351\207\221\343\201\256\345\274\225\343\201\215\345\207\272\343\201\227\343\202\222\345\256\237\350\243\205\343\201\227\343\202\210\343\201\206.md" @@ -18,19 +18,19 @@ ```solidity modifier onlyOwner() { - require(isOwner()); - _; + require(isOwner()); + _; } function isOwner() public view returns (bool) { - return msg.sender == owner; + return msg.sender == owner; } function withdraw() public onlyOwner { - uint amount = address(this).balance; + uint amount = address(this).balance; - (bool success, ) = msg.sender.call{value: amount}(""); - require(success, "Failed to withdraw Matic"); + (bool success, ) = msg.sender.call{value: amount}(""); + require(success, "Failed to withdraw Matic"); } ``` @@ -60,9 +60,9 @@ function withdraw() public onlyOwner { address payable public owner; constructor(string memory _tld) ERC721 ("Ninja Name Service", "NNS") payable { - owner = payable(msg.sender); - tld = _tld; - console.log("%s name service deployed", _tld); + owner = payable(msg.sender); + tld = _tld; + console.log("%s name service deployed", _tld); } ``` @@ -79,30 +79,30 @@ constructor(string memory _tld) ERC721 ("Ninja Name Service", "NNS") payable { const main = async () => { const [owner, superCoder] = await hre.ethers.getSigners(); const domainContractFactory = await hre.ethers.getContractFactory('Domains'); - const domainContract = await domainContractFactory.deploy("ninja"); + const domainContract = await domainContractFactory.deploy('ninja'); await domainContract.deployed(); - console.log("Contract owner:", owner.address); + console.log('Contract owner:', owner.address); // ä»åã¯å€é¡ãèšå®ããŠããŸãã - let txn = await domainContract.register("a16z", {value: hre.ethers.utils.parseEther('1234')}); + let txn = await domainContract.register('a16z', {value: hre.ethers.utils.parseEther('1234')}); await txn.wait(); // ã³ã³ãã©ã¯ãã«ããããããã確èªããŠããŸãã const balance = await hre.ethers.provider.getBalance(domainContract.address); - console.log("Contract balance:", hre.ethers.utils.formatEther(balance)); + console.log('Contract balance:', hre.ethers.utils.formatEther(balance)); // ã¹ãŒããŒã³ãŒããŒãšããŠã³ã³ãã©ã¯ãããè³éã奪ãããšããŸãã try { txn = await domainContract.connect(superCoder).withdraw(); await txn.wait(); } catch(error){ - console.log("Could not rob contract"); + console.log('Could not rob contract'); } // åŒãåºãåã®ãŠã©ã¬ããã®æ®é«ã確èªããŸããããšã§æ¯èŒããŸãã let ownerBalance = await hre.ethers.provider.getBalance(owner.address); - console.log("Balance of owner before withdrawal:", hre.ethers.utils.formatEther(ownerBalance)); + console.log('Balance of owner before withdrawal:', hre.ethers.utils.formatEther(ownerBalance)); // ãªãŒããŒãªãåŒãåºããã§ãããã txn = await domainContract.connect(owner).withdraw(); @@ -112,8 +112,8 @@ const main = async () => { const contractBalance = await hre.ethers.provider.getBalance(domainContract.address); ownerBalance = await hre.ethers.provider.getBalance(owner.address); - console.log("Contract balance after withdrawal:", hre.ethers.utils.formatEther(contractBalance)); - console.log("Balance of owner after withdrawal:", hre.ethers.utils.formatEther(ownerBalance)); + console.log('Contract balance after withdrawal:', hre.ethers.utils.formatEther(contractBalance)); + console.log('Balance of owner after withdrawal:', hre.ethers.utils.formatEther(ownerBalance)); } const runMain = async () => { diff --git "a/docs/Polygon-ENS-Domain/ja/section-3/lesson-2_\347\220\206\350\247\243\343\202\222\346\267\261\343\202\201\343\202\210\343\201\206.md" "b/docs/Polygon-ENS-Domain/ja/section-3/lesson-2_\347\220\206\350\247\243\343\202\222\346\267\261\343\202\201\343\202\210\343\201\206.md" index eb77fd948..976511114 100644 --- "a/docs/Polygon-ENS-Domain/ja/section-3/lesson-2_\347\220\206\350\247\243\343\202\222\346\267\261\343\202\201\343\202\210\343\201\206.md" +++ "b/docs/Polygon-ENS-Domain/ja/section-3/lesson-2_\347\220\206\350\247\243\343\202\222\346\267\261\343\202\201\343\202\210\343\201\206.md" @@ -10,18 +10,18 @@ ```solidity // ã³ã³ãã©ã¯ãã®æåã«ä»ãå ããŠãã ããïŒä»ã®ãããã³ã°ã«ç¶ããŠïŒã -mapping (uint => string) public names; +mapping(uint => string) public names; // ã³ã³ãã©ã¯ãã®ã©ããã«ä»ãå ããŠãã ããã function getAllNames() public view returns (string[] memory) { - console.log("Getting all names from contract"); - string[] memory allNames = new string[](_tokenIds.current()); - for (uint i = 0; i < _tokenIds.current(); i++) { - allNames[i] = names[i]; - console.log("Name for token %d is %s", i, allNames[i]); - } + console.log("Getting all names from contract"); + string[] memory allNames = new string[](_tokenIds.current()); + for (uint i = 0; i < _tokenIds.current(); i++) { + allNames[i] = names[i]; + console.log("Name for token %d is %s", i, allNames[i]); + } - return allNames; + return allNames; } ``` @@ -47,7 +47,7 @@ names[newRecordId] = name; 埩ç¿ã§ãð¥ -Section-2ã®Lesson-3ãåç §ãã ãããð +Section-2ã®Lesson-2ãåç §ãã ãããð --- ### ð ã³ã³ãã©ã¯ãã®ãã¡ã€ã³ã®æå¹æ§ãç¢ºèª @@ -61,8 +61,8 @@ Section-2ã®Lesson-3ãåç §ãã ãããð äžã®ããã«å ããŠã¿ãŸãããã ```solidity -function valid(string calldata name) public pure returns(bool) { - return StringUtils.strlen(name) >= 3 && StringUtils.strlen(name) <= 10; +function valid(string calldata name) public pure returns (bool) { + return StringUtils.strlen(name) >= 3 && StringUtils.strlen(name) <= 10; } ``` @@ -84,15 +84,15 @@ error InvalidName(string name); ```solidity function setRecord(string calldata name, string calldata record) public { - if (msg.sender != domains[name]) revert Unauthorized(); - records[name] = record; + if (msg.sender != domains[name]) revert Unauthorized(); + records[name] = record; } function register(string calldata name) public payable { - if (domains[name] != address(0)) revert AlreadyRegistered(); - if (!valid(name)) revert InvalidName(name); + if (domains[name] != address(0)) revert AlreadyRegistered(); + if (!valid(name)) revert InvalidName(name); - // registeré¢æ°ã®ãã®ä»ã®éšåã¯ãã®ãŸãŸæ®ããŠãããŸãã + // registeré¢æ°ã®ãã®ä»ã®éšåã¯ãã®ãŸãŸæ®ããŠãããŸãã } ``` diff --git "a/docs/Polygon-ENS-Domain/ja/section-4/lesson-1_\343\202\246\343\202\251\343\203\254\343\203\203\343\203\210\343\201\250\343\203\215\343\203\203\343\203\210\343\203\257\343\203\274\343\202\257\343\201\256\346\216\245\347\266\232UI\343\202\222\343\202\273\343\203\203\343\203\210\343\202\242\343\203\203\343\203\227\343\201\227\343\202\210\343\201\206.md" "b/docs/Polygon-ENS-Domain/ja/section-4/lesson-1_\343\202\246\343\202\251\343\203\254\343\203\203\343\203\210\343\201\250\343\203\215\343\203\203\343\203\210\343\203\257\343\203\274\343\202\257\343\201\256\346\216\245\347\266\232UI\343\202\222\343\202\273\343\203\203\343\203\210\343\202\242\343\203\203\343\203\227\343\201\227\343\202\210\343\201\206.md" index 8b8870c5a..4f1e8a91f 100644 --- "a/docs/Polygon-ENS-Domain/ja/section-4/lesson-1_\343\202\246\343\202\251\343\203\254\343\203\203\343\203\210\343\201\250\343\203\215\343\203\203\343\203\210\343\203\257\343\203\274\343\202\257\343\201\256\346\216\245\347\266\232UI\343\202\222\343\202\273\343\203\203\343\203\210\343\202\242\343\203\203\343\203\227\343\201\227\343\202\210\343\201\206.md" +++ "b/docs/Polygon-ENS-Domain/ja/section-4/lesson-1_\343\202\246\343\202\251\343\203\254\343\203\203\343\203\210\343\201\250\343\203\215\343\203\203\343\203\210\343\203\257\343\203\274\343\202\257\343\201\256\346\216\245\347\266\232UI\343\202\222\343\202\273\343\203\203\343\203\210\343\202\242\343\203\203\343\203\227\343\201\227\343\202\210\343\201\206.md" @@ -15,7 +15,7 @@ {/* Display a logo and wallet connection status*/}
Wallet: {currentAccount.slice(0, 6)}...{currentAccount.slice(-4)}
:Not connected
}