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

Binance ID and TRON address automatic conversion #132

Open
KevinShen1124 opened this issue Jun 5, 2024 · 1 comment
Open

Binance ID and TRON address automatic conversion #132

KevinShen1124 opened this issue Jun 5, 2024 · 1 comment

Comments

@KevinShen1124
Copy link

Using this method, entering the Binance ID when executing a transaction will automatically convert it into a TRON address.

org.tron.trident.abi.datatypes.Function transfer = new org.tron.trident.abi.datatypes.Function(
						"transfer",
						Arrays.asList(new Address(toAddress), new Uint256(BigInteger.valueOf(
								(realAmount.multiply(BigDecimal.valueOf(10L).pow(trc20Contract.decimals().intValue())))
										.longValue())
								.multiply(BigInteger.valueOf(10L).pow(0)))),
						Arrays.asList(new org.tron.trident.abi.TypeReference<Bool>() {
						}));
				TransactionBuilder builder = apiWrapper.triggerCall(
						Base58Check.bytesToBase58(ApiWrapper.parseAddress(fromAddress).toByteArray()),
						Base58Check.bytesToBase58(ApiWrapper.parseAddress(contract.getAddress()).toByteArray()),
						transfer);

When I enter all other random numbers, the response is unknown address. Only the Binance ID will be automatically converted into a TRON address.
It is recommended to adjust the package to include Binance ID in unknown addresses instead of automatically converting addresses.
It was sent to an unknown address, can I get it back?

@endiaoekoe
Copy link
Contributor

endiaoekoe commented Jun 6, 2024

Using this method, entering the Binance ID when executing a transaction will automatically convert it into a TRON address.

org.tron.trident.abi.datatypes.Function transfer = new org.tron.trident.abi.datatypes.Function(
						"transfer",
						Arrays.asList(new Address(toAddress), new Uint256(BigInteger.valueOf(
								(realAmount.multiply(BigDecimal.valueOf(10L).pow(trc20Contract.decimals().intValue())))
										.longValue())
								.multiply(BigInteger.valueOf(10L).pow(0)))),
						Arrays.asList(new org.tron.trident.abi.TypeReference<Bool>() {
						}));
				TransactionBuilder builder = apiWrapper.triggerCall(
						Base58Check.bytesToBase58(ApiWrapper.parseAddress(fromAddress).toByteArray()),
						Base58Check.bytesToBase58(ApiWrapper.parseAddress(contract.getAddress()).toByteArray()),
						transfer);

When I enter all other random numbers, the response is unknown address. Only the Binance ID will be automatically converted into a TRON address. It is recommended to adjust the package to include Binance ID in unknown addresses instead of automatically converting addresses. It was sent to an unknown address, can I get it back?

hi, @KevinShen1124
I think you may have two questions from your description above.
1.first one is when you entered a Binance ID(a number),trident SDK will convert it to a tron address,but when you entered a random number it will be convert to an unknown address.
I just check the source code of the method 'new Address(toAddress)',you can see the code will go to the else part when you enter a number(binance id or other random number),also the convert mechanism is compatible with ETH address format.

public Address(String value) {
        if (value.startsWith("T")) {
            byte[] rawValue = Base58Check.base58ToBytes(value);
            this.value = new Uint(DEFAULT_LENGTH, Numeric.toBigInt(Arrays.copyOfRange(rawValue, 1, 21)));
        } else if (value.startsWith("41")) {
            this.value = new Uint(DEFAULT_LENGTH, Numeric.toBigInt(value.substring(2)));
        } else {
            // ETH compatible
            this.value = new Uint(DEFAULT_LENGTH, Numeric.toBigInt(value));
        }
    }
  1. If it was sent to an unknown address, can I get it back?
    as far as I know,if you transfer assets to an unknown address to which you don't have a private key of the address, you can't not get the asset back

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

No branches or pull requests

2 participants