Grant allowances
Building a smart contract dapp that enables users to request a fee grant is a challenging task since all transactions necessitate the payment of transaction fees. However, there are several methods that can be utilized. Here are a few examples:
The granter can manually execute each fee grant allowance transaction using the secretcli
Construct a deployment script containing addresses that you wish to assign a fee grant to. This script will utilize the secretcli to perform the fee grant transaction for each specified address.
Implement a simple frontend application that verifies and validates a user's account. After confirming that they are the account owner, the application would execute a Javascript transaction with secret.js to carry out the fee grant transaction.
Create allowance using secretcli
The secretcli is a key tool for accessing the fundamental functionalities of the Archway Blockchain. To install secretcli, refer to Install. Here is an illustration of a typical transaction for creating a grant allowance:
Let's break down a few of the components:
granter_address
: This value represents the address of the account providing tokens to the grantee for transaction execution.grantee_address
: This denotes the account receiving tokens, enabling it to perform transactions using these grants.allowed-messages
: Through the AllowedMsgAllowance type, you can limit the message type a grantee can use the grant for. If not specified, all messages are allowed.expiration
: The deadline by which the allowance must be used or it will expire.spend-limit
: The maximum allowance provided to the grantee. This amount is adjusted as tokens are utilized.
Create allowance using secretjs
This section demonstrates how to create a grant allowance using secretjs. By following the steps outlined in this section, you'll be able to structure a grant allowance message, and execute the necessary transaction which will grant allowances to designated accounts.
The allowance message comprises three essential components: the
granter
,grantee
, and the actualallowance
. As previously mentioned, thegranter
is the address responsible for granting the allowance, while thegrantee
is the recipient who can utilize the granted allowance. Theallowance
component is slightly more intricate, with its structure dependent on the specific type of allowance employed.
To illustrate, let's examine the structure of a grantMsg using the following example:
Now, all that remains is to execute the transaction:
You can find a working example of this in the Fee Grant Faucet here.
Last updated