Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Java library for V Systems

License

NotificationsYou must be signed in to change notification settings

virtualeconomy/java-v-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java library for V Systems

Install

  1. 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 -versionopenjdk 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)
  2. clone this project

    $ git clone https://github.com/virtualeconomy/java-v-sdk.git
  3. import GSON jar to your project. You can download gson.jar fromGson 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>

Usage

Create chain object

  1. For testnet chain:

    importv.systems.Blockchain;importv.systems.type.NetworkType;Blockchainchain =newBlockchain(NetworkType.Testnet,"http://test.v.systems:9922");
  2. For mainnet chain:

    importv.systems.Blockchain;importv.systems.type.NetworkType;Blockchainchain =newBlockchain(NetworkType.Mainnet,"https://wallet.v.systems/api");
  3. Call node internal used API with API key (to avoidProvided API key is not correct error):

    importv.systems.Blockchain;importv.systems.type.NetworkType;Blockchainchain =newBlockchain(NetworkType.Testnet,"http://test.v.systems:9922","<API_KEY>");List<Transaction>txList =chain.getActiveLeaseTransactions(testAddress);

Create address object

  1. Create account by seed

    importv.systems.Account;importv.systems.type.NetworkType;Accountacc =newAccount(NetworkType.Testnet,"<your seed>",0);
  2. Create account by private key

    importv.systems.Account;importv.systems.type.NetworkType;Accountacc =newAccount(NetworkType.Testnet,"<base58 private key>");
  3. Create account by public key

    importv.systems.Account;importv.systems.type.NetworkType;Accountacc =newAccount(NetworkType.Testnet,"<base58 public key>",null);
  4. Create account by address

    importv.systems.Account;importv.systems.type.NetworkType;Accountacc =newAccount(NetworkType.Testnet,null,"<base58 address>");

Send transaction

  1. Send Payment transaction

    Longamount =1 *Blockchain.V_UNITY;// Send 1.0 V coinPaymentTransactiontx =TransactionFactory.buildPaymentTx("<recipient address>",amount);StringtxId =tx.getId();// get Tx ID offline// Usage 1: for hot wallet sending transactionTransactionresult =acc.sendTransaction(chain,tx);// Usage 2: for cold wallet signing transactionStringsignature =acc.getSignature(tx);
  2. Send Lease transaction

    Longamount =1 *Blockchain.V_UNITY;// Lease 1.0 V coinLeaseTransactiontx =TransactionFactory.buildLeaseTx("<recipient address>",amount);StringtxId =tx.getId();// get Tx ID offline// Usage 1: for hot wallet sending transactionTransactionresult =acc.sendTransaction(chain,tx);// Usage 2: for cold wallet signing transactionStringsignature =acc.getSignature(tx);
  3. Send Token by executing contract function

    First of all, if we do not know any Token information, we could get information bytokenId

    ContractTypetokenType =chain.getContractTypeByTokenId(tokenId);TokenInfotokenInfo =chain.getTokenInfo(tokenId);LongtokenUnity =tokenInfo.getUnity();

    Then we send the token by executing contract function

    Longamount =1 *tokenUnity;// Send 1.0 TokenExecuteContractFunctionTransactiontx =TransactionFactory.buildSendTokenTx(tokenId,tokenType,"<recipient address>",amount);StringtxId =tx.getId();// get Tx ID offline// Usage 1: for hot wallet sending transactionTransactionresult =acc.sendTransaction(chain,tx);// Usage 2: for cold wallet signing transactionStringsignature =acc.getSignature(tx);

[8]ページ先頭

©2009-2025 Movatter.jp