Depends a bit on what you mean by “inside the contract”.
You need to supply to the contract at the minimum the public keys of credential holders (holder ids). These you cannot generate yourself, they are given to you by the user.
The rest you could optimize if the metadata of the credentials is always the same, so when registering a credential you would send one transaction with a list of holder ids.