Authorization

Granting authorization to enable smart contracts to send messages on behalf of a user account involves establishing a mechanism within the blockchain network that allows users to delegate specific permissions and capabilities to other contracts or addresses. This authorization process is facilitated through the Authorization.sol contract, which contains functions to grant approvals and allowances. The contract conforms to the AuthorizationI interface, providing a standardized set of functions and events to manage these authorizations

Functions:

1. approve

 function approve(
        address spender,
        uint256 amount,
        string[] calldata methods
    ) external returns (bool approved);
  • Description: Approves a list of Cosmos or IBC transactions with a specific amount of tokens.

  • Parameters:

    • spender: The address that will spend the funds.

    • amount: The amount of tokens to be spent.

    • methods: The message type URLs of the methods to approve.

  • Return: Boolean value indicating if the approval was successful.

2. revoke

function revoke(
        address spender,
        string[] calldata methods
    ) external returns (bool revoked);
  • Description: Revokes a list of Cosmos transactions.

  • Parameters:

    • spender: The address that will spend the funds.

    • methods: The message type URLs of the methods to revoke.

    • Return: Boolean value indicating if the revocation was successful.

3. increaseAllowance

function increaseAllowance(
        address spender,
        uint256 amount,
        string[] calldata methods
    ) external returns (bool approved);
  • Description: Increases the allowance of a given spender by a specific amount of tokens for IBC transfer methods or staking.

  • Parameters:

    • spender: The address that will spend the funds.

    • amount: The amount of tokens to be added to the allowance.

    • methods: The message type URLs of the methods to approve.

    • Return: Boolean value indicating if the increase in allowance was successful.

4. decreaseAllowance

  function decreaseAllowance(
        address spender,
        uint256 amount,
        string[] calldata methods
    ) external returns (bool approved);
  • Description: Decreases the allowance of a given spender by a specific amount of tokens for IBC transfer methods or staking.

  • Parameters:

    • spender: The address that will spend the funds.

    • amount: The amount of tokens to be deducted from the allowance.

    • methods: The message type URLs of the methods to approve.

  • Return: Boolean value indicating if the decrease in allowance was successful.

5. allowance

function allowance(
        address owner,
        address spender,
        string calldata method
    ) external view returns (uint256 remaining);
  • Description: Returns the remaining number of tokens that a spender is allowed to spend on behalf of the owner through IBC transfer methods or staking.

  • Parameters:

    • owner: The address of the account owning tokens.

    • spender: The address of the account able to transfer the tokens.

    • method: The message type URL of the method for which the approval should be queried.

  • Return: The remaining number of tokens available to be spent.

Events:

1. Approval

  event Approval(
        address indexed owner,
        address indexed spender,
        string[] methods,
        uint256 value
    );
  • Description: Emitted when the allowance of a spender is set by a call to the approve method.

  • Parameters:

    • owner: Owner of the tokens. spender: Address that will spend the tokens.

    • methods: List of message type URLs for which the approval is set.

    • value: Amount of tokens approved to be spent.

2. Revocation

event Revocation(
        address indexed owner,
        address indexed spender,
        string[] methods
    );
  • Description: Emitted when an owner revokes a spender's allowance for specific methods.

  • Parameters:

    • owner: Owner of the tokens.

    • spender: Address that will spend the tokens.

    • methods: List of message type URLs for which the approval is revoked.

3. AllowanceChange

  event AllowanceChange(
        address indexed owner,
        address indexed spender,
        string[] methods,
        uint256[] values
    );
  • Description: Emitted when the allowance of a spender changes due to a call to increaseAllowance or decreaseAllowance methods.

  • Parameters:

    • owner: Owner of the tokens.

    • spender: Address that will spend the tokens.

    • methods: List of message type URLs for which the approval is set.

    • values: Amounts of tokens approved to be spent.

Last updated