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

no frozenBalance(Energy) V2 on my own fullNode #6150

Open
Wesley1T opened this issue Jan 19, 2025 · 16 comments
Open

no frozenBalance(Energy) V2 on my own fullNode #6150

Wesley1T opened this issue Jan 19, 2025 · 16 comments

Comments

@Wesley1T
Copy link

i got sucess in frozenv2 api. But when i check in tronscan, it doesnt have my staking info.
anyone know why?

Image

im still getting error when i unfreezeV2
{
"Error": "class org.tron.core.exception.ContractValidateException : no frozenBalance(Energy)"
}

could this be the reason? in my account i only saw stakev1 permission but doesnt have stakev2?

Image

FYI: my fullnode currently is on sync with main net
"number": 68880376 on mainnet and my own setup full node

@angrynurd
Copy link

angrynurd commented Jan 20, 2025

@Wesley1T
API returning "success" only means the transaction was broadcast, not necessarily executed successfully。
you could first copy your tx hash and search it in tronscan to check the TX status (especially the reason why this TX failed).
then you will know how to proceed to the next step.

@tronprotocol tronprotocol deleted a comment Jan 20, 2025
@King31T
Copy link

King31T commented Jan 20, 2025

If you have the owner permission of your account, you can exclude the reason of active permission.

@Sunny6889
Copy link

Sunny6889 commented Jan 20, 2025

@Wesley1T, did you run the API wallet/broadcasttransaction after generating the frozenv2 API? Only after you broadcast your signed transaction will TRON begin to process it.

@Sunny6889
Copy link

@Wesley1T could you please list all the steps and response for this issue? As we may not understand exactly what you do.

@Wesley1T
Copy link
Author

@Wesley1T API returning "success" only means the transaction was broadcast, not necessarily executed successfully。 you could first copy your tx hash and search it in tronscan to check the TX status (especially the reason why this TX failed). then you will know how to proceed to the next step.

@angrynurd
which one are the tx hash?

{ "visible": true, "txID": "c309d1386a9d289eb20ab8dedcc151b4a02db0fa7f12224730ef4f1fb902b711", "raw_data": { "contract": [ { "parameter": { "value": { "resource": "ENERGY", "frozen_balance": 100000000, "owner_address": "XXXXyLwyxjXajeY35hWGv" }, "type_url": "type.googleapis.com/protocol.FreezeBalanceV2Contract" }, "type": "FreezeBalanceV2Contract" } ], "ref_block_bytes": "075f", "ref_block_hash": "b4f1e975a0ad51ca", "expiration": 1737292242000, "timestamp": 1737292184757 }, "raw_data_hex": "0a02075f2208b4f1e975a0ad51ca40d0b8bff5c7325a5a083612560a34747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e467265657a6542616c616e63655632436f6e7472616374121e0a15419f4cb13195234d3044f299ed2c1bd1eb481983101080c2d72f180170b5f9bbf5c732" }

@Wesley1T
Copy link
Author

If you have the owner permission of your account, you can exclude the reason of active permission.

@King31T Can you elaborate more? Is it a setting in account permission? I do not have owner permission but i can ask the owner to do so. This is a test account.

@Wesley1T
Copy link
Author

Wesley1T commented Jan 20, 2025

@Wesley1T, did you run the API wallet/broadcasttransaction after generating the frozenv2 API? Only after you broadcast your signed transaction will TRON begin to process it.

@Sunny6889 No i did not perform boradcasttransaction. Can you please guide me through?
This is the frozenV2 returned:

