Creating Transaction
Creating Templates Transaction Messages/Data
Using a Simple Flag:
--generate-only
Transaction templates form the foundation of blockchain development and automation in ENI. With the --generate-only
flag and Foundry's cast
tool, developers can create, analyze, and debug transactions in both native Cosmos and EVM environments. Understanding these tools unlocks powerful possibilities for building complex applications and development workflows.
Native Transaction Templates
The --generate-only
flag transforms any ENI CLI transaction command into a template generator, creating a complete transaction structure without broadcasting it. These templates serve as building blocks for applications, frontends, and automation tools.
Basic Usage Pattern
The general pattern follows this structure:
For example, a token transfer template:
EVM Transaction Analysis
ENI's EVM compatibility introduces additional complexity when handling transactions. Let’s explore how to generate and analyze EVM transactions using ENI’s native tools and Foundry’s cast
command.
Generating an EVM Transaction Template
To generate an EVM transaction template, use the evm
module with --generate-only
. Here’s an example of registering an EVM pointer:
This command returns a transaction hash, which you can further analyze using Foundry’s cast
tool.
Analyzing an EVM Transaction with Cast
Once you have the transaction hash, you can use Foundry’s cast
command to inspect transaction details:
This provides detailed transaction information:
Understanding EVM Transaction Components
Let’s break down the key components of an EVM transaction:
input
: Encoded function call datamaxFeePerGas
: Maximum total fee per unit of gasmaxPriorityFeePerGas
: Maximum priority fee per unit of gasgasLimit
: Maximum gas allowed for the transactionto
: Target contract addresstype
: Transaction type (2 indicates an EIP-1559 transaction)
Practical Applications
Development Workflow
When developing applications that interact with native and EVM functionality:
Template Generation for Different Transaction Types
Generate templates for various transaction types:
Best Practices
Transaction Analysis
When analyzing transactions:
Always validate both the native and EVM aspects of a transaction
Use
cast
to decode input data when dealing with EVM transactionsTrack gas parameters on both layers
Monitor transaction status on both the native and EVM layers
Error Handling
Handle potential issues on both layers:
Security
Keep private keys secure and never include them in templates
Use
.env
files or other environment variables whenever possible when dealing with hardcoded wallet keys or mnemonics
Last updated