Making a Birthday Contract.

Intermediate Solidity Ethereum Notes & Development.

4 min readDec 5, 2017

--

Let’s make a Birthday smart contract in Solidity.

Note/selfplug: If you are looking for an introduction to Ethereum, Solidity and Smart Contracts I just published an eBook on getting started:https://www.amazon.com/dp/B078CQ8L7V

The Problem / challenge:

  • To have a contract record it’s birth on the blockchain.
  • To have the contract tell you it’s Birthday.
  • Bonus / Extra Credit: Return the Birthday in a Human Readable way without the need of external UI’s.

The contract :

pragma solidity ^ 0.4.0;contract DateTime {
function getYear(uint timestamp) public constant returns (uint16);
function getMonth(uint timestamp) public constant returns (uint8);
function getDay(uint timestamp) public constant returns (uint8);
}
contract BirthDay {
uint public bday;
address public dateTimeAddr = 0x8Fc065565E3e44aef229F1D06aac009D6A524e82;
DateTime dateTime =…

--

--