tronprotocol / tronprotocol/java-tron

NullPointerException when calling triggerconstantcontract with blacklisted address

Open
#6,523 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: next-release topic:api type:bug
Dominant language
Java
Stars
4.2k
Forks
1.7k
Avg merge
6d 20h
Merged PRs (30d)
14

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the POST /wallet/triggerconstantcontract request for isBlackListed(address) on the supplied blacklisted address, then trace the Java implementation of constant-contract execution and response handling. Compare it with a non-blacklisted call. Done means the endpoint returns a boolean constant_result without a NullPointerException and regression coverage exists for the blacklisted case.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, blockchain
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.