In recent years, food safety issues have drawn growing concerns from society. In order to efficiently detect and prevent food safety problems and trace the accountability, building a reliable traceability system is indispensable. It is especially essential to accurately record, share, and trace the specific data within the whole food supply chain, including the process of production, processing, warehousing, transportation, and retail. The traditional traceability systems have issues, such as data invisibility, tampering, and sensitive information disclosure. The blockchain is a promising technology for the food safety traceability system because of the characteristics, such as the irreversible time vector, smart contract, and consensus algorithm. This paper proposes a food safety traceability system based on the blockchain and the EPC Information Services and develops a prototype system. The management architecture of on-chain & off-chain data is proposed as well, through which the traceability system can alleviate the data explosion issue of the blockchain for the Internet of Things. Furthermore, the enterprise-level smart contract is designed to prevent data tampering and sensitive information disclosure during information interaction among participants. The prototype system was implemented based on the Ethereum. According to the test results, the average time of information query response is around 2 ms, while the amount of on-chain data and query counts are 1 GB and 1000 times/s, respectively. INDEX TERMS Food safety, traceability, blockchain, EPCIS, on-chain & off-chain, smart contract.