IBC Transfer

The ICS20.sol interface, previously known as IBCTransfer.sol, facilitates Solidity contracts to interact with the Inter-Blockchain Communication (IBC) protocol on the CosVM chain. This interface abstracts the intricacies of the underlying IBC transfer module in IBC-go, enabling developers to utilize a simplified Ethereum interface to execute IBC transfers.

This interface, ICS20.sol, provides a convenient means for developers to conduct IBC transfers using familiar Ethereum-based interfaces. It shields them from the complexities of the IBC transfer module's implementation details within IBC-go, allowing for a more straightforward integration of IBC functionality into Solidity contracts on the CosVM chain.

For practical implementation examples, developers can refer to the cosVM/extensions repository, which includes a demonstration showcasing how the ICS20.sol interface can be utilized within Solidity contracts. This example serves as a guide for developers, illustrating the effective usage of the ICS20.sol interface to enable IBC transfers seamlessly within the CosVm ecosystem, leveraging Ethereum-compatible structures and methods.

Function

approve

function approve(
    address spender,
    Allocation[] calldata allocations
) external returns (bool approved);
  • Parameters: spender (address), allocations (an array of Allocation structs)

  • Modifiers: external

  • Returns: approved (boolean)

  • Explanation: This function allows the caller to approve a spender (another address) to manage their allocations. The allocations parameter specifies the list of Allocation structs that the spender is allowed to handle. It returns a boolean indicating whether the approval was successful or not

revoke

function revoke(address spender) external returns (bool revoked);
  • Parameters: spender (address)

  • Modifiers: external Returns: revoked (boolean)

  • Explanation: This function revokes the approval previously given to a spender (specified by the spender address). It returns a boolean indicating whether the revocation was successful or not.

increaseAllowance

function increaseAllowance(
    address spender,
    string calldata sourcePort,
    string calldata sourceChannel,
    string calldata denom,
    uint256 amount
) external returns (bool approved);
  • Parameters: spender (address), sourcePort (string), sourceChannel (string), denom (string), amount (uint256)

  • Modifiers: external

  • Returns: approved (boolean)

  • Explanation: This function increases the allowance granted to a spender by the specified amount for a specific denom in a particular sourcePort and sourceChannel. It returns a boolean indicating whether the increase in allowance was successful or not.

decreaseAllowance

function decreaseAllowance(
    address spender,
    string calldata sourcePort,
    string calldata sourceChannel,
    string calldata denom,
    uint256 amount
) external returns (bool approved);
  • Parameters: spender (address), sourcePort (string), sourceChannel (string), denom (string), amount (uint256)

  • Modifiers: external

  • Returns: approved (boolean)

  • Explanation: This function decreases the allowance granted to a spender by the specified amount for a specific denom in a particular sourcePort and sourceChannel. It returns a boolean indicating whether the decrease in allowance was successful or not.

transfer

function transfer(
    string memory sourcePort,
    string memory sourceChannel,
    string memory denom,
    uint256 amount,
    address sender,
    string memory receiver,
    Height memory timeoutHeight,
    uint64 timeoutTimestamp,
    string memory memo
) external returns (uint64 nextSequence);
  • Parameters: Multiple parameters including sourcePort, sourceChannel, denom, amount, sender, receiver, timeoutHeight, timeoutTimestamp, memo

  • Modifiers: external

  • Returns: nextSequence (uint64)

  • Explanation: This function initiates a transfer of tokens from the specified sender to the designated receiver using IBC (Inter-Blockchain Communication) parameters such as sourcePort, sourceChannel, denom, amount, timeoutHeight, timeoutTimestamp, and an optional memo. It returns the next sequence number of the transfer.

denomTrace

function denomTrace(
    string memory hash
) external returns (DenomTrace memory denomTrace);
  • Parameters: hash (string)

  • Modifiers: external

  • Returns: denomTrace (DenomTrace struct)

  • Explanation: This function retrieves information about a specific denom by providing its hash. It returns a DenomTrace struct containing details about the denomination trace.

denomTraces

function denomTraces(
    PageRequest memory pageRequest
)
    external
    returns (
        DenomTrace[] memory denomTraces,
        PageResponse memory pageResponse
    );
  • Parameters: pageRequest (PageRequest struct)

  • Modifiers: external

  • Returns: An array of denomTraces (DenomTrace structs), pageResponse (PageResponse struct)

  • Explanation: This function fetches multiple DenomTrace structs based on provided pagination parameters (pageRequest). It returns an array of denomTraces and pageResponse that includes pagination details.

denomHash

function denomHash(
    string memory trace
) external returns (string memory hash);
  1. Parameters: trace (string)

  2. Modifiers: external

  3. Returns: hash (string)

  4. Explanation: This function generates a hash of the provided trace information related to a denomination.

Event

IBCTransfer

event IBCTransfer(
    address indexed sender,
    string indexed receiver,
    string sourcePort,
    string sourceChannel,
    string denom,
    uint256 amount,
    string memo
);
  • Purpose: This event is emitted when an IBC (Inter-Blockchain Communication) transfer is executed.

  • Parameters:

    • sender (address): The address of the sender initiating the transfer.

    • receiver (string): The identifier or address of the receiver on the other blockchain.

    • sourcePort (string): The source port of the IBC transaction.

    • sourceChannel (string): The source channel of the IBC transaction.

    • denom (string): The denomination of the tokens transferred.

    • amount (uint256): The amount of tokens transferred.

    • memo (string): Optional information or description related to the transfer.

IBCTransferAuthorization

event IBCTransferAuthorization(
    address indexed grantee,
    address indexed granter,
    string sourcePort,
    string sourceChannel,
    Coin[] spendLimit
);
  • Purpose: This event signals the authorization of a grantee to conduct IBC transfers within specified limits.

  • Parameters:

    • grantee (address): The address of the entity granted the authorization.

    • granter (address): The address granting the authorization.

    • sourcePort (string): The source port for IBC transfers.

    • sourceChannel (string): The source channel for IBC transfers.

    • spendLimit (Coin[]): An array of Coin structs specifying spending limits.

RevokeIBCTransferAuthorization

event RevokeIBCTransferAuthorization(
    address indexed owner,
    address indexed spender
);
  • Purpose: This event indicates the revocation of an IBC transfer authorization.

  • Parameters:

    • owner (address): The address of the owner or holder of the authorization.

    • spender (address): The address of the spender whose authorization has been revoked.

AllowanceChange

event AllowanceChange(
    address indexed owner,
    address indexed spender,
    string[] methods,
    uint256[] values
)
  • Purpose: This event signifies a change in allowance related to specified methods for a spender from an owner.

  • Parameters:

    • owner (address): The address of the owner or token holder.

    • spender (address): The address of the spender who has permissions for certain methods.

    • methods (string[]): An array of strings representing the methods or actions authorized.

    • values (uint256[]): An array of uint256 values associated with each method, representing the allowance or limits.

Last updated