Skip to content

Conversation

shiyasmohd
Copy link
Contributor

Solution

Implemented cast abi-encode-event command that encodes event signatures & args into topics and data.

Example Usage

cast abi-encode-event "Transfer(address indexed from, address indexed to, uint256 value)" 0x1234567890123456789012345678901234567890 0xabcdefabcdefabcdefabcdefabcdefabcdefabcd 1000

Output

[topic0]: 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
[topic1]: 0x0000000000000000000000001234567890123456789012345678901234567890
[topic2]: 0x000000000000000000000000abcdefabcdefabcdefabcdefabcdefabcdefabcd
[data]: 0x00000000000000000000000000000000000000000000000000000000000003e8

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Closes #10905

Copy link
Collaborator

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thanks for this PR, sorry for the delay; I've left a review with some suggestions.

@shiyasmohd shiyasmohd force-pushed the shiyasmohd/event-encode branch from 6911e03 to ca9a558 Compare September 2, 2025 07:07
@shiyasmohd shiyasmohd force-pushed the shiyasmohd/event-encode branch from ca9a558 to 44e4180 Compare September 2, 2025 07:45
@shiyasmohd shiyasmohd force-pushed the shiyasmohd/event-encode branch from 44e4180 to 39fed42 Compare September 2, 2025 07:47
@shiyasmohd
Copy link
Contributor Author

@onbjerg Thanks for the review! Pushed the changes. But CI is failing due to another reason?

@shiyasmohd
Copy link
Contributor Author

@onbjerg following up

@onbjerg
Copy link
Collaborator

onbjerg commented Sep 15, 2025

Hi, apologies for dropping the ball here. Will retrigger CI, since it was flaky last week, and then go from there.

/// );
/// # Ok::<_, eyre::Report>(())
/// ```
pub fn abi_encode_event(sig: &str, args: &[impl AsRef<str>]) -> Result<(Vec<B256>, Vec<u8>)> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we return a LogData struct here instead to of a tuple? https://docs.rs/alloy/latest/alloy/primitives/struct.LogData.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

feat(cast abi-encode-event): add support for event encoding to get topics and data
2 participants