`{
    "visible": true,
    "txID": "c309d1386a9d289eb20ab8dedcc151b4a02db0fa7f12224730ef4f1fb902b711",
    "raw_data": {
        "contract": [
            {
                "parameter": {
                    "value": {
                        "resource": "ENERGY",
                        "frozen_balance": 100000000,
                        "owner_address": "TQVWKDzuYW4y5G4sQyLwyxjXajeY35hWGv"
                    },
                    "type_url": "type.googleapis.com/protocol.FreezeBalanceV2Contract"
                },
                "type": "FreezeBalanceV2Contract"
            }
        ],
        "ref_block_bytes": "075f",
        "ref_block_hash": "b4f1e975a0ad51ca",
        "expiration": 1737292242000,
        "timestamp": 1737292184757
    },
    "raw_data_hex": "0a02075f2208b4f1e975a0ad51ca40d0b8bff5c7325a5a083612560a34747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e467265657a6542616c616e63655632436f6e7472616374121e0a15419f4cb13195234d3044f299ed2c1bd1eb481983101080c2d72f180170b5f9bbf5c732"
}`
And i tried to broadcast but getting error: (Im not sure the to_address needs to put which address)
{"raw_data":{"contract":[{"parameter":{"value":{"amount":1000,"owner_address":"TQVWKDzuYW4y5G4sQyLwyxjXajeY35hWGv","to_address":"41e9d79cc47518930bc322d9bf7cddd260a0260a8d"},"type_url":"type.googleapis.com/protocol.TransferContract"},"type":"TransferContract"}],"ref_block_bytes":"075f","ref_block_hash":"b4f1e975a0ad51ca","expiration":1737292242000,"timestamp":1737292184757},"raw_data_hex":"0a02075f2208b4f1e975a0ad51ca40d0b8bff5c7325a5a083612560a34747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e467265657a6542616c616e63655632436f6e7472616374121e0a15419f4cb13195234d3044f299ed2c1bd1eb481983101080c2d72f180170b5f9bbf5c732"}

returned :

{
    "code": "CONTRACT_VALIDATE_ERROR",
    "txid": "51be0b0aa125254216d1429c091fed307cef9186798772791ffa7669bed97579",
    "message": "436f6e74726163742076616c6964617465206572726f72203a204e6f20636f6e747261637421"
}

So i got a task to setup tron node to do staking. What i have done so far:

  1. setup a full node running in my aws ec2, synced with mainnet and they are on the same block number
  2. tried to do staking (success)
  3. checked it on tronscan (frozen doesnt seems to went thru) maybe i because i did not perform broadcast transaction or doesnt have stake v2 permission
    4)tried to unfrozen but got error no energy

@angrynurd
Copy link

angrynurd commented Jan 20, 2025

@Wesley1T
it seems like you are not performing the right steps to send a tx ,please refer to this doc for guides.
invoke freezev2 interface just finish the first step(tx creation). you need to sign the tx and broadcast it

A transaction goes through the following stages in its life cycle:

1.Transaction's creation and signature.
2.The transaction is broadcast to the TRON network, it will be included in a transaction cache pool after passing the verification and execution by node(including the block-producing node).
3.The block-producing node takes out transaction one by one from the transaction cache pool in the order in which they were put in, packages them into a new block, and then broadcasts the new block to the TRON network.
4.The transaction will be "confirmed". Whether a transaction is confirmed depends on whether the block in which the transaction is included is confirmed. TRON's block confirmation mechanism is that after a block is produced, 19 different super nodes produce subsequent blocks based on this block, then the block is confirmed.

@Wesley1T
Copy link
Author

Wesley1T commented Jan 20, 2025

@angrynurd It seems that i will need to write my own script to provide sign and broadcast for the operation team.
Do you know if there is any python library to do this?
Is this supported well and i can adopt this library?
https://github.com/iexbase/tron-api-python/tree/master/tronapi


from tronapi import Tron
from tronapi.exceptions import TronError

# TRON full node and solidity node URLs
FULL_NODE = 'https://api.trongrid.io'
SOLIDITY_NODE = 'https://api.trongrid.io'
EVENT_SERVER = 'https://api.trongrid.io'

# Replace this with your private key
PRIVATE_KEY = 'your-private-key-here'

