The Incubed Java client uses JNI in order to call native functions. But all the native-libraries are bundled inside the jar-file. This jar file ha no dependencies and can even be used standalone:
like
java -cp in3.jar in3.IN3 eth_getBlockByNumber latest false
The jar file can be downloaded from the latest release. here.
Alternatively, If you wish to download Incubed using the maven package manager, add this to your pom.xml
<dependency>
<groupId>it.slock</groupId>
<artifactId>in3</artifactId>
<version>2.21</version>
</dependency>
After which, install in3 with mvn install
.
For building the shared library you need to enable java by using the -DJAVA=true
flag:
git clone git@github.com:slockit/in3-c.git
mkdir -p in3-c/build
cd in3-c/build
cmake -DJAVA=true .. && make
You will find the in3.jar
in the build/lib - folder.
In order to use Incubed in android simply follow these steps:
Step 1: Create a top-level CMakeLists.txt in android project inside app folder and link this to gradle. Follow the steps using this guide on howto link.
The Content of the CMakeLists.txt
should look like this:
cmake_minimum_required(VERSION 3.4.1)
# turn off FAST_MATH in the evm.
ADD_DEFINITIONS(-DIN3_MATH_LITE)
# loop through the required module and cretae the build-folders
foreach(module
c/src/core
c/src/verifier/eth1/nano
c/src/verifier/eth1/evm
c/src/verifier/eth1/basic
c/src/verifier/eth1/full
java/src
c/src/third-party/crypto
c/src/third-party/tommath
c/src/api/eth1)
file(MAKE_DIRECTORY in3-c/${module}/outputs)
add_subdirectory( in3-c/${module} in3-c/${module}/outputs )
endforeach()
Step 2: clone in3-c into the app
-folder or use this script to clone and update in3:
#!/usr/bin/env sh
#github-url for in3-c
IN3_SRC=https://github.com/slockit/in3-c.git
cd app
# if it exists we only call git pull
if [ -d in3-c ]; then
cd in3-c
git pull
cd ..
else
# if not we clone it
git clone $IN3_SRC
fi
# copy the java-sources to the main java path
cp -r in3-c/java/src/in3 src/main/java/
Step 3: Use methods available in app/src/main/java/in3/IN3.java from android activity to access IN3 functions.
Here is example how to use it:
https://github.com/slockit/in3-example-android
source : in3-c/java/examples/CallFunction.java
Calling Functions of Contracts
// This Example shows how to call functions and use the decoded results. Here we get the struct from the registry.
import in3.*;
import in3.eth1.*;
public class CallFunction {
//
public static void main(String[] args) {
// create incubed
IN3 in3 = IN3.forChain(Chain.MAINNET); // set it to mainnet (which is also dthe default)
// call a contract, which uses eth_call to get the result.
Object[] result = (Object[]) in3.getEth1API().call( // call a function of a contract
"0x2736D225f85740f42D17987100dc8d58e9e16252", // address of the contract
"servers(uint256):(string,address,uint256,uint256,uint256,address)", // function signature
1); // first argument, which is the index of the node we are looking for.
System.out.println("url : " + result[0]);
System.out.println("owner : " + result[1]);
System.out.println("deposit : " + result[2]);
System.out.println("props : " + result[3]);
}
}
source : in3-c/java/examples/Configure.java
Changing the default configuration
// In order to change the default configuration, just use the classes inside in3.config package.
package in3;
import in3.*;
import in3.config.*;
import in3.eth1.Block;
public class Configure {
//
public static void main(String[] args) {
// create incubed client
IN3 in3 = IN3.forChain(Chain.GOERLI); // set it to goerli
// Setup a Configuration object for the client
ClientConfiguration clientConfig = in3.getConfig();
clientConfig.setReplaceLatestBlock(6); // define that latest will be -6
clientConfig.setAutoUpdateList(false); // prevents node automatic update
clientConfig.setMaxAttempts(1); // sets max attempts to 1 before giving up
clientConfig.setProof(Proof.none); // does not require proof (not recommended)
// Setup the ChainConfiguration object for the nodes on a certain chain
ChainConfiguration chainConfiguration = new ChainConfiguration(Chain.GOERLI, clientConfig);
chainConfiguration.setNeedsUpdate(false);
chainConfiguration.setContract("0xac1b824795e1eb1f6e609fe0da9b9af8beaab60f");
chainConfiguration.setRegistryId("0x23d5345c5c13180a8080bd5ddbe7cde64683755dcce6e734d95b7b573845facb");
in3.setConfig(clientConfig);
Block block = in3.getEth1API().getBlockByNumber(Block.LATEST, true);
System.out.println(block.getHash());
}
}
source : in3-c/java/examples/GetBalance.java
getting the Balance with or without API
import in3.*;
import in3.eth1.*;
import java.math.BigInteger;
import java.util.*;
public class GetBalance {
static String AC_ADDR = "0xc94770007dda54cF92009BFF0dE90c06F603a09f";
public static void main(String[] args) throws Exception {
// create incubed
IN3 in3 = IN3.forChain(Chain.MAINNET); // set it to mainnet (which is also dthe default)
System.out.println("Balance API" + getBalanceAPI(in3).longValue());
System.out.println("Balance RPC " + getBalanceRPC(in3));
}
static BigInteger getBalanceAPI(IN3 in3) {
return in3.getEth1API().getBalance(AC_ADDR, Block.LATEST);
}
static String getBalanceRPC(IN3 in3) {
return in3.sendRPC("eth_getBalance", new Object[] {AC_ADDR, "latest"});
}
}
source : in3-c/java/examples/GetBlockAPI.java
getting a block with API
import in3.*;
import in3.eth1.*;
import java.math.BigInteger;
import java.util.*;
public class GetBlockAPI {
//
public static void main(String[] args) throws Exception {
// create incubed
IN3 in3 = IN3.forChain(Chain.MAINNET); // set it to mainnet (which is also dthe default)
// read the latest Block including all Transactions.
Block latestBlock = in3.getEth1API().getBlockByNumber(Block.LATEST, true);
// Use the getters to retrieve all containing data
System.out.println("current BlockNumber : " + latestBlock.getNumber());
System.out.println("minded at : " + new Date(latestBlock.getTimeStamp()) + " by " + latestBlock.getAuthor());
// get all Transaction of the Block
Transaction[] transactions = latestBlock.getTransactions();
BigInteger sum = BigInteger.valueOf(0);
for (int i = 0; i < transactions.length; i++)
sum = sum.add(transactions[i].getValue());
System.out.println("total Value transfered in all Transactions : " + sum + " wei");
}
}
source : in3-c/java/examples/GetBlockRPC.java
getting a block without API
import in3.*;
import in3.eth1.*;
import java.math.BigInteger;
import java.util.*;
public class GetBlockRPC {
//
public static void main(String[] args) throws Exception {
// create incubed
IN3 in3 = IN3.forChain(Chain.MAINNET); // set it to mainnet (which is also the default)
// read the latest Block without the Transactions.
String result = in3.sendRPC("eth_getBlockByNumber", new Object[] {"latest", false});
// print the json-data
System.out.println("current Block : " + result);
}
}
source : in3-c/java/examples/GetTransaction.java
getting a Transaction with or without API
import in3.*;
import in3.eth1.*;
import java.math.BigInteger;
import java.util.*;
public class GetTransaction {
static String TXN_HASH = "0xdd80249a0631cf0f1593c7a9c9f9b8545e6c88ab5252287c34bc5d12457eab0e";
public static void main(String[] args) throws Exception {
// create incubed
IN3 in3 = IN3.forChain(Chain.MAINNET); // set it to mainnet (which is also dthe default)
Transaction txn = getTransactionAPI(in3);
System.out.println("Transaction API #blockNumber: " + txn.getBlockNumber());
System.out.println("Transaction RPC :" + getTransactionRPC(in3));
}
static Transaction getTransactionAPI(IN3 in3) {
return in3.getEth1API().getTransactionByHash(TXN_HASH);
}
static String getTransactionRPC(IN3 in3) {
return in3.sendRPC("eth_getTransactionByHash", new Object[] {TXN_HASH});
}
}
source : in3-c/java/examples/GetTransactionReceipt.java
getting a TransactionReceipt with or without API
import in3.*;
import in3.eth1.*;
import java.math.BigInteger;
import java.util.*;
public class GetTransactionReceipt {
static String TRANSACTION_HASH = "0xdd80249a0631cf0f1593c7a9c9f9b8545e6c88ab5252287c34bc5d12457eab0e";
//
public static void main(String[] args) throws Exception {
// create incubed
IN3 in3 = IN3.forChain(Chain.MAINNET); // set it to mainnet (which is also the default)
TransactionReceipt txn = getTransactionReceiptAPI(in3);
System.out.println("TransactionRerceipt API : for txIndex " + txn.getTransactionIndex() + " Block num " + txn.getBlockNumber() + " Gas used " + txn.getGasUsed() + " status " + txn.getStatus());
System.out.println("TransactionReceipt RPC : " + getTransactionReceiptRPC(in3));
}
static TransactionReceipt getTransactionReceiptAPI(IN3 in3) {
return in3.getEth1API().getTransactionReceipt(TRANSACTION_HASH);
}
static String getTransactionReceiptRPC(IN3 in3) {
return in3.sendRPC("eth_getTransactionReceipt", new Object[] {TRANSACTION_HASH});
}
}
source : in3-c/java/examples/SendTransaction.java
Sending Transactions
// In order to send, you need a Signer. The SimpleWallet class is a basic implementation which can be used.
package in3;
import in3.*;
import in3.eth1.*;
import java.io.IOException;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
public class SendTransaction {
//
public static void main(String[] args) throws IOException {
// create incubed
IN3 in3 = IN3.forChain(Chain.MAINNET); // set it to mainnet (which is also dthe default)
// create a wallet managing the private keys
SimpleWallet wallet = new SimpleWallet();
// add accounts by adding the private keys
String keyFile = "myKey.json";
String myPassphrase = "<secrect>";
// read the keyfile and decoded the private key
String account = wallet.addKeyStore(
Files.readString(Paths.get(keyFile)),
myPassphrase);
// use the wallet as signer
in3.setSigner(wallet);
String receipient = "0x1234567890123456789012345678901234567890";
BigInteger value = BigInteger.valueOf(100000);
// create a Transaction
TransactionRequest tx = new TransactionRequest();
tx.setFrom(account);
tx.setTo("0x1234567890123456789012345678901234567890");
tx.setFunction("transfer(address,uint256)");
tx.setParams(new Object[] {receipient, value});
String txHash = in3.getEth1API().sendTransaction(tx);
System.out.println("Transaction sent with hash = " + txHash);
}
}
In order to run those examples, you only need a Java SDK installed.
./build.sh
will build all examples in this directory.
In order to run a example use
java -cp $IN3/build/lib/in3.jar:. GetBlockAPI
arguments:
========== ==========
``String`` **hash**
========== ==========
arguments:
======== ============
``long`` **number**
======== ============
public
Long
getNumber();
public
void
setNumber(long
block);
arguments:
======== ===========
``long`` **block**
======== ===========
public
String
getHash();
public
void
setHash(String
hash);
arguments:
========== ==========
``String`` **hash**
========== ==========
public
String
toJSON();
public
String
toString();
Constants for Chain-specs.
support for multiple chains, a client can then switch between different chains (but consumes more memory)
Type: static final long
use mainnet
Type: static final long
use kovan testnet
Type: static final long
use tobalaba testnet
Type: static final long
use goerli testnet
Type: static final long
use ewf chain
Type: static final long
use evan testnet
Type: static final long
use ipfs
Type: static final long
use volta test net
Type: static final long
use local client
Type: static final long
use bitcoin client
Type: static final long
This is the main class creating the incubed client.
The client can then be configured.
public IN3();
returns the current configuration.
any changes to the configuration will be applied witth the next request.
public
ClientConfiguration
getConfig();
sets the signer or wallet.
public
void
setSigner(Signer
signer);
arguments:
========================= ============
`Signer <#class-signer>`_ **signer**
========================= ============
returns the signer or wallet.
public
Signer
getSigner();
gets the ipfs-api
public
in3.ipfs.API
getIpfs();
gets the btc-api
public
in3.btc.API
getBtcAPI();
gets the ethereum-api
public
in3.eth1.API
getEth1API();
gets the utils/crypto-api
public
Crypto
getCrypto();
provides the ability to cache content like nodelists, contract codes and validatorlists
public
void
setStorageProvider(StorageProvider
val);
arguments:
=========================================== =========
`StorageProvider <#class-storageprovider>`_ **val**
=========================================== =========
provides the ability to cache content
public
StorageProvider
getStorageProvider();
sets The transport interface.
This allows to fetch the result of the incubed in a different way.
public
void
setTransport(IN3Transport
newTransport);
arguments:
================ ==================
``IN3Transport`` **newTransport**
================ ==================
returns the current transport implementation.
public
IN3Transport
getTransport();
servers to filter for the given chain.
The chain-id based on EIP-155.
public
native long
getChainId();
sets the chain to be used.
The chain-id based on EIP-155.
public
native void
setChainId(long
val);
arguments:
======== =========
``long`` **val**
======== =========
send a request.
The request must a valid json-string with method and params
public
String
send(String
request);
arguments:
========== =============
``String`` **request**
========== =============
send a request but returns a object like array or map with the parsed response.
The request must a valid json-string with method and params
public
Object
sendobject(String
request);
arguments:
========== =============
``String`` **request**
========== =============
send a RPC request by only passing the method and params.
It will create the raw request from it and return the result.
arguments:
============ ============
``String`` **method**
``Object[]`` **params**
============ ============
public
Object
sendRPCasObject(String
method,Object[]
params,boolean
useEnsResolver);
arguments:
============ ====================
``String`` **method**
``Object[]`` **params**
``boolean`` **useEnsResolver**
============ ====================
send a RPC request by only passing the method and params.
It will create the raw request from it and return the result.
public
Object
sendRPCasObject(String
method,Object[]
params);
arguments:
============ ============
``String`` **method**
``Object[]`` **params**
============ ============
clears the cache.
public
boolean
cacheClear();
restrieves the node list
public
IN3Node[]
nodeList();
request for a signature of an already verified hash.
public
SignedBlockHash[]
sign(BlockID[]
blocks,String[]
dataNodeAdresses);
arguments:
============================= ======================
`BlockID[] <#class-blockid>`_ **blocks**
``String[]`` **dataNodeAdresses**
============================= ======================
create a Incubed client using the chain-config.
if chainId is Chain.MULTICHAIN, the client can later be switched between different chains, for all other chains, it will be initialized only with the chainspec for this one chain (safes memory)
arguments:
======== =============
``long`` **chainId**
======== =============
returns the current incubed version.
public static
native String
getVersion();
public static
void
main(String[]
args);
arguments:
============ ==========
``String[]`` **args**
============ ==========
arguments:
============ =============
``String[]`` **urls**
``byte[]`` **payload**
============ =============
public
String
getUrl();
public
String
getAddress();
public
int
getIndex();
public
String
getDeposit();
public
long
getProps();
public
int
getTimeout();
public
int
getRegisterTime();
public
int
getWeight();
public IN3Props();
public
void
setDataNodes(String[]
adresses);
arguments:
============ ==============
``String[]`` **adresses**
============ ==============
public
void
setSignerNodes(String[]
adresses);
arguments:
============ ==============
``String[]`` **adresses**
============ ==============
public
String
toString();
public
String
toJSON();
public static
void
loadLibrary();
returns an array of IN3Node
public
IN3Node[]
getNodes();
Type: static final long
Type: static final long
Type: static final long
Type: static final long
Type: static final long
Type: static final long
Type: static final long
public
String
getBlockHash();
public
long
getBlock();
public
String
getR();
public
String
getS();
public
long
getV();
public
String
getMsgHash();
The Proof type indicating how much proof is required.
The enum type contains the following values:
============== = =====================================================================
**none** 0 No Verification.
**standard** 1 Standard Verification of the important properties.
**full** 2 Full Verification including even uncles wich leads to higher payload.
============== = =====================================================================
arguments:
============ =============
``String[]`` **urls**
``byte[]`` **payload**
============ =============
API for handling BitCoin data.
Use it when connected to Chain.BTC.
creates a btc.API using the given incubed instance.
public API(
IN3
in3);
arguments:
=================== =========
`IN3 <#class-in3>`_ **in3**
=================== =========
Retrieves the transaction and returns the data as json.
public
Transaction
getTransaction(String
txid);
arguments:
========== ==========
``String`` **txid**
========== ==========
Retrieves the serialized transaction (bytes).
public
byte[]
getTransactionBytes(String
txid);
arguments:
========== ==========
``String`` **txid**
========== ==========
Retrieves the blockheader.
public
BlockHeader
getBlockHeader(String
blockHash);
arguments:
========== ===============
``String`` **blockHash**
========== ===============
Retrieves the byte array representing teh serialized blockheader data.
public
byte[]
getBlockHeaderBytes(String
blockHash);
arguments:
========== ===============
``String`` **blockHash**
========== ===============
Retrieves the block including the full transaction data.
Use Api::GetBlockWithTxIds" for only the transaction ids.
arguments:
========== ===============
``String`` **blockHash**
========== ===============
Retrieves the block including only transaction ids.
Use Api::GetBlockWithTxData for the full transaction data.
arguments:
========== ===============
``String`` **blockHash**
========== ===============
Retrieves the serialized block in bytes.
public
byte[]
getBlockBytes(String
blockHash);
arguments:
========== ===============
``String`` **blockHash**
========== ===============
A Block.
Transactions or Transaction of a block.
public
Transaction[]
getTransactions();
Transactions or Transaction ids of a block.
public
String[]
getTransactionHashes();
Size of this block in bytes.
public
long
getSize();
Weight of this block in bytes.
public
long
getWeight();
A Block header.
The hash of the blockheader.
public
String
getHash();
Number of confirmations or blocks mined on top of the containing block.
public
long
getConfirmations();
Block number.
public
long
getHeight();
Used version.
public
long
getVersion();
Version as hex.
public
String
getVersionHex();
Merkle root of the trie of all transactions in the block.
public
String
getMerkleroot();
Unix timestamp in seconds since 1970.
public
long
getTime();
Unix timestamp in seconds since 1970.
public
long
getMediantime();
Nonce-field of the block.
public
long
getNonce();
Bits (target) for the block as hex.
public
String
getBits();
Difficulty of the block.
public
float
getDifficulty();
Total amount of work since genesis.
public
String
getChainwork();
Number of transactions in the block.
public
long
getNTx();
Hash of the parent blockheader.
public
String
getPreviousblockhash();
Hash of the next blockheader.
public
String
getNextblockhash();
Script on a transaction output.
The hash of the blockheader.
public
String
getAsm();
The raw hex data.
public
String
getHex();
The required sigs.
public
long
getReqSigs();
The type e.g.
: pubkeyhash.
public
String
getType();
List of addresses.
public
String[]
getAddresses();
Script on a transaction input.
public ScriptSig(
JSON
data);
arguments:
===================== ==========
`JSON <#class-json>`_ **data**
===================== ==========
The asm data.
public
String
getAsm();
The raw hex data.
public
String
getHex();
A BitCoin Transaction.
public static
Transaction
asTransaction(Object
o);
arguments:
========== =======
``Object`` **o**
========== =======
public static
Transaction[]
asTransactions(Object
o);
arguments:
========== =======
``Object`` **o**
========== =======
Transaction Id.
public
String
getTxid();
The transaction hash (differs from txid for witness transactions).
public
String
getHash();
The version.
public
long
getVersion();
The serialized transaction size.
public
long
getSize();
The virtual transaction size (differs from size for witness transactions).
public
long
getVsize();
The transactions weight (between vsize4-3 and vsize4).
public
long
getWeight();
The locktime.
public
long
getLocktime();
The hex representation of raw data.
public
String
getHex();
The block hash of the block containing this transaction.
public
String
getBlockhash();
The confirmations.
public
long
getConfirmations();
The transaction time in seconds since epoch (Jan 1 1970 GMT).
public
long
getTime();
The block time in seconds since epoch (Jan 1 1970 GMT).
public
long
getBlocktime();
The transaction inputs.
public
TransactionInput[]
getVin();
The transaction outputs.
public
TransactionOutput[]
getVout();
Input of a transaction.
The transaction id.
public
String
getTxid();
The index of the transactionoutput.
public
long
getYout();
The script.
public
ScriptSig
getScriptSig();
Hex-encoded witness data (if any).
public
String[]
getTxinwitness();
The script sequence number.
public
long
getSequence();
A BitCoin Transaction.
public TransactionOutput(
JSON
data);
arguments:
===================== ==========
`JSON <#class-json>`_ **data**
===================== ==========
The value in bitcoins.
public
float
getValue();
The index in the transaction.
public
long
getN();
The script of the transaction.
public
ScriptPubKey
getScriptPubKey();
Part of the configuration hierarchy for IN3 Client.
Holds the configuration a node group in a particular Chain.
Type: NodeConfigurationArrayList< , >
public ChainConfiguration(
long
chain,ClientConfiguration
config);
arguments:
=================================================== ============
``long`` **chain**
`ClientConfiguration <#class-clientconfiguration>`_ **config**
=================================================== ============
public
long
getChain();
public
Boolean
isNeedsUpdate();
public
void
setNeedsUpdate(boolean
needsUpdate);
arguments:
=========== =================
``boolean`` **needsUpdate**
=========== =================
public
String
getContract();
public
void
setContract(String
contract);
arguments:
========== ==============
``String`` **contract**
========== ==============
public
String
getRegistryId();
public
void
setRegistryId(String
registryId);
arguments:
========== ================
``String`` **registryId**
========== ================
public
String
getWhiteListContract();
public
void
setWhiteListContract(String
whiteListContract);
arguments:
========== =======================
``String`` **whiteListContract**
========== =======================
public
String[]
getWhiteList();
public
void
setWhiteList(String[]
whiteList);
arguments:
============ ===============
``String[]`` **whiteList**
============ ===============
generates a json-string based on the internal data.
public
String
toJSON();
public
String
toString();
Configuration Object for Incubed Client.
It holds the state for the root of the configuration tree. Should be retrieved from the client instance as IN3::getConfig()
public
Integer
getRequestCount();
sets the number of requests send when getting a first answer
public
void
setRequestCount(int
requestCount);
arguments:
======= ==================
``int`` **requestCount**
======= ==================
public
Boolean
isAutoUpdateList();
activates the auto update.if true the nodelist will be automaticly updated if the lastBlock is newer
public
void
setAutoUpdateList(boolean
autoUpdateList);
arguments:
=========== ====================
``boolean`` **autoUpdateList**
=========== ====================
public
Proof
getProof();
sets the type of proof used
public
void
setProof(Proof
proof);
arguments:
======================= ===========
`Proof <#class-proof>`_ **proof**
======================= ===========
public
Integer
getMaxAttempts();
sets the max number of attempts before giving up
public
void
setMaxAttempts(int
maxAttempts);
arguments:
======= =================
``int`` **maxAttempts**
======= =================
public
Integer
getSignatureCount();
sets the number of signatures used to proof the blockhash.
public
void
setSignatureCount(int
signatureCount);
arguments:
======= ====================
``int`` **signatureCount**
======= ====================
public
Boolean
isStats();
if true (default) the request will be counted as part of the regular stats, if not they are not shown as part of the dashboard.
public
void
setStats(boolean
stats);
arguments:
=========== ===========
``boolean`` **stats**
=========== ===========
public
Integer
getFinality();
sets the number of signatures in percent required for the request
public
void
setFinality(int
finality);
arguments:
======= ==============
``int`` **finality**
======= ==============
public
Boolean
isIncludeCode();
public
void
setIncludeCode(boolean
includeCode);
arguments:
=========== =================
``boolean`` **includeCode**
=========== =================
public
Boolean
isBootWeights();
if true, the first request (updating the nodelist) will also fetch the current health status and use it for blacklisting unhealthy nodes.
This is used only if no nodelist is availabkle from cache.
public
void
setBootWeights(boolean
value);
arguments:
=========== ===========
``boolean`` **value**
=========== ===========
public
Boolean
isKeepIn3();
public
void
setKeepIn3(boolean
keepIn3);
arguments:
=========== =============
``boolean`` **keepIn3**
=========== =============
public
Boolean
isUseHttp();
public
void
setUseHttp(boolean
useHttp);
arguments:
=========== =============
``boolean`` **useHttp**
=========== =============
public
Long
getTimeout();
specifies the number of milliseconds before the request times out.
increasing may be helpful if the device uses a slow connection.
public
void
setTimeout(long
timeout);
arguments:
======== =============
``long`` **timeout**
======== =============
public
Long
getMinDeposit();
sets min stake of the server.
Only nodes owning at least this amount will be chosen.
public
void
setMinDeposit(long
minDeposit);
arguments:
======== ================
``long`` **minDeposit**
======== ================
public
Long
getNodeProps();
public
void
setNodeProps(long
nodeProps);
arguments:
======== ===============
``long`` **nodeProps**
======== ===============
public
Long
getNodeLimit();
sets the limit of nodes to store in the client.
public
void
setNodeLimit(long
nodeLimit);
arguments:
======== ===============
``long`` **nodeLimit**
======== ===============
public
Integer
getReplaceLatestBlock();
replaces the latest with blockNumber- specified value
public
void
setReplaceLatestBlock(int
replaceLatestBlock);
arguments:
======= ========================
``int`` **replaceLatestBlock**
======= ========================
public
String
getRpc();
setup an custom rpc source for requests by setting Chain to local and proof to none
public
void
setRpc(String
rpc);
arguments:
========== =========
``String`` **rpc**
========== =========
public
ChainConfigurationHashMap< Long, , >
getNodesConfig();
public
void
setChainsConfig(HashMap<
Long,ChainConfiguration
>);
arguments:
=================================================================== ==================
`ChainConfigurationHashMap< Long, , > <#class-chainconfiguration>`_ **chainsConfig**
=================================================================== ==================
public
void
markAsSynced();
public
boolean
isSynced();
public
String
toString();
generates a json-string based on the internal data.
public
String
toJSON();
Configuration Object for Incubed Client.
It represents the node of a nodelist.
public NodeConfiguration(
ChainConfiguration
config);
arguments:
================================================= ============
`ChainConfiguration <#class-chainconfiguration>`_ **config**
================================================= ============
public
String
getUrl();
public
void
setUrl(String
url);
arguments:
========== =========
``String`` **url**
========== =========
public
long
getProps();
public
void
setProps(long
props);
arguments:
======== ===========
``long`` **props**
======== ===========
public
String
getAddress();
public
void
setAddress(String
address);
arguments:
========== =============
``String`` **address**
========== =============
public
String
toString();
an Interface class, which is able to generate a JSON-String.
generates a json-string based on the internal data.
public
String
toJSON();
a Wrapper for the incubed client offering Type-safe Access and additional helper functions.
creates an eth1.API using the given incubed instance.
public API(
IN3
in3);
arguments:
=================== =========
`IN3 <#class-in3>`_ **in3**
=================== =========
finds the Block as specified by the number.
use Block.LATEST
for getting the lastest block.
public
Block
getBlockByNumber(long
block,boolean
includeTransactions);
arguments:
=========== ========================= ================================================================================================
``long`` **block**
``boolean`` **includeTransactions** < the Blocknumber < if true all Transactions will be includes, if not only the transactionhashes
=========== ========================= ================================================================================================
Returns information about a block by hash.
public
Block
getBlockByHash(String
blockHash,boolean
includeTransactions);
arguments:
=========== ========================= ================================================================================================
``String`` **blockHash**
``boolean`` **includeTransactions** < the Blocknumber < if true all Transactions will be includes, if not only the transactionhashes
=========== ========================= ================================================================================================
the current BlockNumber.
public
long
getBlockNumber();
the current Gas Price.
public
long
getGasPrice();
Returns the EIP155 chain ID used for transaction signing at the current best block.
Null is returned if not available.
public
String
getChainId();
calls a function of a smart contract and returns the result.
public
Object
call(TransactionRequest
request,long
block);
arguments:
================================================= ============= =============================================================
`TransactionRequest <#class-transactionrequest>`_ **request**
``long`` **block** < the transaction to call. < the Block used to for the state.
================================================= ============= =============================================================
returns: Object
: the decoded result. if only one return value is expected the Object will be returned, if not an array of objects will be the result.
Makes a call or transaction, which won't be added to the blockchain and returns the used gas, which can be used for estimating the used gas.
public
long
estimateGas(TransactionRequest
request,long
block);
arguments:
================================================= ============= =============================================================
`TransactionRequest <#class-transactionrequest>`_ **request**
``long`` **block** < the transaction to call. < the Block used to for the state.
================================================= ============= =============================================================
returns: long
: the gas required to call the function.
Returns the balance of the account of given address in wei.
arguments:
========== =============
``String`` **address**
``long`` **block**
========== =============
Returns code at a given address.
arguments:
========== =============
``String`` **address**
``long`` **block**
========== =============
Returns the value from a storage position at a given address.
public
String
getStorageAt(String
address,BigInteger
position,long
block);
arguments:
============== ==============
``String`` **address**
``BigInteger`` **position**
``long`` **block**
============== ==============
Returns the number of transactions in a block from a block matching the given block hash.
public
long
getBlockTransactionCountByHash(String
blockHash);
arguments:
========== ===============
``String`` **blockHash**
========== ===============
Returns the number of transactions in a block from a block matching the given block number.
public
long
getBlockTransactionCountByNumber(long
block);
arguments:
======== ===========
``long`` **block**
======== ===========
Polling method for a filter, which returns an array of logs which occurred since last poll.
arguments:
======== ========
``long`` **id**
======== ========
Polling method for a filter, which returns an array of logs which occurred since last poll.
public
String[]
getFilterChangesFromBlocks(long
id);
arguments:
======== ========
``long`` **id**
======== ========
Polling method for a filter, which returns an array of logs which occurred since last poll.
arguments:
======== ========
``long`` **id**
======== ========
Polling method for a filter, which returns an array of logs which occurred since last poll.
arguments:
=============================== ============
`LogFilter <#class-logfilter>`_ **filter**
=============================== ============
Returns information about a transaction by block hash and transaction index position.
public
Transaction
getTransactionByBlockHashAndIndex(String
blockHash,int
index);
arguments:
========== ===============
``String`` **blockHash**
``int`` **index**
========== ===============
Returns information about a transaction by block number and transaction index position.
public
Transaction
getTransactionByBlockNumberAndIndex(long
block,int
index);
arguments:
======== ===========
``long`` **block**
``int`` **index**
======== ===========
Returns the information about a transaction requested by transaction hash.
public
Transaction
getTransactionByHash(String
transactionHash);
arguments:
========== =====================
``String`` **transactionHash**
========== =====================
Returns the number of transactions sent from an address.
public
BigInteger
getTransactionCount(String
address,long
block);
arguments:
========== =============
``String`` **address**
``long`` **block**
========== =============
Returns the number of transactions sent from an address.
public
TransactionReceipt
getTransactionReceipt(String
transactionHash);
arguments:
========== =====================
``String`` **transactionHash**
========== =====================
Returns information about a uncle of a block number and uncle index position.
Note: An uncle doesn't contain individual transactions.
public
Block
getUncleByBlockNumberAndIndex(long
block,int
pos);
arguments:
======== ===========
``long`` **block**
``int`` **pos**
======== ===========
Returns the number of uncles in a block from a block matching the given block hash.
public
long
getUncleCountByBlockHash(String
block);
arguments:
========== ===========
``String`` **block**
========== ===========
Returns the number of uncles in a block from a block matching the given block hash.
public
long
getUncleCountByBlockNumber(long
block);
arguments:
======== ===========
``long`` **block**
======== ===========
Creates a filter in the node, to notify when a new block arrives.
To check if the state has changed, call eth_getFilterChanges.
public
long
newBlockFilter();
Creates a filter object, based on filter options, to notify when the state changes (logs).
To check if the state has changed, call eth_getFilterChanges.
A note on specifying topic filters: Topics are order-dependent. A transaction with a log with topics [A, B] will be matched by the following topic filters:
[] "anything" [A] "A in first position (and anything after)" [null, B] "anything in first position AND B in second position (and anything after)" [A, B] "A in first position AND B in second position (and anything after)" [[A, B], [A, B]] "(A OR B) in first position AND (A OR B) in second position (and anything after)"
public
long
newLogFilter(LogFilter
filter);
arguments:
=============================== ============
`LogFilter <#class-logfilter>`_ **filter**
=============================== ============
uninstall filter.
public
boolean
uninstallFilter(long
filter);
arguments:
======== ============
``long`` **filter**
======== ============
Creates new message call transaction or a contract creation for signed transactions.
public
String
sendRawTransaction(String
data);
arguments:
========== ==========
``String`` **data**
========== ==========
returns: String
: transactionHash
encodes the arguments as described in the method signature using ABI-Encoding.
arguments:
============ ===============
``String`` **signature**
``String[]`` **params**
============ ===============
decodes the data based on the signature.
public
String[]
abiDecode(String
signature,String
encoded);
arguments:
========== ===============
``String`` **signature**
``String`` **encoded**
========== ===============
converts the given address to a checksum address.
public
String
checksumAddress(String
address);
arguments:
========== =============
``String`` **address**
========== =============
converts the given address to a checksum address.
Second parameter includes the chainId.
public
String
checksumAddress(String
address,Boolean
useChainId);
arguments:
=========== ================
``String`` **address**
``Boolean`` **useChainId**
=========== ================
resolve ens-name.
public
String
ens(String
name);
arguments:
========== ==========
``String`` **name**
========== ==========
resolve ens-name.
Second parameter especifies if it is an address, owner, resolver or hash.
arguments:
=============================== ==========
``String`` **name**
`ENSMethod <#class-ensmethod>`_ **type**
=============================== ==========
sends a Transaction as described by the TransactionRequest.
This will require a signer to be set in order to sign the transaction.
public
String
sendTransaction(TransactionRequest
tx);
arguments:
================================================= ========
`TransactionRequest <#class-transactionrequest>`_ **tx**
================================================= ========
the current Gas Price.
public
Object
call(String
to,String
function,Object...
params);
arguments:
============= ==============
``String`` **to**
``String`` **function**
``Object...`` **params**
============= ==============
returns: Object
: the decoded result. if only one return value is expected the Object will be returned, if not an array of objects will be the result.
represents a Block in ethereum.
The latest Block Number.
Type: static long
The Genesis Block.
Type: static long
returns the total Difficulty as a sum of all difficulties starting from genesis.
public
BigInteger
getTotalDifficulty();
the gas limit of the block.
public
BigInteger
getGasLimit();
the extra data of the block.
public
String
getExtraData();
the difficulty of the block.
public
BigInteger
getDifficulty();
the author or miner of the block.
public
String
getAuthor();
the roothash of the merkletree containing all transaction of the block.
public
String
getTransactionsRoot();
the roothash of the merkletree containing all transaction receipts of the block.
public
String
getTransactionReceiptsRoot();
the roothash of the merkletree containing the complete state.
public
String
getStateRoot();
the transaction hashes of the transactions in the block.
public
String[]
getTransactionHashes();
the transactions of the block.
public
Transaction[]
getTransactions();
the unix timestamp in seconds since 1970.
public
long
getTimeStamp();
the roothash of the merkletree containing all uncles of the block.
public
String
getSha3Uncles();
the size of the block.
public
long
getSize();
the seal fields used for proof of authority.
public
String[]
getSealFields();
the block hash of the of the header.
public
String
getHash();
the bloom filter of the block.
public
String
getLogsBloom();
the mix hash of the block.
(only valid of proof of work)
public
String
getMixHash();
the mix hash of the block.
(only valid of proof of work)
public
String
getNonce();
the block number
public
long
getNumber();
the hash of the parent-block.
public
String
getParentHash();
returns the blockhashes of all uncles-blocks.
public
String[]
getUncles();
public
int
hashCode();
public
boolean
equals(Object
obj);
arguments:
========== =========
``Object`` **obj**
========== =========
a log entry of a transaction receipt.
true when the log was removed, due to a chain reorganization.
false if its a valid log.
public
boolean
isRemoved();
integer of the log index position in the block.
null when its pending log.
public
int
getLogIndex();
integer of the transactions index position log was created from.
null when its pending log.
public
int
gettTansactionIndex();
Hash, 32 Bytes - hash of the transactions this log was created from.
null when its pending log.
public
String
getTransactionHash();
Hash, 32 Bytes - hash of the block where this log was in.
null when its pending. null when its pending log.
public
String
getBlockHash();
the block number where this log was in.
null when its pending. null when its pending log.
public
long
getBlockNumber();
20 Bytes - address from which this log originated.
public
String
getAddress();
Array of 0 to 4 32 Bytes DATA of indexed log arguments.
(In solidity: The first topic is the hash of the signature of the event (e.g. Deposit(address,bytes32,uint256)), except you declared the event with the anonymous specifier.)
public
String[]
getTopics();
Log configuration for search logs.
public
long
getFromBlock();
public
void
setFromBlock(long
fromBlock);
arguments:
======== ===============
``long`` **fromBlock**
======== ===============
public
long
getToBlock();
public
void
setToBlock(long
toBlock);
arguments:
======== =============
``long`` **toBlock**
======== =============
public
String
getAddress();
public
void
setAddress(String
address);
arguments:
========== =============
``String`` **address**
========== =============
public
Object[]
getTopics();
public
void
setTopics(Object[]
topics);
arguments:
============ ============
``Object[]`` **topics**
============ ============
public
int
getLimit();
public
void
setLimit(int
limit);
arguments:
======= ===========
``int`` **limit**
======= ===========
creates a JSON-String.
public
String
toString();
a simple Implementation for holding private keys to sing data or transactions.
adds a key to the wallet and returns its public address.
public
String
addRawKey(String
data);
arguments:
========== ==========
``String`` **data**
========== ==========
adds a key to the wallet and returns its public address.
public
String
addKeyStore(String
jsonData,String
passphrase);
arguments:
========== ================
``String`` **jsonData**
``String`` **passphrase**
========== ================
optiional method which allows to change the transaction-data before sending it.
This can be used for redirecting it through a multisig.
public
TransactionRequest
prepareTransaction(IN3
in3,TransactionRequest
tx);
arguments:
================================================= =========
`IN3 <#class-in3>`_ **in3**
`TransactionRequest <#class-transactionrequest>`_ **tx**
================================================= =========
returns true if the account is supported (or unlocked)
public
boolean
canSign(String
address);
arguments:
========== =============
``String`` **address**
========== =============
signing of the raw data.
arguments:
========== =============
``String`` **data**
``String`` **address**
========== =============
represents a Transaction in ethereum.
public static
Transaction
asTransaction(Object
o);
arguments:
========== =======
``Object`` **o**
========== =======
the blockhash of the block containing this transaction.
public
String
getBlockHash();
the block number of the block containing this transaction.
public
long
getBlockNumber();
the chainId of this transaction.
public
String
getChainId();
the address of the deployed contract (if successfull)
public
String
getCreatedContractAddress();
the address of the sender.
public
String
getFrom();
the Transaction hash.
public
String
getHash();
the Transaction data or input data.
public
String
getData();
the nonce used in the transaction.
public
long
getNonce();
the public key of the sender.
public
String
getPublicKey();
the value send in wei.
public
BigInteger
getValue();
the raw transaction as rlp encoded data.
public
String
getRaw();
the address of the receipient or contract.
public
String
getTo();
the signature of the sender - a array of the [ r, s, v]
public
String[]
getSignature();
the gas price provided by the sender.
public
long
getGasPrice();
the gas provided by the sender.
public
long
getGas();
represents a Transaction receipt in ethereum.
the blockhash of the block containing this transaction.
public
String
getBlockHash();
the block number of the block containing this transaction.
public
long
getBlockNumber();
the address of the deployed contract (if successfull)
public
String
getCreatedContractAddress();
the address of the sender.
public
String
getFrom();
the Transaction hash.
public
String
getTransactionHash();
the Transaction index.
public
int
getTransactionIndex();
20 Bytes - The address of the receiver.
null when it's a contract creation transaction.
public
String
getTo();
The amount of gas used by this specific transaction alone.
public
long
getGasUsed();
Array of log objects, which this transaction generated.
public
Log[]
getLogs();
256 Bytes - A bloom filter of logs/events generated by contracts during transaction execution.
Used to efficiently rule out transactions without expected logs
public
String
getLogsBloom();
32 Bytes - Merkle root of the state trie after the transaction has been executed (optional after Byzantium hard fork EIP609).
public
String
getRoot();
success of a Transaction.
true indicates transaction failure , false indicates transaction success. Set for blocks mined after Byzantium hard fork EIP609, null before.
public
boolean
getStatus();
represents a Transaction Request which should be send or called.
public
String
getFrom();
public
void
setFrom(String
from);
arguments:
========== ==========
``String`` **from**
========== ==========
public
String
getTo();
public
void
setTo(String
to);
arguments:
========== ========
``String`` **to**
========== ========
public
BigInteger
getValue();
public
void
setValue(BigInteger
value);
arguments:
============== ===========
``BigInteger`` **value**
============== ===========
public
long
getNonce();
public
void
setNonce(long
nonce);
arguments:
======== ===========
``long`` **nonce**
======== ===========
public
long
getGas();
public
void
setGas(long
gas);
arguments:
======== =========
``long`` **gas**
======== =========
public
long
getGasPrice();
public
void
setGasPrice(long
gasPrice);
arguments:
======== ==============
``long`` **gasPrice**
======== ==============
public
String
getFunction();
public
void
setFunction(String
function);
arguments:
========== ==============
``String`` **function**
========== ==============
public
Object[]
getParams();
public
void
setParams(Object[]
params);
arguments:
============ ============
``Object[]`` **params**
============ ============
public
void
setData(String
data);
arguments:
========== ==========
``String`` **data**
========== ==========
creates the data based on the function/params values.
public
String
getData();
public
String
getTransactionJson();
public
Object
getResult(String
data);
arguments:
========== ==========
``String`` **data**
========== ==========
The enum type contains the following values:
============== =
**addr** 0
**resolver** 1
**hash** 2
**owner** 3
============== =
API for ipfs custom methods.
To be used along with "Chain.IPFS" on in3 instance.
creates a ipfs.API using the given incubed instance.
public API(
IN3
in3);
arguments:
=================== =========
`IN3 <#class-in3>`_ **in3**
=================== =========
Returns the content associated with specified multihash on success OR NULL on error.
public
byte[]
get(String
multihash);
arguments:
========== ===============
``String`` **multihash**
========== ===============
Returns the IPFS multihash of stored content on success OR NULL on error.
public
String
put(String
content);
arguments:
========== =============
``String`` **content**
========== =============
Returns the IPFS multihash of stored content on success OR NULL on error.
public
String
put(byte[]
content);
arguments:
========== =============
``byte[]`` **content**
========== =============
The enum type contains the following values:
============ =
**base64** 0
**hex** 1
**utf8** 2
============ =
Pojo that represents the result of an ecrecover operation (see: Crypto class).
address from ecrecover operation.
public
String
getAddress();
public key from ecrecover operation.
public
String
getPublicKey();
a Wrapper for crypto-related helper functions.
public Crypto(
IN3
in3);
arguments:
=================== =========
`IN3 <#class-in3>`_ **in3**
=================== =========
returns a signature given a message and a key.
public
Signature
signData(String
msg,String
key,SignatureType
sigType);
arguments:
======================================= =============
``String`` **msg**
``String`` **key**
`SignatureType <#class-signaturetype>`_ **sigType**
======================================= =============
arguments:
========== ================
``String`` **key**
``String`` **passphrase**
========== ================
extracts the public address from a private key.
public
String
pk2address(String
key);
arguments:
========== =========
``String`` **key**
========== =========
extracts the public key from a private key.
public
String
pk2public(String
key);
arguments:
========== =========
``String`` **key**
========== =========
extracts the address and public key from a signature.
arguments:
========== =========
``String`` **msg**
``String`` **sig**
========== =========
extracts the address and public key from a signature.
public
Account
ecrecover(String
msg,String
sig,SignatureType
sigType);
arguments:
======================================= =============
``String`` **msg**
``String`` **sig**
`SignatureType <#class-signaturetype>`_ **sigType**
======================================= =============
returns a signature given a message and a key.
arguments:
========== =========
``String`` **msg**
``String`` **key**
========== =========
internal helper tool to represent a JSON-Object.
Since the internal representation of JSON in incubed uses hashes instead of name, the getter will creates these hashes.
gets the property
public
Object
get(String
prop);
arguments:
========== ========== =========================
``String`` **prop** the name of the property.
========== ========== =========================
returns: Object
: the raw object.
adds values.
This function will be called from the JNI-Iterface.
Internal use only!
arguments:
========== ========= ===================
``int`` **key** the hash of the key
``Object`` **val** the value object
========== ========= ===================
returns the property as long
public
long
getLong(String
key);
arguments:
========== ========= ================
``String`` **key** the propertyName
========== ========= ================
returns: long
: the long value
returns the property as BigInteger
public
BigInteger
getBigInteger(String
key);
arguments:
========== ========= ================
``String`` **key** the propertyName
========== ========= ================
returns: BigInteger
: the BigInteger value
returns the property as StringArray
public
String[]
getStringArray(String
key);
arguments:
========== ========= ================
``String`` **key** the propertyName
========== ========= ================
returns: String[]
: the array or null
returns the property as String or in case of a number as hexstring.
public
String
getString(String
key);
arguments:
========== ========= ================
``String`` **key** the propertyName
========== ========= ================
returns: String
: the hexstring
public
String
toString();
public
int
hashCode();
public
boolean
equals(Object
obj);
arguments:
========== =========
``Object`` **obj**
========== =========
casts the object to a String[]
public static
String[]
asStringArray(Object
o);
arguments:
========== =======
``Object`` **o**
========== =======
public static
BigInteger
asBigInteger(Object
o);
arguments:
========== =======
``Object`` **o**
========== =======
public static
long
asLong(Object
o);
arguments:
========== =======
``Object`` **o**
========== =======
public static
int
asInt(Object
o);
arguments:
========== =======
``Object`` **o**
========== =======
public static
String
asString(Object
o);
arguments:
========== =======
``Object`` **o**
========== =======
public static
String
toJson(Object
ob);
arguments:
========== ========
``Object`` **ob**
========== ========
public static
void
appendKey(StringBuilder
sb,String
key,Object
value);
arguments:
================= ===========
``StringBuilder`` **sb**
``String`` **key**
``Object`` **value**
================= ===========
public
String
getMessage();
public
String
getMessageHash();
public
String
getSignature();
public
String
getR();
public
String
getS();
public
long
getV();
a simple Storage Provider storing the cache in the temp-folder.
returns a item from cache ()
public
byte[]
getItem(String
key);
arguments:
========== ========= ====================
``String`` **key** the key for the item
========== ========= ====================
returns: byte[]
: the bytes or null if not found.
stores a item in the cache.
arguments:
========== ============= ====================
``String`` **key** the key for the item
``byte[]`` **content** the value to store
========== ============= ====================
clear the cache.
public
boolean
clear();
The enum type contains the following values:
============== =
**eth_sign** 0
**raw** 1
**hash** 2
============== =
a Interface responsible for signing data or transactions.
optiional method which allows to change the transaction-data before sending it.
This can be used for redirecting it through a multisig.
public
TransactionRequest
prepareTransaction(IN3
in3,TransactionRequest
tx);
arguments:
================================================= =========
`IN3 <#class-in3>`_ **in3**
`TransactionRequest <#class-transactionrequest>`_ **tx**
================================================= =========
returns true if the account is supported (or unlocked)
public
boolean
canSign(String
address);
arguments:
========== =============
``String`` **address**
========== =============
signing of the raw data.
arguments:
========== =============
``String`` **data**
``String`` **address**
========== =============
Provider methods to cache data.
These data could be nodelists, contract codes or validator changes.
returns a item from cache ()
public
byte[]
getItem(String
key);
arguments:
========== ========= ====================
``String`` **key** the key for the item
========== ========= ====================
returns: byte[]
: the bytes or null if not found.
stores a item in the cache.
arguments:
========== ============= ====================
``String`` **key** the key for the item
``byte[]`` **content** the value to store
========== ============= ====================
clear the cache.
public
boolean
clear();