I want one contract to collect a certain amount of finney before sending it to another contract, but I can't simply send in with C2.send(thisMuch)
.
function() {
Dividend m = Dividend(dividendAddr);
if (this.balance >= 70 finney) {
uint sendProfit = this.balance;
}
m.Enter.send(sendProfit);
}
This is what I have so far, but I'm completely lost when it comes to sending finney from one contract to the next. How can I do that?
I have made two contracts on how I think it should work. Contract one sends it to contract two.
contract one {
address public deployer;
address public targetAddress;
modifier execute {
if (msg.sender == deployer) {
_
}
}
function one(address _targetAddress) {
deployer = msg.sender;
targetAddress = _targetAddress;
}
function forward() {
two m = two(targetAddress);
m.pay();
targetAddress.send(this.balance);
}
function() {
forward();
}
function sendBack() execute {
deployer.send(this.balance);
}
}
Contract two sends it back to me.
contract two {
address public deployer;
function two() {
deployer = msg.sender;
}
function pay() {
deployer.send(this.balance);
}
function() {
pay();
}
}
Is this how it should work?