With the continuous development of the Internet of Things (IoT), the surge in data generated by sensors and smart devices has caused data overload in designated centralized data centers. However, centralized data centers, such as cloud storage, cannot afford to manage these gigantic data in the suitable way. Due to the lots of devices and senors continuously creating data, traditional IoT architectures must address many challenges that are not designed to provide trust, security, resiliency, and low latency. To solve theses problems, we propose a decentralized architecture named MicrothingsChain based on blockchain with smart contract, which enables edge computing nodes storing corresponding domain IoT data and interacting with each other safely. It brings computing and storage capabilities to the edge of the IoT network and realizes distributed storage of large amounts of data. Specially, MicrothingsChain adopts publish-subscribe mode, in which users can access the data across domain. Furthermore, we present one cryptographic currency for our ecology named MicroCoin. The security analysis and experimental results demonstrate that MicrothingsChain is suitable in practice.