//tips
//smart contract
シンプルなhelloworldをtruffleでムンバイテストネットワークにdeployしてみる。
// SPDX-License-Identifier: MIT
// compiler version must be greater than or equal to 0.8.10 and less than 0.9.0
pragma solidity ^0.8.10;
contract HelloWorld {
string public greet = "Hello World!";
}
/*
pragma solidity ^0.4.22;
contract helloWorld {
function renderHelloWorld () public pure returns (string) {
return 'helloWorld';
}
}
*/
後で0.8では
function renderHelloWorld () public pure returns (memory string) {
return 'helloWorld';
}
でもエラーが出る要因を調べておく。
Npm init
Truffle init
npx truffle version
Truffle v5.4.24 (core: 5.4.24)
Solidity - 0.8.10 (solc-js)
Node v16.2.0
Web3.js v1.5.3
きちんと機能は組み込まれているのでganache接続し、truffle compile。
コンパイルもできたので、truffle develop してからのmigrate。
Ganacheへのデプロイは成功。ただ、hello.solがデプロイできておらずこれは.jsで指示ができていなかったから。
const HelloContract=artifacts.require("HelloWor”ld);
module.exports=function(deployer){
deployer.deploy(HelloContract);
}
これを追加し、再度デプロイ。正しくデプロイできている。
今度はテストネットワークへの接続準備。
npm install @truffle/hdwallet-provider
npm install dotenv
昨日同様にtruffle-config修正。.envファイルの追加。
npx truffle migrate --network matic
やはりError: PollingBlockTracker - encountered an error while attempting to update latest block:undefinedのエラー。
https://rpc-mumbai.maticvigil.com/に変換しなければならないのか。

一旦npm install -g truffleを実行。
これでもできないので一旦質問中。
環境は下記。
npm list --depth=0
@truffle/hdwallet-provider@2.0.0
└── dotenv@10.0.0
Truffle v5.4.25 (core: 5.4.25)
Solidity - 0.8.10 (solc-js)
Node v16.2.0
Web3.js v1.5.3