API Reference Java¶
Installing¶
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
Downloading¶
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
.
Building¶
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.
Android¶
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:
Examples¶
CallFunction¶
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]);
}
}
Configure¶
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());
}
}
GetBalance¶
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"});
}
}
GetBlockAPI¶
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");
}
}
GetBlockRPC¶
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);
}
}
GetTransaction¶
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});
}
}
GetTransactionReceipt¶
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});
}
}
SendTransaction¶
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);
}
}
Building¶
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
Package in3¶
class BlockID¶
getNumber¶
publicLong
getNumber();
getHash¶
publicString
getHash();
toJSON¶
publicString
toJSON();
toString¶
publicString
toString();
class Chain¶
Constants for Chain-specs.
MULTICHAIN¶
support for multiple chains, a client can then switch between different chains (but consumes more memory)
Type: static final long
class IN3¶
This is the main class creating the incubed client.
The client can then be configured.
IN3¶
public IN3();
getConfig¶
returns the current configuration.
any changes to the configuration will be applied witth the next request.
publicClientConfiguration
getConfig();
setSigner¶
sets the signer or wallet.
publicvoid
setSigner(Signer
signer);
arguments:
Signer | signer |
setStorageProvider¶
provides the ability to cache content like nodelists, contract codes and validatorlists
publicvoid
setStorageProvider(StorageProvider
val);
arguments:
StorageProvider | val |
getStorageProvider¶
provides the ability to cache content
publicStorageProvider
getStorageProvider();
setTransport¶
sets The transport interface.
This allows to fetch the result of the incubed in a different way.
publicvoid
setTransport(IN3Transport
newTransport);
arguments:
IN3Transport |
newTransport |
getChainId¶
servers to filter for the given chain.
The chain-id based on EIP-155.
publicnative long
getChainId();
setChainId¶
sets the chain to be used.
The chain-id based on EIP-155.
publicnative void
setChainId(long
val);
arguments:
long |
val |
send¶
send a request.
The request must a valid json-string with method and params
publicString
send(String
request);
arguments:
String |
request |
sendobject¶
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
publicObject
sendobject(String
request);
arguments:
String |
request |
sendRPC¶
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 |
sendRPCasObject¶
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 |
sign¶
request for a signature of an already verified hash.
arguments:
BlockID[] | blocks |
String[] |
dataNodeAdresses |
forChain¶
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 |
class IN3DefaultTransport¶
class IN3Node¶
getUrl¶
publicString
getUrl();
getAddress¶
publicString
getAddress();
getIndex¶
publicint
getIndex();
getDeposit¶
publicString
getDeposit();
getProps¶
publiclong
getProps();
getTimeout¶
publicint
getTimeout();
getRegisterTime¶
publicint
getRegisterTime();
getWeight¶
publicint
getWeight();
class IN3Props¶
IN3Props¶
public IN3Props();
toString¶
publicString
toString();
toJSON¶
publicString
toJSON();
class NodeProps¶
NODE_PROP_PROOF¶
Type: static final long
NODE_PROP_MULTICHAIN¶
Type: static final long
NODE_PROP_ARCHIVE¶
Type: static final long
NODE_PROP_HTTP¶
Type: static final long
NODE_PROP_BINARY¶
Type: static final long
NODE_PROP_ONION¶
Type: static final long
NODE_PROP_STATS¶
Type: static final long
class SignedBlockHash¶
getBlockHash¶
publicString
getBlockHash();
getBlock¶
publiclong
getBlock();
getR¶
publicString
getR();
getS¶
publicString
getS();
getV¶
publiclong
getV();
getMsgHash¶
publicString
getMsgHash();
enum Proof¶
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. |
Package in3.btc¶
class API¶
API for handling BitCoin data.
Use it when connected to Chain.BTC.
getTransaction¶
Retrieves the transaction and returns the data as json.
publicTransaction
getTransaction(String
txid);
arguments:
String |
txid |
getTransactionBytes¶
Retrieves the serialized transaction (bytes).
publicbyte[]
getTransactionBytes(String
txid);
arguments:
String |
txid |
getBlockHeader¶
Retrieves the blockheader.
publicBlockHeader
getBlockHeader(String
blockHash);
arguments:
String |
blockHash |
getBlockHeaderBytes¶
Retrieves the byte array representing teh serialized blockheader data.
publicbyte[]
getBlockHeaderBytes(String
blockHash);
arguments:
String |
blockHash |
getBlockWithTxData¶
Retrieves the block including the full transaction data.
Use Api::GetBlockWithTxIds” for only the transaction ids.
arguments:
String |
blockHash |
getBlockWithTxIds¶
Retrieves the block including only transaction ids.
Use Api::GetBlockWithTxData for the full transaction data.
arguments:
String |
blockHash |
class Block¶
A Block.
getTransactionHashes¶
Transactions or Transaction ids of a block.
publicString[]
getTransactionHashes();
class BlockHeader¶
A Block header.
getConfirmations¶
Number of confirmations or blocks mined on top of the containing block.
publiclong
getConfirmations();
getMerkleroot¶
Merkle root of the trie of all transactions in the block.
publicString
getMerkleroot();
class ScriptPubKey¶
Script on a transaction output.
class ScriptSig¶
Script on a transaction input.
class Transaction¶
A BitCoin Transaction.
getHash¶
The transaction hash (differs from txid for witness transactions).
publicString
getHash();
getVsize¶
The virtual transaction size (differs from size for witness transactions).
publiclong
getVsize();
getBlockhash¶
The block hash of the block containing this transaction.
publicString
getBlockhash();
class TransactionInput¶
Input of a transaction.
class TransactionOutput¶
A BitCoin Transaction.
Package in3.config¶
class ChainConfiguration¶
Part of the configuration hierarchy for IN3 Client.
Holds the configuration a node group in a particular Chain.
nodesConfig¶
ChainConfiguration¶
public ChainConfiguration(long
chain,ClientConfiguration
config);
arguments:
long |
chain |
ClientConfiguration | config |
getChain¶
publiclong
getChain();
isNeedsUpdate¶
publicBoolean
isNeedsUpdate();
getContract¶
publicString
getContract();
getRegistryId¶
publicString
getRegistryId();
getWhiteListContract¶
publicString
getWhiteListContract();
setWhiteListContract¶
publicvoid
setWhiteListContract(String
whiteListContract);
arguments:
String |
whiteListContract |
getWhiteList¶
publicString[]
getWhiteList();
toString¶
publicString
toString();
class ClientConfiguration¶
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()
getRequestCount¶
publicInteger
getRequestCount();
setRequestCount¶
sets the number of requests send when getting a first answer
publicvoid
setRequestCount(int
requestCount);
arguments:
int |
requestCount |
isAutoUpdateList¶
publicBoolean
isAutoUpdateList();
setAutoUpdateList¶
activates the auto update.if true the nodelist will be automaticly updated if the lastBlock is newer
publicvoid
setAutoUpdateList(boolean
autoUpdateList);
arguments:
boolean |
autoUpdateList |
getMaxAttempts¶
publicInteger
getMaxAttempts();
setMaxAttempts¶
sets the max number of attempts before giving up
publicvoid
setMaxAttempts(int
maxAttempts);
arguments:
int |
maxAttempts |
getSignatureCount¶
publicInteger
getSignatureCount();
setSignatureCount¶
sets the number of signatures used to proof the blockhash.
publicvoid
setSignatureCount(int
signatureCount);
arguments:
int |
signatureCount |
isStats¶
publicBoolean
isStats();
setStats¶
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.
publicvoid
setStats(boolean
stats);
arguments:
boolean |
stats |
getFinality¶
publicInteger
getFinality();
setFinality¶
sets the number of signatures in percent required for the request
publicvoid
setFinality(int
finality);
arguments:
int |
finality |
isIncludeCode¶
publicBoolean
isIncludeCode();
isBootWeights¶
publicBoolean
isBootWeights();
setBootWeights¶
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.
publicvoid
setBootWeights(boolean
value);
arguments:
boolean |
value |
isKeepIn3¶
publicBoolean
isKeepIn3();
isUseHttp¶
publicBoolean
isUseHttp();
getTimeout¶
publicLong
getTimeout();
setTimeout¶
specifies the number of milliseconds before the request times out.
increasing may be helpful if the device uses a slow connection.
publicvoid
setTimeout(long
timeout);
arguments:
long |
timeout |
getMinDeposit¶
publicLong
getMinDeposit();
setMinDeposit¶
sets min stake of the server.
Only nodes owning at least this amount will be chosen.
publicvoid
setMinDeposit(long
minDeposit);
arguments:
long |
minDeposit |
getNodeProps¶
publicLong
getNodeProps();
getNodeLimit¶
publicLong
getNodeLimit();
setNodeLimit¶
sets the limit of nodes to store in the client.
publicvoid
setNodeLimit(long
nodeLimit);
arguments:
long |
nodeLimit |
getReplaceLatestBlock¶
publicInteger
getReplaceLatestBlock();
setReplaceLatestBlock¶
replaces the latest with blockNumber- specified value
publicvoid
setReplaceLatestBlock(int
replaceLatestBlock);
arguments:
int |
replaceLatestBlock |
getRpc¶
publicString
getRpc();
setRpc¶
setup an custom rpc source for requests by setting Chain to local and proof to none
publicvoid
setRpc(String
rpc);
arguments:
String |
rpc |
getNodesConfig¶
publicChainConfigurationHashMap< Long, , >
getNodesConfig();
markAsSynced¶
publicvoid
markAsSynced();
isSynced¶
publicboolean
isSynced();
toString¶
publicString
toString();
class NodeConfiguration¶
Configuration Object for Incubed Client.
It represents the node of a nodelist.
NodeConfiguration¶
public NodeConfiguration(ChainConfiguration
config);
arguments:
ChainConfiguration | config |
getUrl¶
publicString
getUrl();
getProps¶
publiclong
getProps();
getAddress¶
publicString
getAddress();
toString¶
publicString
toString();
Package in3.eth1¶
class API¶
a Wrapper for the incubed client offering Type-safe Access and additional helper functions.
getBlockByNumber¶
finds the Block as specified by the number.
use Block.LATEST
for getting the lastest block.
arguments:
long |
block | |
boolean |
includeTransactions | < the Blocknumber < if true all Transactions will be includes, if not only the transactionhashes |
getBlockByHash¶
Returns information about a block by hash.
arguments:
String |
blockHash | |
boolean |
includeTransactions | < the Blocknumber < if true all Transactions will be includes, if not only the transactionhashes |
getChainId¶
Returns the EIP155 chain ID used for transaction signing at the current best block.
Null is returned if not available.
publicString
getChainId();
call¶
calls a function of a smart contract and returns the result.
arguments:
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.
estimateGas¶
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.
arguments:
TransactionRequest | request | |
long |
block | < the transaction to call. < the Block used to for the state. |
returns: long
: the gas required to call the function.
getBalance¶
Returns the balance of the account of given address in wei.
arguments:
String |
address |
long |
block |
getStorageAt¶
Returns the value from a storage position at a given address.
arguments:
String |
address |
BigInteger |
position |
long |
block |
getBlockTransactionCountByHash¶
Returns the number of transactions in a block from a block matching the given block hash.
publiclong
getBlockTransactionCountByHash(String
blockHash);
arguments:
String |
blockHash |
getBlockTransactionCountByNumber¶
Returns the number of transactions in a block from a block matching the given block number.
publiclong
getBlockTransactionCountByNumber(long
block);
arguments:
long |
block |
getFilterChangesFromLogs¶
Polling method for a filter, which returns an array of logs which occurred since last poll.
arguments:
long |
id |
getFilterChangesFromBlocks¶
Polling method for a filter, which returns an array of logs which occurred since last poll.
publicString[]
getFilterChangesFromBlocks(long
id);
arguments:
long |
id |
getFilterLogs¶
Polling method for a filter, which returns an array of logs which occurred since last poll.
arguments:
long |
id |
getLogs¶
Polling method for a filter, which returns an array of logs which occurred since last poll.
arguments:
LogFilter | filter |
getTransactionByBlockHashAndIndex¶
Returns information about a transaction by block hash and transaction index position.
arguments:
String |
blockHash |
int |
index |
getTransactionByBlockNumberAndIndex¶
Returns information about a transaction by block number and transaction index position.
arguments:
long |
block |
int |
index |
getTransactionByHash¶
Returns the information about a transaction requested by transaction hash.
publicTransaction
getTransactionByHash(String
transactionHash);
arguments:
String |
transactionHash |
getTransactionCount¶
Returns the number of transactions sent from an address.
arguments:
String |
address |
long |
block |
getTransactionReceipt¶
Returns the number of transactions sent from an address.
publicTransactionReceipt
getTransactionReceipt(String
transactionHash);
arguments:
String |
transactionHash |
getUncleByBlockNumberAndIndex¶
Returns information about a uncle of a block number and uncle index position.
Note: An uncle doesn’t contain individual transactions.
arguments:
long |
block |
int |
pos |
getUncleCountByBlockHash¶
Returns the number of uncles in a block from a block matching the given block hash.
publiclong
getUncleCountByBlockHash(String
block);
arguments:
String |
block |
getUncleCountByBlockNumber¶
Returns the number of uncles in a block from a block matching the given block hash.
publiclong
getUncleCountByBlockNumber(long
block);
arguments:
long |
block |
newBlockFilter¶
Creates a filter in the node, to notify when a new block arrives.
To check if the state has changed, call eth_getFilterChanges.
publiclong
newBlockFilter();
newLogFilter¶
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)”
publiclong
newLogFilter(LogFilter
filter);
arguments:
LogFilter | filter |
uninstallFilter¶
uninstall filter.
publicboolean
uninstallFilter(long
filter);
arguments:
long |
filter |
sendRawTransaction¶
Creates new message call transaction or a contract creation for signed transactions.
publicString
sendRawTransaction(String
data);
arguments:
String |
data |
returns: String
: transactionHash
abiEncode¶
encodes the arguments as described in the method signature using ABI-Encoding.
arguments:
String |
signature |
String[] |
params |
checksumAddress¶
converts the given address to a checksum address.
publicString
checksumAddress(String
address);
arguments:
String |
address |
checksumAddress¶
converts the given address to a checksum address.
Second parameter includes the chainId.
arguments:
String |
address |
Boolean |
useChainId |
ens¶
resolve ens-name.
Second parameter especifies if it is an address, owner, resolver or hash.
arguments:
String |
name |
ENSMethod | type |
sendTransaction¶
sends a Transaction as described by the TransactionRequest.
This will require a signer to be set in order to sign the transaction.
publicString
sendTransaction(TransactionRequest
tx);
arguments:
TransactionRequest | tx |
class Block¶
represents a Block in ethereum.
getTotalDifficulty¶
returns the total Difficulty as a sum of all difficulties starting from genesis.
publicBigInteger
getTotalDifficulty();
getTransactionsRoot¶
the roothash of the merkletree containing all transaction of the block.
publicString
getTransactionsRoot();
getTransactionReceiptsRoot¶
the roothash of the merkletree containing all transaction receipts of the block.
publicString
getTransactionReceiptsRoot();
getStateRoot¶
the roothash of the merkletree containing the complete state.
publicString
getStateRoot();
getTransactionHashes¶
the transaction hashes of the transactions in the block.
publicString[]
getTransactionHashes();
getSha3Uncles¶
the roothash of the merkletree containing all uncles of the block.
publicString
getSha3Uncles();
hashCode¶
publicint
hashCode();
class Log¶
a log entry of a transaction receipt.
isRemoved¶
true when the log was removed, due to a chain reorganization.
false if its a valid log.
publicboolean
isRemoved();
getLogIndex¶
integer of the log index position in the block.
null when its pending log.
publicint
getLogIndex();
gettTansactionIndex¶
integer of the transactions index position log was created from.
null when its pending log.
publicint
gettTansactionIndex();
getTransactionHash¶
Hash, 32 Bytes - hash of the transactions this log was created from.
null when its pending log.
publicString
getTransactionHash();
getBlockHash¶
Hash, 32 Bytes - hash of the block where this log was in.
null when its pending. null when its pending log.
publicString
getBlockHash();
getBlockNumber¶
the block number where this log was in.
null when its pending. null when its pending log.
publiclong
getBlockNumber();
getTopics¶
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.)
publicString[]
getTopics();
class LogFilter¶
Log configuration for search logs.
getFromBlock¶
publiclong
getFromBlock();
getToBlock¶
publiclong
getToBlock();
getAddress¶
publicString
getAddress();
getTopics¶
publicObject[]
getTopics();
getLimit¶
publicint
getLimit();
class SimpleWallet¶
a simple Implementation for holding private keys to sing data or transactions.
addRawKey¶
adds a key to the wallet and returns its public address.
publicString
addRawKey(String
data);
arguments:
String |
data |
addKeyStore¶
adds a key to the wallet and returns its public address.
arguments:
String |
jsonData |
String |
passphrase |
prepareTransaction¶
optiional method which allows to change the transaction-data before sending it.
This can be used for redirecting it through a multisig.
arguments:
IN3 | in3 |
TransactionRequest | tx |
class Transaction¶
represents a Transaction in ethereum.
getBlockNumber¶
the block number of the block containing this transaction.
publiclong
getBlockNumber();
getCreatedContractAddress¶
the address of the deployed contract (if successfull)
publicString
getCreatedContractAddress();
getSignature¶
the signature of the sender - a array of the [ r, s, v]
publicString[]
getSignature();
class TransactionReceipt¶
represents a Transaction receipt in ethereum.
getBlockNumber¶
the block number of the block containing this transaction.
publiclong
getBlockNumber();
getCreatedContractAddress¶
the address of the deployed contract (if successfull)
publicString
getCreatedContractAddress();
getTo¶
20 Bytes - The address of the receiver.
null when it’s a contract creation transaction.
publicString
getTo();
getLogsBloom¶
256 Bytes - A bloom filter of logs/events generated by contracts during transaction execution.
Used to efficiently rule out transactions without expected logs
publicString
getLogsBloom();
getRoot¶
32 Bytes - Merkle root of the state trie after the transaction has been executed (optional after Byzantium hard fork EIP609).
publicString
getRoot();
getStatus¶
success of a Transaction.
true indicates transaction failure , false indicates transaction success. Set for blocks mined after Byzantium hard fork EIP609, null before.
publicboolean
getStatus();
class TransactionRequest¶
represents a Transaction Request which should be send or called.
getFrom¶
publicString
getFrom();
getTo¶
publicString
getTo();
getValue¶
publicBigInteger
getValue();
getNonce¶
publiclong
getNonce();
getGas¶
publiclong
getGas();
getGasPrice¶
publiclong
getGasPrice();
getFunction¶
publicString
getFunction();
getParams¶
publicObject[]
getParams();
getTransactionJson¶
publicString
getTransactionJson();
Package in3.ipfs¶
class API¶
API for ipfs custom methods.
To be used along with “Chain.IPFS” on in3 instance.
get¶
Returns the content associated with specified multihash on success OR NULL on error.
publicbyte[]
get(String
multihash);
arguments:
String |
multihash |
Package in3.ipfs.API¶
Package in3.utils¶
class Account¶
Pojo that represents the result of an ecrecover operation (see: Crypto class).
class Crypto¶
a Wrapper for crypto-related helper functions.
signData¶
returns a signature given a message and a key.
arguments:
String |
msg |
String |
key |
SignatureType | sigType |
pk2address¶
extracts the public address from a private key.
publicString
pk2address(String
key);
arguments:
String |
key |
pk2public¶
extracts the public key from a private key.
publicString
pk2public(String
key);
arguments:
String |
key |
ecrecover¶
extracts the address and public key from a signature.
arguments:
String |
msg |
String |
sig |
SignatureType | sigType |
class JSON¶
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.
get¶
gets the property
publicObject
get(String
prop);
arguments:
String |
prop | the name of the property. |
returns: Object
: the raw object.
put¶
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 |
getLong¶
returns the property as long
publiclong
getLong(String
key);
arguments:
String |
key | the propertyName |
returns: long
: the long value
getBigInteger¶
returns the property as BigInteger
publicBigInteger
getBigInteger(String
key);
arguments:
String |
key | the propertyName |
returns: BigInteger
: the BigInteger value
getStringArray¶
returns the property as StringArray
publicString[]
getStringArray(String
key);
arguments:
String |
key | the propertyName |
returns: String[]
: the array or null
getString¶
returns the property as String or in case of a number as hexstring.
publicString
getString(String
key);
arguments:
String |
key | the propertyName |
returns: String
: the hexstring
toString¶
publicString
toString();
hashCode¶
publicint
hashCode();
asStringArray¶
casts the object to a String[]
public staticString[]
asStringArray(Object
o);
arguments:
Object |
o |
class Signature¶
getMessage¶
publicString
getMessage();
getMessageHash¶
publicString
getMessageHash();
getSignature¶
publicString
getSignature();
getR¶
publicString
getR();
getS¶
publicString
getS();
getV¶
publiclong
getV();
class TempStorageProvider¶
a simple Storage Provider storing the cache in the temp-folder.
getItem¶
returns a item from cache ()
publicbyte[]
getItem(String
key);
arguments:
String |
key | the key for the item |
returns: byte[]
: the bytes or null if not found.
setItem¶
stores a item in the cache.
arguments:
String |
key | the key for the item |
byte[] |
content | the value to store |
interface Signer¶
a Interface responsible for signing data or transactions.
prepareTransaction¶
optiional method which allows to change the transaction-data before sending it.
This can be used for redirecting it through a multisig.
arguments:
IN3 | in3 |
TransactionRequest | tx |
interface StorageProvider¶
Provider methods to cache data.
These data could be nodelists, contract codes or validator changes.
getItem¶
returns a item from cache ()
publicbyte[]
getItem(String
key);
arguments:
String |
key | the key for the item |
returns: byte[]
: the bytes or null if not found.
setItem¶
stores a item in the cache.
arguments:
String |
key | the key for the item |
byte[] |
content | the value to store |