Search code examples
pact-lang

Is there a way to determine if a namespace is already taken on Chainweb?


In the Pact language reference entry on namespaces, the text is clear that on public blockchains modules and interfaces must be defined within namespaces, and namespaces must be globally-unique.

Namespace declarations provide a unique prefix for modules and interfaces defined within the namespace scope. Namespaces are handled differently in public and private blockchain contexts: in private they are freely definable, and the root namespace (ie, not using a namespace at all) is available for user code. In public blockchains, users are not allowed to use the root namespace (which is reserved for built-in contracts like the coin contract) and must define code within a namespace, which may or may not be definable (ie, users might be restricted to “user” namespaces).

If I am writing a smart contract and need to define a namespace, is there any way for me to verify whether my namespace is unique?


Solution

  • Use (list-modules) to get a list of existing modules with their full namespace name. You can also list them from Chainweaver. Please note that you cannot create the namespace on testnet or mainnet without it being assigned to you by Kadena. If you want to deploy in a public space without having to obtain a namespace use the existing namespace free or user.