Getting up and running with Ethereum on Ubuntu Trusty has been fairly painless thanks to the truffle development environment. The HOWTO: Building Ethereum Apps With Truffle is a good introduction but a few details, like directory layout, have changed since then.
At the most recent Austin Ethereum meetup we had a conversation about how to handle the contingency of when you need to update your “contract” which has already been deployed to the blockchain. Using “contract” as the term for the main class makes the discussion of updating such code more difficult than it should be. Code often needs to be updated for new features or fixing bugs.
For instance, it is important to check (as mentioned in How to Write Safe Smart Contracts and Address types) the return value of send().
The “King of the Ether Throne” post-mortem shares the unenviable experience of not doing this check. The offending solidity code was
currentMonarch.etherAddress.send(compensation);
In this particular case, send() was failing because the destination address was a contract address (an Ethereum Mist “contract-based wallet”) and the default 2300 gas supplied by send() was insufficient for the destination contract to run. So, their fix was to define a new sendWithGas() function which allows extra gas to be sent and returns a boolean like send():
//Unfortunately destination.send() only includes a stipend of 2300 gas, which
//isn't enough to send ether to some wallet contracts - use this to add more.
function sendWithGas(address destination, uint256 value, uint256 extraGasAmt) internal returns (bool)
{
return destination.call.value(value).gas(extraGasAmt)();
}
Now, the sendWithGas() return value is stored in a payment status and if that status is failure, the operation is cancelled with prior state restored.
Now, they just need to update their contract!