@@ -20,7 +20,7 @@ A community developed Java SDK to interact with the Æternity blockchain.
2020
2121## Latest stable release
2222
23- - [ v1.0.1 ] ( https://github.com/kryptokrauts/aepp-sdk-java/releases/tag/v1.0.1 )
23+ - [ v1.0.2 ] ( https://github.com/kryptokrauts/aepp-sdk-java/releases/tag/v1.0.2 )
2424
2525### Download
2626
@@ -40,7 +40,7 @@ A community developed Java SDK to interact with the Æternity blockchain.
4040<dependency >
4141 <groupId >com.kryptokrauts</groupId >
4242 <artifactId >aepp-sdk-java</artifactId >
43- <version >1.0.1 </version >
43+ <version >1.0.2 </version >
4444</dependency >
4545...
4646```
@@ -52,7 +52,7 @@ repositories {
5252 jcenter()
5353}
5454
55- compile "com.kryptokrauts:aepp-sdk-java:1.0.1 "
55+ compile "com.kryptokrauts:aepp-sdk-java:1.0.2 "
5656```
5757
5858### Snapshots
@@ -68,6 +68,10 @@ Here's the [list of snapshot versions](https://oss.jfrog.org/webapp/#/artifacts/
6868``` xml
6969...
7070<repositories >
71+ <repository >
72+ <id >jcenter</id >
73+ <url >https://jcenter.bintray.com/</url >
74+ </repository >
7175 <repository >
7276 <id >oss-snapshot-local</id >
7377 <url >https://oss.jfrog.org/artifactory/oss-snapshot-local</url >
@@ -78,7 +82,7 @@ Here's the [list of snapshot versions](https://oss.jfrog.org/webapp/#/artifacts/
7882 <dependency >
7983 <groupId >com.kryptokrauts</groupId >
8084 <artifactId >aepp-sdk-java</artifactId >
81- <version >1.0.2 -SNAPSHOT</version >
85+ <version >1.0.3 -SNAPSHOT</version >
8286 </dependency >
8387</dependencies >
8488...
@@ -87,24 +91,73 @@ Here's the [list of snapshot versions](https://oss.jfrog.org/webapp/#/artifacts/
8791#### Gradle
8892``` groovy
8993repositories {
94+ jcenter()
9095 maven { url "https://oss.jfrog.org/artifactory/oss-snapshot-local" }
9196}
9297
93- compile "com.kryptokrauts:aepp-sdk-java:1.0.2 -SNAPSHOT"
98+ compile "com.kryptokrauts:aepp-sdk-java:1.0.3 -SNAPSHOT"
9499```
95100
96101## Documentation
97102
98- The services of the SDK can be accessed using the factory pattern. Every service has its own factory which allows to get the service either with default config (` ae_devnet ` using ` https://sdk-testnet.aepps.com/v2 ` ) or using a XServiceConfiguration builder pattern configuration object:
103+ The services of the SDK can be accessed using the factory pattern. Every service has its own factory which allows to get the service either with default config (` ae_uat ` using ` https://sdk-testnet.aepps.com/v2 ` ) or using a XServiceConfiguration builder pattern configuration object:
99104
100105``` java
101106new ChainServiceFactory (). getService(); // get default configured service
102107
103108new TransactionServiceFactory (). getService( TransactionServiceConfiguration . configure(). baseUrl( " http://localhost/v2" ). compile() ); // set the baseUrl to localhost
104109```
105110
111+ ### Example code to generate and post a transaction
112+ ``` java
113+ // secret needed to recover KeyPair and sign tx
114+ final String testSecret = " <your_private_key>" ;
115+
116+ // the KeyPairService doesn't need specific configuration parameters
117+ final KeyPairService keyPairService = new KeyPairServiceFactory (). getService();
118+ BaseKeyPair keyPair = keyPairService. generateBaseKeyPairFromSecret(testSecret);
119+
120+ final String baseUrl = " https://sdk-testnet.aepps.com/v2" ; // default: https://sdk-testnet.aepps.com/v2
121+ final Network testnet = Network . TESTNET ; // default: TESTNET -> ae_uat
122+
123+ // get services with required configuration
124+ // you can also call getService() which will load the default settings (see above)
125+ ServiceConfiguration serviceConf = ServiceConfiguration . configure(). baseUrl(baseUrl). compile();
126+ final AccountService accountService = new AccountServiceFactory (). getService(serviceConf);
127+ final ChainService chainService = new ChainServiceFactory (). getService(serviceConf);
128+ // the TransactionService needs to know the network because the signature of tx is handled differently
129+ final TransactionService transactionService = new TransactionServiceFactory (). getService(TransactionServiceConfiguration . configure(). baseUrl(baseUrl). network(testnet). compile());
130+
131+ final String toAddress = " <recipient_address>" ;
132+
133+ // get block to determine current height for calculation of TTL
134+ KeyBlock block = chainService. getCurrentKeyBlock(). blockingGet();
135+ // get the current account to determine nonce which has to be increased
136+ Account account = accountService. getAccount( keyPair. getPublicKey() ). blockingGet();
137+
138+ // amount to send (we need utils to calculate æternity units
139+ BigInteger amount = BigInteger . valueOf( 1 );
140+ // some payload included within tx
141+ String payload = " works =)" ;
142+ // we need to provide a way to determine optimal fee
143+ BigInteger fee = BigInteger . valueOf( BaseConstants . DEFAULT_FEE );
144+ // tx will be valid for the next ten blocks
145+ BigInteger ttl = block. getHeight(). add(BigInteger . TEN );
146+ // we need to increase the current account nonce by one
147+ BigInteger nonce = account. getNonce(). add( BigInteger . ONE );
148+
149+ // create the tx
150+ UnsignedTx unsignedTxNative = transactionService. createSpendTx( keyPair. getPublicKey(), toAddress, amount, payload, fee, ttl, nonce ). blockingGet();
151+ // sign the tx
152+ Tx signedTx = transactionService. signTransaction( unsignedTxNative, keyPair. getPrivateKey() );
153+
154+ // hopefully you receive a successful txResponse
155+ PostTxResponse txResponse = transactionService. postTransaction( signedTx ). blockingGet();
156+ ```
157+
106158## Release notes
107159
160+ - [ v1.0.2] ( docs/release-notes/RELEASE-NOTES-1.0.2.md )
108161- [ v1.0.1] ( docs/release-notes/RELEASE-NOTES-1.0.1.md )
109162- [ v1.0.0] ( docs/release-notes/RELEASE-NOTES-1.0.0.md )
110163
0 commit comments