I have some trouble creating two interacting contracts. The first contract should receive ether from a user at a function payRate() and forward the amount to another contract, which is saved at the address pool. Both functions (the payRate() and the receivePayment() function) are payable and receivePayment() is working if called from a user. Mining the contracts works fine but using the functions fails. I also tried a different versions with small fixed amounts of ether, same result.
The environment I used is Visual Studio Code with the Solidity extension as compiler and Parity (dev. chain).
pragma solidity ^0.4.18;
contract sendEther {
address owner;
address pool;
uint amountPaid;
function sendEther(address _pool) public {
pool = _pool;
owner = msg.sender;
}
function payRate() payable {
require(pool != address(0));
pool.transfer(msg.value);
amountPaid += msg.value;
//other ways of sending i tried:
//TransactionPool test = TransactionPool(pool);
//test.receivePayment().value(msg.value);
//pool.call.value(msg.value)(bytes4(keccak256("receivePayment()")));
}
}
and
pragma solidity ^0.4.18;
contract TransactionPool {
address owner;
uint totalPayments;
function TransactionPool() public {
owner = msg.sender;
}
function receivePayment() public payable {
totalPayments += msg.value;
}
function() payable public { //fallback function
totalPayments += msg.value;
}
}
Thanks!