I'm trying to send some Ether to the payable function of my contract and I'm unable to find/understand a resource to do so.
Here's my attempt below:
Web3 App file (simplified, without initialisation functions) :
App = {
sendEther: function(_value) {
// Enter details to send transaction;
web3.eth.getAccounts(function(error, accounts) {
if (error) {
console.log(error);
}
var account = accounts[1]; // send from account index 1
App.contracts.Plant.deployed().then(function(instance) {
return instance.sendTransaction({ // Something like this?!
from: account,
gas: 5000,
value: _value
});
}).then(function(result) {
console.log(result);
return App.UpdateContractValues();
}).catch(function(err) {
console.log(err.message);
});
});
}
};
Simplified smart contract:
contract Plant {
address public creator;
uint public finney_balance;
function () payable public {
finney_balance += msg.value/1000000000000000;
depositedFunds(msg.value, finney_balance);
}
}
plantInstance.sendTransaction is not a function
which is expected as I wrote it as a placeholder.