I am writing a smart contract which will contain an escrow service. The escrow is to be a smart contract and eventually I want to use it to transfer meta tokens from the escrows address to another user. The issue I have is that I want to be able to transfer from the escrow but have a modifier which allows only the escrow contract itself to call. I have tried to make a modifier which only allows "this" (referring to the contract address) to make the call but that doesn't work.
If a contract internally calls another function how can I have it that only the contract itself can call the function and have the transfer happen. Msg.sender doesn't seem to accommodate for this.
My Code:
modifier contractOnly(){
address contractAddress = this;
if(msg.sender != contractAddress) throw; _
}
and the transfer function (which needs the modifier to prevent anyone from calling the function and taking all the tokens from the escrow)
function transfer(address from, address to, uint amount)
contractOnly returns (uint) {
balances[from] -= amount;
balances[to] += amount;
return balances[from];
}