Managing Permits
Permits are stored in local storage inside an object calledgriptape.js
A permit is a free authentication message from a certain public address, like a wallet signature, permits are stored locally so you don't need to re-generate a permit.
Add a permit
To create a permit, we must first import in our application permitManager
from @stakeordie/griptape.js
.
Next, we're going to use the permitManager
for this we use the add
function, to which we're going to pass our contract and a permissions array.
You can notice that within the createPermit
function we are also using permitManager.get()
this function returns a boolean
indicating whether or not this account has a permit
. In this case it already has it and we add it to the setIsPermit
variable.
Use a permit with the contracts API
To learn more about contract definitions, click here.
Here is an example of how to use a permit in our contract definition, first we must import the APIs thet we require.
Now we create myContract_permit
object, where we add the query
called getBalance
wich receives a permit
object and returns in this case the query
and the permit
.
Finally we export and extend our contract.
Last updated