tronprotocol / trident

133 stars 105 forks source link

Use trident for tron private chain #113

Closed TOBEACODER7 closed 3 months ago

TOBEACODER7 commented 8 months ago

Is there any way to use trident for private chain.

//main net, using TronGrid
ApiWrapper wrapper = ApiWrapper.ofMainnet("hex private key", "API key");
//Shasta test net, using TronGrid
ApiWrapper wrapper = ApiWrapper.ofShasta("hex private key");
//Nile test net, using a node from Nile official website
ApiWrapper wrapper = ApiWrapper.ofNile("hex private key");

No match function for tron private chain.

TOBEACODER7 commented 8 months ago

I know the goal of trident is to protect your private key. I can just use trident to sign and use HTTP requests to achieve other goals. But I need to init ApiWrapper, but I don`t know how to achieve this.

endiaoekoe commented 8 months ago

Is there any way to use trident for private chain.

//main net, using TronGrid
ApiWrapper wrapper = ApiWrapper.ofMainnet("hex private key", "API key");
//Shasta test net, using TronGrid
ApiWrapper wrapper = ApiWrapper.ofShasta("hex private key");
//Nile test net, using a node from Nile official website
ApiWrapper wrapper = ApiWrapper.ofNile("hex private key");

No match function for tron private chain.

hi, @TOBEACODER7 if you want to use trident-java in your private chain, just use the constructor function ApiWrapper(String grpcEndpoint, String grpcEndpointSolidity, String hexPrivateKey)in ApiWrapper.java. in this function, the grpcEndpoint param is your private chain's grpcendpoint, which may look like ''xx.xx.xx.xx:50051", and the grpcEndpointSolidity is your private chain's grpcEndpointSolidity , which may look like ‘xx.xx.xx.xx:50061’, and the hexPrivateKey is the private key you pass to. hope this may help.

TOBEACODER7 commented 8 months ago

Thanks for your answer! I`ll try it in my project.

TOBEACODER7 commented 8 months ago

In document

Initialize a ApiWrapper Instance

Before using functions in ApiWrapper, you should bind your private key to an ApiWrapper instance:

ApiWrapper wrapper = new ApiWrapper("grpc endpoint", "solidity grpc endpoint", "hex private key");

Any node can be used here. Alternatively, there are hardcoded initializers for the main net, Shasta and Nile test nets

The grpcEndpoint and solidity grpcEndpoint is the IP and port of any node of your private chain, like"xx.xx.xx.xx:50051/50052". And the setting of port is in your configuration(private_net_config.conf)

rpc {
    port = 50051
    solidityPort= 50052
}

My trouble was successfully solved with this helpful information. Thanks for the useful help.

TOBEACODER7 commented 3 months ago

In document

Initialize a ApiWrapper Instance

Before using functions in ApiWrapper, you should bind your private key to an ApiWrapper instance:

ApiWrapper wrapper = new ApiWrapper("grpc endpoint", "solidity grpc endpoint", "hex private key");

Any node can be used here. Alternatively, there are hardcoded initializers for the main net, Shasta and Nile test nets

The grpcEndpoint and solidity grpcEndpoint is the IP and port of any node of your private chain, like"xx.xx.xx.xx:50051/50052". The setting of port is in your configuration(private_net_config.conf)

rpc {
    port = 50051
    solidityPort= 50052
}

My trouble was successfully solved with this helpful information. Thanks for the useful help.

I want to use trident to sign and broadcast transactions from a normal fullnode instead of a srnode. I try to change the setting of fullnode in :

rpc{
    port = 16669
    SolidityPort = 16670
}

And change the code as :

ApiWrapper wrapper = new ApiWrapper("IP of fullnode:16669", "IP of fullnode:16670", "hex private key");

It will lead to an error:

org.tron.trident.core.exceptions.IllegalException: createTransactionExtention error,CANCELLED: Thread interrupted

I noticed that the doc of trident: Any node can be used here. What should I do to use fullnode to init wrapper of trident?