I have created this simple Dapp and it work fine in the private testnet & java VM inside Remix and outside it using a web interface. The problem come when it will be used in the "public" testnet (Ropsten). It send the transaction and execute the function but never send the ether from the contract to the address. I' ve already set the value of the contract to the correct value.
Sorry for bad English
pragma solidity ^0.4.0;
contract DApp
{
uint256 acconto;
uint256 saldo;
address committent;
address technician;
bool done = false;
uint timeFinish;
modifier onlyCom
{
if (msg.sender != committent)
{
assert(true);
}
else
{
_;
}
}
function DApp (uint256 _acconto, uint256 _saldo, address _technician, uint _Time) payable public
{
if (msg.value >= _acconto + _saldo) {
acconto = _acconto * 1000000000000000000;
saldo = _saldo * 1000000000000000000;
committent = msg.sender;
technician = _technician;
timeFinish = block.timestamp + _Time;
technician.transfer(acconto);
} else revert();
}
function Done () public onlyCom
{
done = true;
}
function reciveReward () payable public
{
if(done == true)
{
technician.transfer(saldo);
selfdestruct(this);
}
else
{
if(block.timestamp >= timeFinish)
{
committent.transfer(saldo);
selfdestruct(this);
}
assert(true);
}
}
}
Edit:
This is how it should work:
I write the data for the transaction
In the photo I putted the value of contract with an error, I will correct it in the last photo.
Basically now the deployer is paying 4 ether + transaction cost.
The "acconto" goes directly to the technician address.
The rest remains into the contract.
This is the change of money (In the first try only the first part of the contract worked fine because the value wasn' t enough)
I remaded the whole transaction at the receiveReward call the remaining part goes to technician and all worked as I wanted.
Why in the Ropsten Test Net it doesn' t work? It doesn' t send ether or am I looking in the wrong direction?