Skip to content

fix: return 400 for client-side errors for send-signed-transaction #892

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

Conversation

arcoraven
Copy link
Contributor

@arcoraven arcoraven commented May 17, 2025

Changes

  • Improved error handling in the sendSignedTransaction endpoint to better handle client-side errors
  • Added specific handling for insufficient funds errors, returning a 400 status code with a clearer error message
  • Imported necessary utilities from the error handling module

How this PR will be tested

  • Send a signed transaction with insufficient funds. Result: Should receive a 400 status code with a "CLIENT_RPC_ERROR" error type and a clear error message.
  • Send a valid signed transaction. Result: Should receive a 200 status code with the transaction hash in the response.
  • Send a transaction that fails for a non-client reason. Result: Should receive the appropriate error status code.

Output

curl -X POST /transaction/blockchain/send-signed-tx \
  -H "Content-Type: application/json" \
  -d '{"signedTransaction": "0x...", "chainId": 1}' \
  -v

For insufficient funds:

HTTP/1.1 400 Bad Request
{
  "error": "CLIENT_RPC_ERROR",
  "message": "Insufficient funds for gas * price + value"
}

PR-Codex overview

This PR enhances the send-signed-tx.ts file by adding error handling for insufficient funds when sending a signed transaction. It introduces a new error handling mechanism that returns a 400 status code for client errors.

Detailed summary

  • Added Hex type import from thirdweb.
  • Introduced isInsufficientFundsError and prettifyError imports for error handling.
  • Wrapped the eth_sendRawTransaction call in a try-catch block.
  • Implemented custom error handling for insufficient funds, returning a 400 status code.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

zeet-co bot commented May 17, 2025

We're building your pull request over on Zeet.
Click me for more info about your build and deployment.
Once built, this branch can be tested at: https://tw-unreal-demo-engine-vwn0-05-17--a95059.engine-aws-usw2.zeet.app before merging 😉

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arcoraven arcoraven marked this pull request as ready for review May 17, 2025 00:26
@arcoraven arcoraven force-pushed the 05-17-fix_return_400_for_client-side_errors_for_send-signed-transaction branch from 3214c83 to b08eec3 Compare May 17, 2025 01:02
@arcoraven arcoraven merged commit 3a5dce9 into main May 17, 2025
5 of 7 checks passed
@arcoraven arcoraven deleted the 05-17-fix_return_400_for_client-side_errors_for_send-signed-transaction branch May 17, 2025 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant