Documentation Index
Fetch the complete documentation index at: https://injectivelabs-mintlify-jp-developers-first-half-1777019423.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Hooks
Thex/evm module implements an EvmHooks interface that extend and customize the Tx processing logic externally.
This supports EVM contracts to call native cosmos modules by
- defining a log signature and emitting the specific log from the smart contract,
- recognizing those logs in the native tx processing code, and
- converting them to native module calls.
PostTxProcessing hook that registers custom Tx hooks in the EvmKeeper. These Tx hooks are processed after the EVM state transition is finalized and doesn’t fail. Note that there are no default hooks implemented in the EVM module.
PostTxProcessing
PostTxProcessing is only called after a EVM transaction finished successfully and delegates the call to underlying hooks. If no hook has been registered, this function returns with a nil error.
nil instead.
The error returned by the hooks is translated to a VM error failed to process native logs, the detailed error message is stored in the return value. The message is sent to native modules asynchronously, there’s no way for the caller to catch and recover the error.
Use Case: Call Native ERC20 Module on Injective
Here is an example taken from the Injective erc20 module that shows how theEVMHooks supports a contract calling a native module to convert ERC-20 Tokens into Cosmos native Coins. Following the steps from above.
You can define and emit a Transfer log signature in the smart contract like this:
BankSendHook to the EvmKeeper. It recognizes the ethereum tx Log and converts it to a call to the bank module’s SendCoinsFromAccountToAccount method:
app.go:
