-
Notifications
You must be signed in to change notification settings - Fork 102
feat(precompiles): erc20 factory precompile #405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(precompiles): erc20 factory precompile #405
Conversation
Hey @GuillemGarciaDev looks like we have some solidity tests failing from these changes |
# Conflicts: # local_node.sh # precompiles/common/interfaces.go
Fixes applied! They should pass now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, looks great! I do have a couple nits and comments, though. After you look at those, we should be good to finally merge :)
…precompile # Conflicts: # tests/solidity/init-node.sh
@vladjdk All comments addressed! |
@GuillemGarciaDev, yes, please add an entry into unreleased! |
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! @GuillemGarciaDev feel free to merge after the conflict is resolved. Thank you again for your work!
…precompile # Conflicts: # CHANGELOG.md
…nto feat/erc20-factory-precompile # Conflicts: # CHANGELOG.md
Thanks @vladjdk ! I do not have permissions though, already fixed the comments. A pleasure! |
Description
This PR implements event emission functionality for the ERC20 Factory precompile and fixes critical issues with event topic handling.
ERC20 Factory Precompile Overview
The ERC20 Factory precompile is a precompile deployed at address
0x0000000000000000000000000000000000000900
that enables deterministic creation of ERC20 token pairs. It provides a factory pattern for deploying ERC20 tokens with predictable addresses.Core Functionality
The precompile bridges Ethereum-style ERC20 tokens with Cosmos SDK's bank module, automatically:
Available Methods
1.
create(uint8 tokenPairType, bytes32 salt, string name, string symbol, uint8 decimals) → address
Transaction Method | Gas Cost: 3,000,000
Creates a new ERC20 token pair and returns the deployed contract address.
Parameters:
tokenPairType
: Type identifier for the token pair (uint8)salt
: 32-byte salt for deterministic address generationname
: Token name (3-128 characters)symbol
: Token symbol (3-16 characters)decimals
: Number of decimal places (uint8)Process:
Create
event2.
calculateAddress(uint8 tokenPairType, bytes32 salt) → address
View Method | Gas Cost: 3,000
Calculates the deterministic address where a token would be deployed without actually creating it.
Parameters:
tokenPairType
: Type identifier for the token pairsalt
: 32-byte salt for address calculationReturns: The calculated contract address using CREATE2 formula
Events Emitted
Create(address indexed tokenAddress, uint8 tokenPairType, bytes32 salt, string name, string symbol, uint8 decimals)
Emitted when a new ERC20 token pair is successfully created.
Indexed Parameters:
tokenAddress
: Address of the deployed token contractNon-Indexed Parameters:
tokenPairType
: Type identifier used during creationsalt
: Salt value used for deterministic deploymentname
: Token namesymbol
: Token symboldecimals
: Decimal precisionIntegration with Cosmos SDK
The precompile seamlessly integrates with multiple Cosmos SDK modules:
Critical Files to Review
precompiles/erc20factory/events.go
- Core event emission logicprecompiles/erc20factory/types.go
- Event struct definitionsprecompiles/erc20factory/tx.go
- Integration with Create methodtests/integration/precompiles/erc20factory/test_events.go
- Go test coveragetests/solidity/suites/precompiles/test/erc20factory.js
- JavaScript test coverageCloses: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
main
branchReviewers Checklist
All items are required.
Please add a note if the item is not applicable
and please add your handle next to the items reviewed
if you only reviewed selected items.
I have...
Unreleased
section inCHANGELOG.md