You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
The cosmos native token ecosystem and EVM ecosystem are disconnected currently, connect these two can make many user cases possible:
Wrap some ibc tokens in erc20 contract to participate in the evm DeFi applications.
Move some erc20 tokens to native tokens to enjoy cosmos ecosystem, like, ibc transfer, gravity bridge, gravity dex, etc.
Scenario 1
Wrap an existing native token in an erc20 contract
Module Managed ERC20 Contract
ERC20 contract that is managed by native module:
Contract code is builtin and deployed by native module
Permissions of mint/burn are granted to the native module only, like this:
require(msg.sender == native_module_address)
Security: normal clients can't sign transaction with the private key corresponds to the native_module_address, only native module can execute transactions with that sender address.
With this, native module can deploy and manage erc20 tokens.
Wrap native token in EVM
The native module provide three types of message:
deploy(denom), native module deploy a standard erc20 contract for the native token, and record the relationship between the native token and the contract address.
deposit(denom, amount), user locks some native tokens to the module account, and the module mint equivalent erc20 tokens in the contract.
withdraw(denom, amount), the native module burns user's erc20 tokens in the contract, and release equivalent native tokens from module account to user.
Scenario 2
Move existing erc20 token to native token.
We can provide an api to evm smart contract to mint/burn native tokens of bank module.
How to ensure ownership?
the native tokens can be named as evm/contract_address, and the contract can only manage native tokens with it's own address.
How is the api called?
Precompiled smart contract
Problem: With current go-ethereum evm implementation, precompiled contract implementation can't access the caller's address.
Passing the message by emit a specific log, transaction post processing logic could recognize the log and do the action.
func post_processing(tx) {
for log in tx.logs {
if log.type == CosmosNativeMint {
recipient, amount = abi_decode(log.data)
mint(log.address, recipient, amount)
}
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Context
The cosmos native token ecosystem and EVM ecosystem are disconnected currently, connect these two can make many user cases possible:
Scenario 1
Wrap an existing native token in an erc20 contract
Module Managed ERC20 Contract
ERC20 contract that is managed by native module:
Contract code is builtin and deployed by native module
Permissions of mint/burn are granted to the native module only, like this:
Security: normal clients can't sign transaction with the private key corresponds to the
native_module_address
, only native module can execute transactions with that sender address.With this, native module can deploy and manage erc20 tokens.
Wrap native token in EVM
The native module provide three types of message:
deploy(denom)
, native module deploy a standard erc20 contract for the native token, and record the relationship between the native token and the contract address.deposit(denom, amount)
, user locks some native tokens to the module account, and the module mint equivalent erc20 tokens in the contract.withdraw(denom, amount)
, the native module burns user's erc20 tokens in the contract, and release equivalent native tokens from module account to user.Scenario 2
Move existing erc20 token to native token.
We can provide an api to evm smart contract to mint/burn native tokens of bank module.
How to ensure ownership?
evm/contract_address
, and the contract can only manage native tokens with it's own address.How is the api called?
Precompiled smart contract
Passing the message by emit a specific log, transaction post processing logic could recognize the log and do the action.
The
mint
API could be like this:Beta Was this translation helpful? Give feedback.
All reactions