Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/signum-network/signumj
SignumJ - Java Development Framework
https://github.com/signum-network/signumj
bitcoin blockchain burstcoin ethereum java jdk signum transaction
Last synced: 2 months ago
JSON representation
SignumJ - Java Development Framework
- Host: GitHub
- URL: https://github.com/signum-network/signumj
- Owner: signum-network
- License: apache-2.0
- Created: 2018-09-27T15:07:32.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-29T21:20:05.000Z (6 months ago)
- Last Synced: 2024-09-30T13:42:13.231Z (3 months ago)
- Topics: bitcoin, blockchain, burstcoin, ethereum, java, jdk, signum, transaction
- Language: Java
- Homepage: https://signum.network/
- Size: 3.18 MB
- Stars: 29
- Watchers: 5
- Forks: 19
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# SignumJ
[![GPLv3](https://img.shields.io/badge/license-GPLv3-blue.svg)](LICENSE)
[![](https://jitpack.io/v/signum-network/signumj.svg)](https://jitpack.io/#signum-network/signumj)Signum Java Development Framework
## Including in your project
* Maven:
```xml
jitpack.io
https://jitpack.io
com.github.signum-network
signumj
v1.3.1
```
* Gradle:
```gradle
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.signum-network:signumj:v1.3.1'
}
```## Usage
* Commonly used Signum objects / entities / helper classes can be found in the [entity](src/main/java/signumj/entity) package.
* For locally-performed cryptographic operations such as encrypting/decrypting, signing/verifying, etc please see the [SignumCrypto](src/main/java/signumj/crypto/SignumCrypto.java) interface (Use `SignumCrypto.getInstance()` to obtain a singleton instance)
* For Singum Node API calls such as making transactions and looking at blocks/accounts/transactions, please see the [NodeService](src/main/java/signumj/service/NodeService.java) interface. (Use `NodeService.getInstance("http://nodeAddress.com:8125")` to obtain an instance.)
The `NodeService` wraps the returned values in RxJava Singles. You can create your own `SchedulerAssigner` to automatically make all returned values subscribe on the specified schedulers. If you don't want to use RxJava, call `toFuture()` on any Single.
GSON is used for JSON serialization/deserialization. To obtain a `GsonBuilder` customized to serialize/deserialize the entities, call `SignumUtils.buildGson()`.
### SignumJ badge
If you use SignumJ on your project, please consider using one the badges available on the [style guide](https://signum.network/styleguide.html).
## Examples
Please see the [examples folder](src/test/java/signumj/examples).
Bellow a simple example on how to send a transaction and sign it locally.```java
import signumj.Constants;
import signumj.crypto.SignumCrypto;
import signumj.entity.SignumAddress;
import signumj.entity.SignumValue;
import signumj.service.NodeService;/**
* Example which sends 1 SIGNA to another account with a fee of 0.1 SIGNA.
*
* Performs the cryptographic signature locally so does not send the passphrase
* to over the wire.
*
*/
public class SendTransactionBlockingGet {public static void main(String[] args) {
NodeService node = NodeService.getInstance(Constants.HTTP_NODE_EUROPE2);String passphrase = "YOUR SENDING ACCOUNT PASSPHRASE, USED TO SIGN MESSAGES LOCALLY";
SignumAddress recipient = SignumAddress.fromRs("S-JJQS-MMA4-GHB4-4ZNZU");
SignumValue amountToSend = SignumValue.fromSigna(1);
SignumValue fee = SignumValue.fromSigna(0.1);
int deadline = 1440; // deadline in minutes before this transaction becomes invalid// Generate the transaction without signing it
byte[] unsignedTransactionBytes = node.generateTransaction(recipient,
SignumCrypto.getInstance().getPublicKey(passphrase), amountToSend, fee, deadline, null).blockingGet();
// Locally sign the transaction using our passphrase
byte[] signedTransactionBytes = SignumCrypto.getInstance().signTransaction(passphrase, unsignedTransactionBytes);
// Broadcast the transaction through the node, still not sending it any sensitive information.
node.broadcastTransaction(signedTransactionBytes).blockingGet();
}
}
```