Skip to content
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

Add an example for working with revert data from contracts #179

Open
onbjerg opened this issue Feb 13, 2025 · 0 comments · May be fixed by #181
Open

Add an example for working with revert data from contracts #179

onbjerg opened this issue Feb 13, 2025 · 0 comments · May be fixed by #181
Milestone

Comments

@onbjerg
Copy link
Contributor

onbjerg commented Feb 13, 2025

Interacting with contract instances can result in reverts. It would be nice to add an example of how to get the revert data out of alloy::contract::Error, in cases where you want to manually handle the revert data.

Currently, to me this seems a bit cumbersome, but I might be wrong:

match res {
  Err(alloy::contract::Error::TransportError(rpc_err)) => {
    let revert_data = rpc_err.as_error_resp().and_then(|res| res.as_revert_data()); // Option<Bytes>
  },
  _ => unimplemented!()
}
@jenpaff jenpaff added this to Alloy Feb 28, 2025
@github-project-automation github-project-automation bot moved this to Todo in Alloy Feb 28, 2025
@jenpaff jenpaff moved this from Todo to Reviewed in Alloy Feb 28, 2025
@jenpaff jenpaff added this to the v1.0 milestone Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Reviewed
Development

Successfully merging a pull request may close this issue.

2 participants