Skip to content

NullPointerException when calling triggerconstantcontract with blacklisted address #6523

Open

Description

@csc-EricWu

Issue Description

When calling the triggerconstantcontract endpoint to check if a TRON address is blacklisted using the isBlackListed(address) function, a NullPointerException is thrown when the address is actually blacklisted.

Environment

  • TRON Network: Mainnet
  • API Endpoint: https://tron-mainnet.gateway.tatum.io/wallet/triggerconstantcontract
  • Contract Address: TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t (USDT TRC-20)
  • Function: isBlackListed(address)

Steps to Reproduce

  1. Call the triggerconstantcontract endpoint with the following payload:
{
  "owner_address": "TKgD8Qnx9Zw3RNjdiU2i5y2Swa2y4QvG6v",
  "contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
  "function_selector": "isBlackListed(address)",
  "parameter": "0000000000000000000000418a8e8b8c8d8e8f9a9b9c9d9e9f0a1b2c3d4e5f6",
  "visible": true
}
  1. The address TKgD8Qnx9Zw3RNjdiU2i5y2Swa2y4QvG6v is confirmed to be blacklisted.

Expected Behavior

The endpoint should return a successful response with the blacklist status in the constant_result field, for example:

{
  "result": {
    "result": true,
    "constant_result": ["0000000000000000000000000000000000000000000000000000000000000001"]
  }
}

Actual Behavior

The endpoint returns an error:

{
  "result": {
    "code": "OTHER_ERROR",
    "message": "class java.lang.NullPointerException : null"
  }
}

Error Details

  • Error Type: java.lang.NullPointerException
  • Error Code: OTHER_ERROR
  • Message: class java.lang.NullPointerException : null

Additional Information

Test Cases

  1. Blacklisted Address (Fails with NullPointerException):

    • Address: TKgD8Qnx9Zw3RNjdiU2i5y2Swa2y4QvG6v
    • Expected: Should return true or 1 in constant_result
    • Actual: Returns NullPointerException
  2. Non-blacklisted Address (May work correctly):

    • Should be tested to confirm if the issue only occurs with blacklisted addresses

Request Details

  • Method: POST
  • URL: /wallet/triggerconstantcontract
  • Content-Type: application/json
  • Parameter Encoding: The address is converted from Base58 to hex format, padded to 64 characters (32 bytes)

Address Conversion

The address TKgD8Qnx9Zw3RNjdiU2i5y2Swa2y4QvG6v is converted as follows:

  1. Base58 to hex: 418a8e8b8c8d8e8f9a9b9c9d9e9f0a1b2c3d4e5f6
  2. Ensure 41 prefix (TRON address prefix)
  3. Pad to 64 hex characters: 0000000000000000000000418a8e8b8c8d8e8f9a9b9c9d9e9f0a1b2c3d4e5f6

Possible Root Cause

The NullPointerException suggests that when processing a blacklisted address, the TRON node may be encountering a null reference when:

  1. Accessing the blacklist mapping
  2. Processing the return value
  3. Encoding the response

This could indicate a bug in the contract execution or response encoding logic when dealing with blacklisted addresses.

Impact

This issue prevents applications from properly checking blacklist status for addresses that are actually blacklisted, which is critical for compliance and security purposes.

Requested Action

Please investigate and fix the NullPointerException that occurs when calling triggerconstantcontract with isBlackListed(address) for blacklisted addresses. The function should return a proper boolean value instead of throwing an exception.

Related Information

  • TRON USDT Contract: TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t
  • Function Signature: isBlackListed(address)
  • Test Address: TKgD8Qnx9Zw3RNjdiU2i5y2Swa2y4QvG6v (confirmed blacklisted)

Activity

  1. Benson0224 commented on Jan 23, 2026

    @Benson0224
    Collaborator

    I took a quick look at the request. It appears the address in your query parameters is invalid; the string length is one character short. Please double-check the address and try again.

  2. waynercheung commented on Jan 23, 2026

    @waynercheung
    Collaborator

    @csc-EricWu
    As @Benson0224 pointed out, TKgD8Qnx9Zw3RNjdiU2i5y2Swa2y4QvG6v is not a valid Base58 address. Please verify it.

  3. yanghang8612 commented on Jan 23, 2026

    @yanghang8612
    Collaborator

    Should we improve the error messages for such interface issues? Currently, these error prompts are extremely unfriendly to users.

  4. yanghang8612 commented on Jan 23, 2026

    @yanghang8612
    Collaborator

    Additionally, your data parameter contains 63 hex characters. Please verify this. Otherwise, even if the owner address is valid, the call will result in a revert.

  5. GordonLtron commented on Jan 23, 2026

    @GordonLtron

    Agree. While the root cause here is malformed input (invalid address length and odd-length hex parameter), throwing a raw NullPointerException is confusing for API users. It implies a node-side failure rather than a client-side request error.

  6. csc-EricWu commented on Jan 23, 2026

    @csc-EricWu
    Author

    Thank you all. Upon confirmation, this is an invalid address.

  7. GrothenDI commented on Jan 23, 2026

    @GrothenDI

    About why TKgD8Qnx9Zw3RNjdiU2i5y2Swa2y4QvG6v is not a valid Tron address:

    Although this address is 34 characters long and starts with T, which aligns with the characteristics of a TRON address, it is in Base58 format but not Base58Check. When converted to hexadecimal format, the address becomes 416A7A4AD43541826EDAFD718826F58BADCEB483B819C12F8B. The last four bytes 19C12F8B are not the correct checksum for the actual address 416A7A4AD43541826EDAFD718826F58BADCEB483B8. The correct checksum should be 054B538A

  8. halibobo1205 commented on Mar 17, 2026

    @halibobo1205
    Collaborator

    The root cause is that the API lacks input validation for the address parameter — when an invalid address is passed, it triggers a bare NullPointerException, which is very unfriendly to API consumers. We suggest adding upfront validation with a clear and descriptive error message in the next release. I'll confirm the implementation approach at the upcoming Core Devs Community Call 58 before we move forward. cc @yanghang8612 @waynercheung

  9. halibobo1205 commented on May 12, 2026

    @halibobo1205
    Collaborator

    Apologies that we did not cover this topic in the Core Devs Community Call 58 as previously planned. The agenda was already full, so this item was not discussed.

    I'd like to add this to Core Devs Community Call 62 for discussion.

    cc @yanghang8612 @waynercheung

  10. waynercheung commented on May 15, 2026

    @waynercheung
    Collaborator

    @halibobo1205 Hi,after the tronprotocol/pm#207, is there any update for this issue?

  11. halibobo1205 commented on May 15, 2026

    @halibobo1205
    Collaborator

    @waynercheung Hi, the Core Devs Community Call 62 hasn't started yet.

  12. halibobo1205 commented on May 20, 2026

    @halibobo1205
    Collaborator

    A consolidated plan ahead of Core Devs Community Call 62.

    Shared root cause

    The NPE in this issue and the CodeQL alert java/error-message-exposure are the same class of problem: HTTP servlets catch Exception and write the raw exception class/message straight back to the client.

    Proposal — split API errors into parameter errors vs. internal errors

    • Parameter errors: validate upfront (address, hex length, etc.) and return a precise, stable message. Today's NPE -> e.g., "invalid address: base58check failed".
    • Internal errors: log the full stack server-side (logger.warn(..., e)); the response carries only a fixed generic message, no e.getClass() / e.getMessage().
    • Centralize: introduce a Util.writeError(response, code, message) helper.
  13. halibobo1205 commented on May 27, 2026

    @halibobo1205
    Collaborator

    Status update: this was discussed in Core Devs Community Call 62, and the consolidated plan above was accepted with no objections.

    Agreed approach:

    • Split API errors into two clear categories:
      • Parameter errors: validate upfront (address base58check, hex length, etc.) and return a precise, stable client-facing message such as "invalid address: base58check failed" — no more raw NullPointerException reaching the client.
      • Internal errors: log the full stack server-side via logger.warn(..., e); the HTTP response carries only a fixed generic message, with no e.getClass() / e.getMessage() leakage.
    • Centralize the response path through a Util.writeError(response, code, message) helper so every servlet goes through the same sanitization point.

    This also resolves the CodeQL java/error-message-exposure alerts, since both share the same root cause.

    Timing: v4.8.2 scope is already locked, so this work will land in a later release. The issue stays open and will be updated once implementation is in flight.

    Thanks @yanghang8612, @waynercheung, and everyone who contributed to the discussion.

  14. halibobo1205 commented on Sep 2, 2026

    @halibobo1205
    Collaborator

    traced by #6936.

  15. removed this from the GreatVoyage-v4.8.3 milestone on Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions