Whenever i try to hit this request i get a error, also used debugger and it says buyTokens function not found.
exports.transferEthShare = (data, next) => {
var data_contract = require('../contractABI/data');
var abiData = require('../contractABI/testabi');
let send_add = data.user_address;
let recv_add = data.contract_address;
let transfer_amount = web3.toWei(data.amount, 'ether');
let nonce = web3.toHex(web3.eth.getTransactionCount(data.user_address));
var private_key = data.user_pri_key.slice(2);
let gas = web3.toHex(data.gas_limit);
let gasPrice = web3.toHex(data.gas_price);
var contract_abi = abiData.abi;
var demo_Contract = web3.eth.contract(contract_abi);
let deploy = demo_Contract.buyTokens.getData( // to ask --- start
send_add,
recv_add,
{
data: data_contract.abiData,
}); // to ask --- end
var rawTx = {
from: send_add,
nonce: nonce,
gasLimit: gas,
gasPrice: gasPrice,
value: web3.toHex(transfer_amount),
to: recv_add,
data: deploy,
};
var transaction = new tx(rawTx);
var txData = new Buffer(private_key, 'hex');
transaction.sign(txData);
var serializedTx = transaction.serialize().toString('hex');
web3.eth.sendRawTransaction('0x' + serializedTx, function (err, txHash) {
if (txHash) {
next(null, txHash);
}
else if (err && err.message) {
next(err.message, null);
}
else {
next('Unable to sendRawTransaction', null);
}
});
}