geth控制台 部署合约问题,复制到geth控制台回车提示Cannot read property 'deploy' of undefined

以下是remix-ide里的合约的details里的web3depoly直接复制过来的,我直接复制到geth控制台部署,回车后提示 TypeError: Cannot read property 'deploy' of undefined at <eval>:1:20(4)

求解,怎么解决?怎么别人的这段都是contract.new(...)的,为啥我这是contract.depoly(...)? 环境:solidity ^0.8.3

var infocontractContract = new web3.eth.Contract([{"inputs":[],"name":"getInfo","outputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"uint256","name":"_age","type":"uint256"}],"name":"setInfo","outputs":[],"stateMutability":"nonpayable","type":"function"}]);
var infocontract = infocontractContract.deploy({
     data: '0x608060....(太长省略)', 
     arguments: [
     ]
}).send({
     from: web3.eth.accounts[0], 
     gas: '4700000'
   }, function (e, contract){
    console.log(e, contract);
    if (typeof contract.address !== 'undefined') {
         console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
    }
 })
请先 登录 后评论

2 个回答

Tiny熊 - 布道者
  擅长:智能合约,以太坊
请先 登录 后评论
Kason Wong
请先 登录 后评论