File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change 99
1010public class CreateTokenDemo {
1111 public static void main (String [] args ) throws Exception {
12- // load your operator credentials
13- AccountId operatorId = AccountId .fromString (System .getenv ("OPERATOR_ID" ));
14- PrivateKey operatorKey = PrivateKey .fromString (System .getenv ("OPERATOR_KEY" ));
12+ // .env-provided
13+ String operatorId = System .getenv ("OPERATOR_ID" );
14+ String operatorKey = System .getenv ("OPERATOR_KEY" );
15+ String network = System .getenv ().getOrDefault ("HEDERA_NETWORK" , "local" ); // "local" for Solo
16+ String mirrorNodeUrl = System .getenv ().getOrDefault (
17+ "MIRROR_NODE_URL" ,
18+ "http://localhost:5551/api/v1" // Solo default (adjust if yours differs)
19+ );
1520
16- // initialize the client for testnet
17- Client client = Client .forTestnet ().setOperator (operatorId , operatorKey );
21+ if (operatorId == null || operatorKey == null ) {
22+ throw new IllegalStateException ("OPERATOR_ID / OPERATOR_KEY not set" );
23+ }
24+
25+ Client client =
26+ "local" .equalsIgnoreCase (network )
27+ ? Client .forNetwork (java .util .Map .of ("127.0.0.1:50211" , new AccountId (3 ))) // Solo default node + node account (adjust if needed)
28+ : Client .forTestnet ();
29+
30+ client .setOperator (AccountId .fromString (operatorId ), PrivateKey .fromString (operatorKey ));
1831
1932 // generate token keys
2033 PrivateKey supplyKey = PrivateKey .generateECDSA ();
You can’t perform that action at this time.
0 commit comments