Skip to main content

Authorization

To enable smart contracts to send messages on behalf of a user account, authorization is required. This is achieved through the use of the Authorization.sol contract, which provides the necessary functions to grant approvals and allowances. Precompiled contracts utilize the Authorization interface to allow users to approve corresponding messages and amounts, thereby granting the necessary authorization for the smart contracts to send messages on their behalf.

Solidity Interfaces

Authorization.sol

Find the Solidity interface in the Humans.ai/extensions repo.

Transactions

  • approve

    Approves a list of transactions in Cosmos or IBC involving a certain number of tokens.

    function approve(
    address spender,
    uint256 amount,
    string[] calldata methods
    ) external returns (bool approved);
  • revoke

    Revokes transaction authorizations for Cosmos.

    function revoke(
    address spender,
    string[] calldata methods
    ) external returns (bool revoked);
  • increaseAllowance

    For IBC transfer methods or staking, increases a specific spender's allowence by a predetermined number of tokens.

    function increaseAllowance(
    address spender,
    uint256 amount,
    string[] calldata methods
    ) external returns (bool approved);
  • decreaseAllowance

    For IBC transfer methods or staking, decreases a specific spender's allowence by a predetermined number of tokens.

    function decreaseAllowance(
    address spender,
    uint256 amount,
    string[] calldata methods
    ) external returns (bool approved);

Queries

  • allowance

This function returns the remaining number of tokens that the spender is authorized to spend on behalf of the owner through Inter-Blockchain Communication (IBC) transfer methods or staking. The default value for this function is zero.

```solidity
function allowance(
address owner,
address spender,
string calldata method
) external view returns (uint256 remaining);
```

Events

  • Approval

    This event is triggered when a spender's allowance is modified via a call to the approve method. The event emits a value field that specifies the new allowance and a methods field that contains information regarding the methods for which the approval was set.

    event Approval(
    address indexed owner,
    address indexed spender,
    string[] methods,
    uint256 value
    );
  • Revocation

    This event is triggered when an owner revokes a spender's allowance.

    event Revocation(
    address indexed owner,
    address indexed spender,
    string[] methods
    );
  • AllowanceChange

    This event is triggered when a spender's allowance is modified via a call to the decrease or increase allowance method. The event emits a values field that specifies the new allowances and a methods field that contains information regarding the methods for which the approval was set.

    event AllowanceChange(
    address indexed owner,
    address indexed spender,
    string[] methods,
    uint256[] values
    );