LoginSignup
5
4

More than 5 years have passed since last update.

エラー: "web3.eth.contract is not a function"

Posted at

原因

  • Web3.jsのバージョンとコードの記法が異なる。

対策

1.0.x を利用している場合は↓のように記載することで解決。

const myContract = new web3.eth.Contract(JSON.parse(myContractABI), myContractAddress);

元のコード

const myContract = web3.eth.contract(JSON.parse(myContractABI)).at(myContractAddress);

エラー内容

TypeError: web3.eth.contract is not a function

以下のようなエラーも同様

TypeError: Cannot read property 'sendTransaction' of undefined
TypeError: (intermediate value).at is not a function
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4