Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

velas/JVelas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

Use

Generate keys

generate keys from random:

HD keys = new Hd();

generate keys from seed:

HD keys = new Hd(seed, deriveIndex);

create keys from private key:

HD keys = new Hd(privateKey);

Wallet

Create wallet

сreate wallet from hd keys:

HD keys = new Hd();
Wallet wallet = keys.toWallet();

сreate wallet from public key:

Wallet wallet = new Wallet(publicKey);

Get balance

get balance by wallet address:

String nodeUrl = "https://testnet.velas.com" //testnet
VelasClient client = new VelasClient(nodeUrl);
BigInteger balance = client.wallet.getBalance(wallet.base58Address); 

Get unspents

get unspents by wallet address:

VelasClient client = new VelasClient(nodeUrl);
List<TransactionInputOutpoint> unspent = 
        client.wallet.getUnspent(wallet.base58Address);

Create transaction

create and sign transaction:

Transaction tx = new Transaction(unspents,
                                amount,
                                hd,
                                wallet.base58Address,
                                toAddress,
                                commission);

Transactions

Validate transaction

validate transaction, return error if transaction incorrect

VelasClient client = new VelasClient(testNetMasterNodeUrl);
HD hd = new HD(pk);
Wallet wallet = hd.toWallet();

List<TransactionInputOutpoint> unspents = 
        client.wallet.getUnspent(wallet.base58Address);

Transaction tx = new Transaction(unspents,
                                amount,
                                hd,
                                wallet.base58Address,
                                toAddress,
                                commission);

boolean res = client.tx.validate(tx); // true or false

Publish Transaction

Publish transaction to blockchain:

VelasClient client = new VelasClient(testNetMasterNodeUrl);
HD hd = new HD(pk);
Wallet wallet = hd.toWallet();

List<TransactionInputOutpoint> unspents = 
        client.wallet.getUnspent(wallet.base58Address);

Transaction tx = new Transaction(unspents,
                                amount,
                                hd,
                                wallet.base58Address,
                                toAddress,
                                commission);

boolean res = client.tx.publish(tx); // true or false

if confirmed field is greater then 0 in transaction object(can get with method getByHashList), then transaction is confirmed

Get transactions by block

Get an array of transaction hashes by range blocks from the given height to the highest block

VelasClient client = new VelasClient(testNetMasterNodeUrl);
int height = 1500;
String[] hashes = client.tx.getHashListByHeight(height);

Get Detail of transactions by hashes

Get array of transaction objects by hash list, maximum hashes is 10000(can change later)

var client = new Client(Url);
// Get hashes by wallet address for example
VelasClient client = new VelasClient(testNetMasterNodeUrl);
String[] hashes = client.tx.getHashListByAddress("VLa1hi77ZXD2BSWDD9wQe8vAhejXyS7vBM4");

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages