0
function Execution (address _from, address _to) {
        _from.transfer(price);
        _to.getBalance(_to) += price;
    }

1) I think it is duplicate but i gone through but nothing helped

2) I want to add money to to account which is deducted from from account plese help me

3) I tried

_to.value()

also to add but nothing helped

1 Answer 1

0

First of all you have to make sure you control the private key of the account you are sending the funds from, either through metamask or through geth node. Then you would have to do something like:

/// Transfer the funds from the smart contract to the user's address
function Execution (uint _Amount) {
    receiver = msg.sender;
    receiver.transfer(_Amount);
}

if you don't want to send the funds to the address thats calling the function then try something along the lines of:

/// Transfer the funds from the smart contract to selected user's address
    function Execution (address _Address, uint _Amount) {
        receiver = _Address;
        receiver.transfer(_Amount);
    }

This should do the trick if you want to keep track of your current balance I recommend creating a new function:

function getBalance() public view returns (uint256) {
    return address(this).balance;
  }

Same thing with the balance if you want to retrieve it from another address:

function getBalance(address _Address) public view returns (uint256) {
        return _Address.balance;
      }

Ps: Make sure your contract includes the function payable() if your contract is going to be receiving any amount of eth. Like so:

function() public payable { }
3
  • make sure to mark it as the correct answer if it was helpful =) Commented Oct 10, 2018 at 14:25
  • Thanks for support i wan't to add the funds to one of my etherium which is debeted from another account Commented Oct 11, 2018 at 5:00
  • You need to have the control of the pk of the account you're sending from, meaning you cant send funds from my account to yours. Even if you do have the private key, you can only withdraw with the account that is executing the smart contract. Commented Oct 12, 2018 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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