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
approveApproves 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);revokeRevokes transaction authorizations for Cosmos.
function revoke(
address spender,
string[] calldata methods
) external returns (bool revoked);increaseAllowanceFor 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);decreaseAllowanceFor 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
ApprovalThis event is triggered when a spender's allowance is modified via a call to the
approvemethod. The event emits avaluefield that specifies the new allowance and a methods field that contains information regarding themethodsfor which the approval was set.event Approval(
address indexed owner,
address indexed spender,
string[] methods,
uint256 value
);RevocationThis event is triggered when an owner revokes a spender's allowance.
event Revocation(
address indexed owner,
address indexed spender,
string[] methods
);AllowanceChangeThis event is triggered when a spender's allowance is modified via a call to the decrease or increase allowance method. The event emits a
valuesfield that specifies the new allowances and amethodsfield that contains information regarding the methods for which the approval was set.event AllowanceChange(
address indexed owner,
address indexed spender,
string[] methods,
uint256[] values
);