This is probably a very simple problem to solve, but I am setting up a node.js backend using express for my Dapp and I can now deploy new contracts just fine.
I now need to figure out how to make calls to a function in an existing contract (created previously in Remix). I have the following syntax:
const platformArtifacts = require('./build/contracts/Platform.json');
var myPlatformContract = contract(platformArtifacts);
myPlatformContract.setProvider(provider);
I know that this is wrong, but I do not know how to do it properly. The function call I make is:
var insurerAddress = '0x...';
var myClientUIC = req.body.clientUIC;
var myClientName = req.body.clientName;
var myClientGroup = req.body.clientGroup;
var myClientNACE = req.body.clientNACE;
var myCreditLine = req.body.creditLine;
var myCreditLineDate = req.body.creditLineDate;
var myClientCurrency = req.body.clientCurrency;
var myClientCity = req.body.clientCity;
var myClientCountry = req.body.clientCountry;
myPlatformContract.at("0x...").createClient(myClientUIC, myClientName, myClientGroup,
myClientNACE, insurerAddress, myCreditLine, myCreditLineDate, myClientCurrency, myClientCity, myClientCountry,
{ from:provider.getAddress() })
.once('transactionHash', function(hash) {
console.log("TxHash: " + hash);
}).on('receipt', function(receipt) { console.log("receipt: " + JSON.stringify(receipt)); })
.then(function(result) {
}, function(error) {
console.log(error);
});
The error I get is:
TypeError: myPlatformContract.at(...).createClient is not a function
However, createClient is a function. I would appreciate any help you an give me with this beginner's issue! Many thanks. Phil