# Initialize Tron
tron = Tron(
    full_node=FULL_NODE,
    solidity_node=SOLIDITY_NODE,
    event_server=EVENT_SERVER
)
tron.private_key = PRIVATE_KEY
tron.default_address = tron.address.from_private_key(PRIVATE_KEY)

def sign_and_broadcast(raw_data_hex):
    try:
        # Sign the transaction
        signed_tx = tron.trx.sign(
            {'raw_data_hex': raw_data_hex}
        )
        print("Signed Transaction:", signed_tx)

        # Broadcast the transaction
        broadcast_result = tron.trx.broadcast(signed_tx)
        print("Broadcast Result:", broadcast_result)

        # Return the transaction ID for verification
        if 'txid' in broadcast_result:
            print(f"Transaction ID: {broadcast_result['txid']}")
            return broadcast_result['txid']
        else:
            print("Broadcast failed:", broadcast_result)
            return None
    except TronError as e:
        print(f"An error occurred: {str(e)}")
        return None

if __name__ == "__main__":
    # Replace this with the `raw_data_hex` from your transaction
    raw_data_hex = "0a02075f2208b4f1e975a0ad51ca40d0b8bff5c7325a5a083612560a34747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e467265657a6542616c616e63655632436f6e7472616374121e0a15419f4cb13195234d3044f299ed2c1bd1eb481983101080c2d72f180170b5f9bbf5c732"  # Replace with your raw_data_hex

    txid = sign_and_broadcast(raw_data_hex)
    if txid:
        print(f"Transaction successfully broadcasted. TXID: {txid}")
    else:
        print("Failed to broadcast the transaction.")

@angrynurd
Copy link

angrynurd commented Jan 20, 2025

Do you know if there is any python library to do this?
Is this supported well and i can adopt this library?
https://github.com/iexbase/tron-api-python/tree/master/tronapi

@Wesley1T
The project you mentioned above has not been developed/maintained for 5 years, I am not sure if it can work well(it may not support stake 2.0 APIs)
As far as I know, there are some python lib SDK of tron, but they are mostly not maintained.
Currently, the Tron SDK which is actively upgraded includes tronweb(js version) and trident(java version)

@Sunny6889
Copy link

Hi @Wesley1T For easily do signature, please use wallet-cli. Import your private key there, then it will do signature for you. Refer wallet-cli. Make sure you edit config.conf in src/main/resources as below:

fullnode = {
  ip.list = [
    "localhost:50051" 
  ]
}

@Sunny6889
Copy link

By the way, here is my example of Java code for broadcastTrans. The wallet-cli is actually written in a similar way.

@King31T
Copy link

King31T commented Jan 21, 2025

If you have the owner permission of your account, you can exclude the reason of active permission.

@King31T Can you elaborate more? Is it a setting in account permission? I do not have owner permission but i can ask the owner to do so. This is a test account.

According to the following replies, before considering the permission issues, firstly try to sign and broadcast the transaction correctly.

@Wesley1T
Copy link
Author

Hi @Wesley1T For easily do signature, please use wallet-cli. Import your private key there, then it will do signature for you. Refer wallet-cli. Make sure you edit config.conf in src/main/resources as below:

fullnode = {
  ip.list = [
    "localhost:50051" 
  ]
}

@Sunny6889 So when i include this in my config.conf with localhost:50051 and launch java -jar wallet-cli.jar it will do the signature on the transaction i created using frozenV2 api?
Can you share the step to perform staking after i run the wallet cli? Do i still need to broadcast manually?

@Wesley1T
Copy link
Author

By the way, here is my example of Java code for broadcastTrans. The wallet-cli is actually written in a similar way.

Do you recommend me using the java you written or just use the existing broadcast API from the fullNode?
And can you provide the guide to do broadcast using the java you written?

@Sunny6889
Copy link

@Wesley1T I would recommend you just use wallet-cli. So you just need send freezebalancev2 request use wallet-cli, it will do signature for you and broadcast the transaction to TRON. Please read through the introduction here, then import your wallet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
@angrynurd @Sunny6889 @Wesley1T @King31T and others