OKRW Precompile
Mint the native KRW-pegged stablecoin (OKRW) directly from your smart contracts.
The OKRW Precompile is a specialized, gas-efficient contract at a fixed address that exposes the core minting functionality of Maroo's native x/okrw module to the EVM. This allows developers to programmatically create new OKRW tokens, a crucial function for regulated financial applications, decentralized exchanges, and other protocols that need to manage stablecoin liquidity. The precompile enforces strict access control, ensuring only a designated minter account can create new tokens.
Key Features
EVM-Native Minting
Call a `mint` function from Solidity just like any other contract call, without needing complex cross-module communication.
Strict Access Control
Only the globally configured 'Minter Address' can successfully execute a mint, preventing unauthorized token creation.
Custom Error Reporting
Failed calls revert with detailed, custom Solidity errors (e.g., `UnauthorizedMinter`), allowing for robust off-chain and on-chain error handling.
Standard Event Emission
Emits a standard EVM `Mint` event, making it easy for indexers, block explorers, and dApps to track minting activity.
Architecture
graph TD
subgraph EVM Environment
A[Your Smart Contract] -->|calls IOkrw.mint(...)| B{OKRW Precompile<br>0x100...0001}
end
subgraph Cosmos SDK
D[x/okrw Module] -->|updates balances| E[x/bank Module]
end
B -->|constructs & dispatches MsgMint| C(Maroo Message Router)
C -->|routes message| D Architectural flow of a call to the OKRW precompile. An EVM call is translated into a native Cosmos SDK message, processed by the `x/okrw` module, and results in a state change in the `x/bank` module.
How It Works
mint function on the precompile's fixed address (0x100...0001), the Maroo node intercepts the call before it reaches the EVM. The precompile's Go implementation takes over, decoding the function arguments (recipient and amount).The core logic then performs several crucial steps. First, it validates the inputs. Second, it retrieves the globally configured
MinterAddress from the x/okrw module's parameters. It compares this address with contract.Caller(), which represents the direct caller of the precompile. If they do not match, the transaction is reverted. If they do match, the precompile constructs a native Cosmos SDK MsgMint. This message is then dispatched through Maroo's internal message router to the x/okrw module, which executes the final minting logic and updates the recipient's balance in the core x/bank module.Error and Event Handling
x/okrw module returns an error (e.g., an authorization failure), the precompile's error-handling logic in errors.go packs this into a custom Solidity error revert. This is more gas-efficient and machine-readable than a simple string revert.On a successful mint, the
events.go logic constructs and emits a standard EVM log that matches the Mint event defined in the IOkrw interface. This allows dApp frontends, indexers, and other off-chain services to listen for and react to minting events just as they would with a standard ERC20 token.