Image for post
Image for post

How to develop smart contracts for Ethereum blockchain

Step 1: Find an open source Solidity contract as a starting point

Step 2: Define the abstract token contract

contract CryptoSticker is ERC721, Ownable { function mint(address _to, uint256 _stickerId, string _stickerName) external; function burn(address _owner, uint256 _stickerId) external; function stickerName(uint256 _stickerId) external view returns (string); }

Step 3: Define the abstract store contract

contract CryptoStickerStore is Ownable { function transferTokenOwnership(address _to) external; function mintSticker(uint256 _stickerId, string _stickerName) external; function burnSticker(uint256 _stickerId) external; function listSticker(uint256 _stickerId, uint256 _price) external; function unlistSticker(uint256 _stickerId) external; function listingPrice(uint256 _stickerId) external view returns (uint256); function listingName(uint256 _stickerId) external view returns (string); function purchaseSticker(uint256 _stickerId) external payable; function withdraw() external; }

Step 4: Write test cases for use with TDD

Step 5: Implement the smart contract code

function listSticker(uint256 _stickerId, uint256 _price) external onlyOwnerOf(_stickerId) { require(token.exists(_stickerId)); require(listings[_stickerId].price == 0); require(_price > 0); uint256 index = listedIds.push(_stickerId) - 1; listings[_stickerId] = Listing(_price, index); emit ListSticker(msg.sender, _stickerId, _price); }

Step 6: Create a custom dev chain for testing

All done. Ready to develop your smart contract?

We help companies forge meaningful connections with their customers and employees through lovable apps and digital products. Learn more at arctouch.com.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store