TruffleããHardhatã«ä¹ãæããã®ã§ãããå©ç¨ãã¦ããConsoleã®ä½¿ãæ¹ã«ã¤ãã¦ãã¾ã¨ããã
ãã¾ãConsoleãç´æ¥å©ãã¦Ethereumã¨ããã¨ããã人ã¯è¦ãªãæ°ãããã誰ãã®åèã«ã§ããªãã°ã
ãã¡ã°ãã¯èªåç¨ã®ã¡ã¢ã
Hardhatã®å°å
¥ã¨åºæ¬çãªä½¿ãæ¹ã¯ä»¥åã®è¨äºãåèã«ã
y-nakajo.hatenablog.com
accountsã®åå¾
wallets = await ethers.getSigners() wallets[0].address
å®è¡çµæã¯ä»¥ä¸ã
walletsã«æ ¼ç´ãããwalletæ å ±ã¯hardhat.config.jsã«è¨å®ããç§å¯éµçã®æ°ã¨ãªããå èµnodeèµ·åæã¯20ååå¾ãããã
balanceã®åå¾
ethers.providerãåå¾ãããã¨ã§å種RPCãå®è¡å¯è½ã以ä¸ãã¯balanceã確èªããä¾ã
me = wallets[0].address await ethers.provider.getBalance(me)
contractã®ã¤ã³ã¹ã¿ã³ã¹å
GLDToken = await ethers.getContractFactory("GLDToken") token = await GLDToken.attach("0x3D2b9dc161Eb862EcdffCde9F7dE21599F70CB11") await token.balanceOf(wallets[0].address)
Truffleã ã¨contracts/以ä¸ã®ã³ã³ãã©ã¯ãã¯èªåçã«ãã¼ãããã¦ããããhardhatã§ã¯æåã§ãã¼ãããå¿ è¦ãããã
contract methodã®å®è¡
ã¤ã¾ãã¯sendTransactionããæ¹æ³ãç½²åã®ããã«walletã¨æ¥ç¶ããå¿ è¦ãããã
await token.connect(wallets[0]).transfer("0x3D2b9dc161Eb862EcdffCde9F7dE21599F70CB11", 200000)
gasLimitãªã©ãè¨å®ãããå ´åã¯ãå¼æ°ã®æå¾ã«æå®ããã
await token.connect(wallets[0]).transfer("0x3D2b9dc161Eb862EcdffCde9F7dE21599F70CB11", 200000, {gasLimit: 40000})