The highly dynamic nature of cognitive radio (CR) systems and their stringent latency requirements pose a major challenge in the realization of efficient intelligent transport systems (ITS). In this paper, we investigate relay selection and opportunistic spectrum access in conjunction with blockchain technology in a secure manner. Specifically, we propose a cross-layer method for secure relay selection, where secondary relays (SRs) are granted access to available spectrum bands based on the balance of their respective virtual wallets. These virtual wallets, which are built based on the SRs' secrecy capacity and their behavior in the network, are the predominant factors that allow SRs to participate in an auction model. To quantify the trustworthiness of the SRs, we formulate a mathematical framework to evaluate the trust value of each SR, which is then leveraged for rewarding or penalizing the SR. Furthermore, we develop an offline blockchain framework to store the information of participating relays and make it available for future operations, in order to detect reputable and non-reputable relays in the presence of multiple eavesdroppers. The stored reputations of the participating relays are used to develop a self-learning algorithm to exclude the non-reputable relays from the selection group. Finally, we present thorough numerical results to demonstrate the superiority of the proposed system in terms of security, credibility, and integrity.