My purpose is deploying a smart contract to a private network with Node-js. I work on Truffle and Ganache. I tried it with "truffle-contract". But in deploying process an error occurs. My contract name is "Deploy".
Command i used to deploy: myContract.deploy().send(...);
.
The error: TypeError: myContract.deploy is not a function
.
I don't know what is the problem. Please provide an appropriate code.
app.js:
var fs=require("fs");
var solc=require("solc");
var contract=require("truffle-contract");
var Web3=require('web3');
var web3=new Web3('ws://127.0.0.1:8545');
var address="0xfE72f8B082CF099715785d23FBeaed9272F27559";
var DeployJson=fs.readFileSync("E:/Deploy/build/contracts/Deploy.json");
var DeployJs=JSON.parse(DeployJson);
var DeployAbi=DeployJs.abi;
var contract=require("truffle-contract");
var myContract=contract({abi: DeployAbi, unlinked_binary:"0x608060405234801561001057600080fd5b5061011d806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806318620ef014602d575b600080fd5b603360ab565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101560715780820151818401526020810190506058565b50505050905090810190601f168015609d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60606040518060400160405280601581526020017f436f6e7472616374206973206465706c6f79656421000000000000000000000081525090509056fea265627a7a723158206cddf11cab61deaceb98041f67bc88c98dfa84738b1c39323262ccd385732c7864736f6c634300050c0032"});
myContract.setProvider(web3);
myContract.deploy().send({from:address, gas:1000000, gasPrice:200});
deploy
function. Shouldn't it bedeployed()
?new()
but i don't usage ofnew()
.