Search code examples
pactpact-langkadena

How do I run a function in Pact REPL without a keyset I defined


I defined a keyset (i.e. "my-admin-keyset") in the pact environment data. I want to test a function without that keyset present.

However every function I run, signs with that keyset.

How do I exclude a keyset when running a function?


Solution

  • This can be done by defining things in transaction blocks in the REPL.

    When you need the admin-keyset functionality, you can define the keys for that block you're testing.

    (begin-tx)
    (env-keys ["my-admin-keyset"])
    ; Your code ...
    (commit-tx)
    

    If you want to test without that keyset and with another keyset, just set the environment keys to something else, like this

    (begin-tx)
    (env-keys ["some-other-keyset"])
    ; Your code ...
    (commit-tx)