From the documentation:
Example: Defining a namespace
Defining a namespace requires a keyset, and a namespace name of type string:
(define-keyset 'my-keyset)
(define-namespace 'my-namespace (read-keyset 'my-keyset))
This is how the documentation initially describes the process of defining a namespace and associating it with a keyset in its cursory introduction to this topic. I've tried this out, creating a keyset beforehand, too (that is not the issue).
So I use this code:
(define-keyset 'my-keyset)
(define-namespace 'my-namespace (read-keyset 'my-keyset))
With the keyset right there, too Keyset created in environment
When I load the example code from above into the REPL I get the following error message:
2:1Invalid arguments, received ["my-namespace"] for namespace:string user-guard:guard admin-guard:guard -> string
Why does this happen and what is the significance of this error? I've read in the documentation that
"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)."
And I was wondering whether this had something to do with the error message but the statement itself was rather ambiguous and I don't know how to work around it in case this is what is happening (or what it really means and when it applies)
I've tried writing it in different ways but it always ends up with the same error. Any ideas on what is going on and why this fails?
The docs are outdated.
Based on the error message, it expects 1 string and 2 guards.
Invalid arguments, received ["my-namespace"] for namespace:string user-guard:guard admin-guard:guard -> string
I.e. it expects these inputs
namespace:string
user-guard:guard
admin-guard:guard
This should work
(define-keyset 'my-keyset)
(define-namespace 'my-namespace (read-keyset 'my-keyset) (read-keyset 'my-keyset))