'How do I set Royalty on OpenSea from my DApp?

The project we are supposed to make is a minting page that can set royalty fee on opensea testnet from the dapp itself (i.e. you cannot set it from open sea's interface)

I already have a nft contract made with ERC2981 for the royalties feature and made the frond-end

what I want to is when I call the constructor of the smart contract it should automatically set the royalty fee (on open sea) to whatever I enter.

is this possible? if it is can you guide me on how to do it, and if not how should I do it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source