Reputation: 29
const {web3js, myAccount} = require ('./utils')
const {bytecode} = require ('./contractartifact')
async function deploy() {
web3js.eth.sendTransaction({
from: myAccount.address,
data: bytecode,
gas: 800
})
.on('receipt', console.log)
}
deploy()
Error
C:\Users\giris\getter-setter\deploy.js:9 web3js.eth.sendTransaction({ ^
TypeError: Cannot read properties of undefined (reading 'eth')
at deploy (C:\Users\giris\getter-setter\deploy.js:9:12)
at Object. (C:\Users\giris\getter-setter\deploy.js:19:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules /cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
Upvotes: 0
Views: 2561
Reputation: 2187
Your import is incorrect here:
const {web3js, myAccount} = require ('./utils')
It should be:
const web3js = new Web3(Web3.givenProvider || "ws://localhost:8545");
Upvotes: 1