In the 6G era, Internet of things (IoT) devices can form a blockchain network, which also faces the problems of data sharing. And the data transmitted and stored through the network has the risk of privacy leaking. Encrypting the shared data can satisfy the need of the privacy, and retrieving the encrypted data can make the data used efficiently.However, to enable users to retrieve encrypted data and perform fine-grained authorization on their encrypted files is still a great challenge. Although attribute-based keyword search (ABKS) is a well-received solution to the challenge, there are still privacy and efficiency issues if the traditional ABKS schemes are directly used in blockchain data sharing. In order to solve the problems, this paper proposes privacy protection data retrieval scheme with an inverted index which is an application of attribute-based encryption. Firstly, our scheme is proved secure against the outside keyword guessing attack (KGA) and chosen keyword attack (CKA) under semi-trusted model. Secondly, the scheme returns a multi-keywords ranked result. Thirdly, we analyze the efficiency of our scheme, and verify it by simulation.The results show that our scheme has improvement in efficiency and can meet the data sharing needs of the blockchain network composed of IoT devices.