Java library for V Systems
- 
To use this SDK, we need Java 1.8. First of all, update the repository $ sudo apt-get update Install Java in your machine $ sudo apt-get install openjdk-8-jdk Check Java version (remove the old version Java if needed). $ java -version openjdk version "1.8.0_181" OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-0ubuntu0.16.04.1-b13) OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
- 
clone this project $ git clone https://github.com/virtualeconomy/java-v-sdk.git 
- 
import GSON jar to your project. You can download gson.jar from Gson Release. If you are using Maven, you can add dependency looks like this: <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.8.5</version> </dependency>
- 
For testnet chain: import v.systems.Blockchain; import v.systems.type.NetworkType; Blockchain chain = new Blockchain(NetworkType.Testnet, "http://test.v.systems:9922"); 
- 
For mainnet chain: import v.systems.Blockchain; import v.systems.type.NetworkType; Blockchain chain = new Blockchain(NetworkType.Mainnet, "https://wallet.v.systems/api"); 
- 
Call node internal used API with API key (to avoid Provided API key is not correcterror):import v.systems.Blockchain; import v.systems.type.NetworkType; Blockchain chain = new Blockchain(NetworkType.Testnet, "http://test.v.systems:9922", "<API_KEY>"); List<Transaction> txList = chain.getActiveLeaseTransactions(testAddress); 
- 
Create account by seed import v.systems.Account; import v.systems.type.NetworkType; Account acc = new Account(NetworkType.Testnet, "<your seed>", 0); 
- 
Create account by private key import v.systems.Account; import v.systems.type.NetworkType; Account acc = new Account(NetworkType.Testnet, "<base58 private key>"); 
- 
Create account by public key import v.systems.Account; import v.systems.type.NetworkType; Account acc = new Account(NetworkType.Testnet, "<base58 public key>", null); 
- 
Create account by address import v.systems.Account; import v.systems.type.NetworkType; Account acc = new Account(NetworkType.Testnet, null, "<base58 address>"); 
- 
Send Payment transaction Long amount = 1 * Blockchain.V_UNITY; // Send 1.0 V coin PaymentTransaction tx = TransactionFactory.buildPaymentTx("<recipient address>", amount); String txId = tx.getId(); // get Tx ID offline // Usage 1: for hot wallet sending transaction Transaction result = acc.sendTransaction(chain, tx); // Usage 2: for cold wallet signing transaction String signature = acc.getSignature(tx); 
- 
Send Lease transaction Long amount = 1 * Blockchain.V_UNITY; // Lease 1.0 V coin LeaseTransaction tx = TransactionFactory.buildLeaseTx("<recipient address>", amount); String txId = tx.getId(); // get Tx ID offline // Usage 1: for hot wallet sending transaction Transaction result = acc.sendTransaction(chain, tx); // Usage 2: for cold wallet signing transaction String signature = acc.getSignature(tx); 
- 
Send Token by executing contract function First of all, if we do not know any Token information, we could get information by tokenIdContractType tokenType = chain.getContractTypeByTokenId(tokenId); TokenInfo tokenInfo = chain.getTokenInfo(tokenId); Long tokenUnity = tokenInfo.getUnity(); Then we send the token by executing contract function Long amount = 1 * tokenUnity; // Send 1.0 Token ExecuteContractFunctionTransaction tx = TransactionFactory.buildSendTokenTx(tokenId, tokenType,"<recipient address>", amount); String txId = tx.getId(); // get Tx ID offline // Usage 1: for hot wallet sending transaction Transaction result = acc.sendTransaction(chain, tx); // Usage 2: for cold wallet signing transaction String signature = acc.getSignature(tx);