Fifth-generation (5G) technology is anticipated to allow a slew of novel applications across a variety of industries. The wireless communication of the 5G and Beyond-5G (B5G) networks will accommodate a wide variety of services and user expectations, including intense end-user connectivity, sub-1 ms delay, and a transmission rate of 100 Gbps. Network slicing is envisioned as an appropriate ... [Show full abstract] technique that can meet these disparate requirements. The intrinsic qualities of a blockchain, which has lately acquired prominence, mean that it is critical for the 5G network and B5G networks. In particular, the incorporation of blockchain technology into B5G enables the network to effectively monitor and control resource utilization and sharing. Using blockchain technology, a network-slicing architecture referred to as the Blockchain Consensus Framework is introduced that allows resource providers to dynamically contract resources, especially the radio access network (RAN) schedule, to guarantee that their end-to-end services are effortlessly executed. The core of our methodology is comprehensive service procurement, which offers the fine-grained adaptive allocation of resources through a blockchain-based consensus mechanism. Our objective is to have Primary User—Secondary User (PU—SU) interactions with a variety of services, while minimizing the operation and maintenance costs of the 5G service providers. A Blockchain-Enabled Network Slicing Model (BENS), which is a learning-based algorithm, is incorporated to handle the spectrum resource allocation in a sophisticate manner. The performance and inferences of the proposed work are analyzed in detail.