Let's begin writing the orderbook smart contract with the functions that we discussed in the previous section:
- Start by creating a smart contract file called Orderbook.sol.
- We begin by defining first the Solidity compiler version:
pragma solidity ^0.5.2;
- Next, we import the open-zeppelin contract template (ERC20.sol):
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
Importing the ERC20 contract allows our smart contract to transfer the Gold and USD ERC20 tokens to and from the trader's Ethereum accounts, using the Transfer method in the ERC20 contract.
- Next, we define the contract name as Orderbook:
contract Orderbook {using SafeMath for uint;
We also use the using keyword to declare that we'll be ...