I try to develop a simple app with meteor and metamask. I'm trying to change the state of the "name" variable of this contract throught my app :
contract demo{
string public name = 'Etienne';
function changeName(string _newName){
name = _newName;
}
}
I can read and display the name variable and use it in a helper with
const myContract = web3.eth.contract(AbiArray).at(contractAddress);
Template.home.helpers({
name () {
const template = Template.instance();
myContract.name(function(err,res){
TemplateVar.set(template, "name", res);
})
But how do I use my changeName function ? Something like this nothing happens (change-name is linked to a button):
Template.home.events({
'click .change-name'(){
myContract.changeName('Pitouf');
},
})
If I exlpicitely say it is transaction, not a call, I get a transaction in metamask, but the name still reads the same :
Template.home.events({
'click .change-name'(){
myContract.changeName('Pitouf').sendTransaction();
},
})
I am pretty sure I am using the wrong arguments… but how?