2
pragma solidity ^0.4.23;

contract Hotelbooking{

    address receiver;
    function deposit(uint256 _amount) payable public {
        require(msg.value == _amount);
        // nothing else to do!
    }

    function Execution (address _Address, uint _Amount) {
           receiver = _Address;
           receiver.transfer(_Amount);
       }
    function getBalance() public view returns (uint256) {
        return address(this).balance;
    }
}

I want to write a block chain application to transfer ether from one account to another

I tried more blogs and stack overflow questions but nothing is helping me.

I deployed using truffle with following commands

Hotelbooking.deployed().then(function(i){app = i})

app.Execution(web3.eth.accounts[1],10)

I tried every blog and stack overflow q&a. I want to transfer ether from one account to another I am getting following error

at XMLHttpRequest._onHttpResponseEnd (/usr/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1) at XMLHttpRequest._setReadyState (/usr/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1) at XMLHttpRequestEventTarget.dispatchEvent (/usr/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1) at XMLHttpRequest.request.onreadystatechange (/usr/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1) at /usr/lib/node_modules/truffle/build/webpack:/packages/truffle-provider/wrapper.js:134:1 at /usr/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:86:1 at Object.InvalidResponse (/usr/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1)

0

I was able to get your contract working without modifications. I think it's just how you're interacting with it is causing you problems. Here are the steps I took:

$ truffle console --network development
truffle(development)> Hotelbooking.deployed().then(app => app.deposit(10, {value: 10}))
{ tx: '0x54c09f6a4f5eac57ca09bf54c6056e1439bd82c00b06a67680a3b3f490ee8547',
  receipt:
  { transactionHash: '0x54c09f6a4f5eac57ca09bf54c6056e1439bd82c00b06a67680a3b3f490ee8547',
    transactionIndex: 0,
    blockHash: '0x973414f0c998d8dcd04dca66704b639d93d47a84f1115d110f3d725d2dc83e8b',
    blockNumber: 5,
    gasUsed: 21703,
    cumulativeGasUsed: 21703,
    contractAddress: null,
    logs: [],
    status: '0x01',
    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' },
  logs: [] }
truffle(development)> Hotelbooking.deployed().then(app => app.Execution(web3.eth.accounts[1], 10, {from: web3.eth.accounts[0]}))
{ tx: '0x242bd5f0fc0b7e071e14d85ba269c2b216af67320fc3de2814670772d8269f1b',
  receipt:
  { transactionHash: '0x242bd5f0fc0b7e071e14d85ba269c2b216af67320fc3de2814670772d8269f1b',
    transactionIndex: 0,
    blockHash: '0xac0fad638722200b102891158d3348493ce3e0bcff63eb54515f845385875756',
    blockNumber: 6,
    gasUsed: 51127,
    cumulativeGasUsed: 51127,
    contractAddress: null,
    logs: [],
    status: '0x01',
    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' },
  logs: [] }

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.