2

I'm new to the topic but can I somehow sendTransaction via contract instance? What I'm missing here? I simply want to send some ether to contract.

    var abi =[ {
        "constant": true,
        "inputs": [],
        "name": "mess",
        "outputs":
            [ { "name": "", "type": "string", "value": "Some random mess" } ],
        "payable": false, "stateMutability": "view", "type": "function" },
        { "constant": false, "inputs": [], "name": "add", "outputs": [],
            "payable": true, "stateMutability": "payable", "type": "function" },
        { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" },
        { "anonymous": false, "inputs": [ { "indexed": false, "name": "mess", "type": "string" } ],
            "name": "log", "type": "event" } ];

    var MyContract = web3.eth.contract(abi);
    var myContractInstance = MyContract.at('0x9b5131e932127ED42B7F19A75A8f6984d3e8e497');


    function sendEth() {
        web3.eth.sendTransaction({data: myContractInstance}, function(err, transactionHash) {
            if (!err)
                console.log(transactionHash); // ""
        });
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.