Skip to main content
GitHub: ICosmos

Overview

The ICosmos interface defines a set of functions for interacting with the Cosmos blockchain from an Ethereum Virtual Machine (EVM) environment. It includes functions for address conversion, querying, and executing Cosmos messages.

Constants

COSMOS_ADDRESS

The address of the Cosmos precompile contract.

COSMOS_CONTRACT

The instance of the ICosmos contract.

Functions

is_blocked_address

Checks if an address is blocked by the Cosmos SDK bank module.

Parameters

NameTypeDescription
accountaddressThe address to check

Returns

TypeDescription
booltrue if the address is blocked, false otherwise

is_module_address

Checks if an address is a Cosmos SDK module account.

Parameters

NameTypeDescription
accountaddressThe address to check

Returns

TypeDescription
booltrue if the address is a module account, false otherwise

to_cosmos_address

Converts an EVM hex format address to a Cosmos bech32 format address.

Parameters

NameTypeDescription
evm_addressaddressThe EVM address to convert

Returns

TypeDescription
string memoryThe corresponding Cosmos address

to_evm_address

Converts a Cosmos bech32 format address to an EVM hex format address.

Parameters

NameTypeDescription
cosmos_addressstring memoryThe Cosmos address to convert

Returns

TypeDescription
addressThe corresponding EVM address

to_denom

Converts an ERC20 address to a Cosmos coin denom.

Parameters

NameTypeDescription
erc20_addressaddressThe ERC20 address to convert

Returns

TypeDescription
string memoryThe corresponding Cosmos denom

to_erc20

Converts a Cosmos coin denom to an ERC20 address.

Parameters

NameTypeDescription
denomstring memoryThe Cosmos denom to convert

Returns

TypeDescription
addressThe corresponding ERC20 address

execute_cosmos

Records a Cosmos message to be executed after the current message execution. The message must be in JSON string format.

Parameters

NameTypeDescription
msgstring memoryThe Cosmos message in JSON format

Returns

TypeDescription
boolDummy return value

query_cosmos

Executes a whitelisted Cosmos SDK query.

Parameters

NameTypeDescription
pathstring memoryThe query path
reqstring memoryThe query request in JSON format

Returns

TypeDescription
string memoryThe query result in JSON format