Fundamentals of Building Distributed Applications on Blockchain