API Reference Dotnet¶
Dotnet bindings and library for in3. Go to our readthedocs page for more on usage.
This library is based on the C version of Incubed.
Runtimes¶
Since this is built on top of the native library, it is limited to the followin runtimes (RID)
- osx-x64
- linux-x86
- linux-x64
- win-x64
- linux-arm64
For more information, see Rid Catalog.
Examples¶
CallSmartContractFunction¶
source : in3-c/dotnet/Examples/CallSmartContractFunction//CallSmartContractFunction
using System;
using System.Numerics;
using System.Threading.Tasks;
using In3;
using In3.Configuration;
using In3.Eth1;
using In3.Utils;
namespace CallSmartContractFunction
{
public class Program
{
public static async Task Main()
{
// Set it to mainnet
IN3 mainnetClient = IN3.ForChain(Chain.Mainnet);
ClientConfiguration cfg = mainnetClient.Configuration;
cfg.Proof = Proof.Standard;
string contractAddress = "0x2736D225f85740f42D17987100dc8d58e9e16252";
// Create the query transaction
TransactionRequest serverCountQuery = new TransactionRequest();
serverCountQuery.To = contractAddress;
// Define the function and the parameters to query the total in3 servers
serverCountQuery.Function = "totalServers():uint256";
serverCountQuery.Params = new object[0];
string[] serverCountResult = (string[])await mainnetClient.Eth1.Call(serverCountQuery, BlockParameter.Latest);
BigInteger servers = DataTypeConverter.HexStringToBigint(serverCountResult[0]);
for (int i = 0; i < servers; i++)
{
TransactionRequest serverDetailQuery = new TransactionRequest();
serverDetailQuery.To = contractAddress;
// Define the function and the parameters to query the in3 servers detail
serverDetailQuery.Function = "servers(uint256):(string,address,uint32,uint256,uint256,address)";
serverDetailQuery.Params = new object[] { i }; // index of the server (uint256) as per solidity function signature
string[] serverDetailResult = (string[])await mainnetClient.Eth1.Call(serverDetailQuery, BlockParameter.Latest);
Console.Out.WriteLine($"Server url: {serverDetailResult[0]}");
}
}
}
}
ConnectToEthereum¶
source : in3-c/dotnet/Examples/ConnectToEthereum//ConnectToEthereum
using System;
using System.Numerics;
using System.Threading.Tasks;
using In3;
namespace ConnectToEthereum
{
class Program
{
static async Task Main()
{
Console.Out.WriteLine("Ethereum Main Network");
IN3 mainnetClient = IN3.ForChain(Chain.Mainnet);
BigInteger mainnetLatest = await mainnetClient.Eth1.BlockNumber();
BigInteger mainnetCurrentGasPrice = await mainnetClient.Eth1.GetGasPrice();
Console.Out.WriteLine($"Latest Block Number: {mainnetLatest}");
Console.Out.WriteLine($"Gas Price: {mainnetCurrentGasPrice} Wei");
Console.Out.WriteLine("Ethereum Kovan Test Network");
IN3 kovanClient = IN3.ForChain(Chain.Kovan);
BigInteger kovanLatest = await kovanClient.Eth1.BlockNumber();
BigInteger kovanCurrentGasPrice = await kovanClient.Eth1.GetGasPrice();
Console.Out.WriteLine($"Latest Block Number: {kovanLatest}");
Console.Out.WriteLine($"Gas Price: {kovanCurrentGasPrice} Wei");
Console.Out.WriteLine("Ethereum Goerli Test Network");
IN3 goerliClient = IN3.ForChain(Chain.Goerli);
BigInteger goerliLatest = await goerliClient.Eth1.BlockNumber();
BigInteger clientCurrentGasPrice = await goerliClient.Eth1.GetGasPrice();
Console.Out.WriteLine($"Latest Block Number: {goerliLatest}");
Console.Out.WriteLine($"Gas Price: {clientCurrentGasPrice} Wei");
}
}
}
EnsResolver¶
source : in3-c/dotnet/Examples/EnsResolver//EnsResolver
using System;
using System.Threading.Tasks;
using In3;
namespace EnsResolver
{
public class Program
{
static async Task Main()
{
IN3 in3 = IN3.ForChain(Chain.Mainnet);
string cryptoKittiesDomain = "cryptokitties.eth";
string resolver = await in3.Eth1.Ens(cryptoKittiesDomain, ENSParameter.Resolver);
string owner = await in3.Eth1.Ens(cryptoKittiesDomain, ENSParameter.Owner);
Console.Out.WriteLine($"The owner of {cryptoKittiesDomain} is {owner}, resolver is {resolver}.");
}
}
}
Ipfs¶
source : in3-c/dotnet/Examples/Ipfs//Ipfs
using System;
using System.Text;
using System.Threading.Tasks;
using In3;
namespace Ipfs
{
class Program
{
static async Task Main()
{
// Content to be stored
string toStore = "LOREM_IPSUM";
// Connect to ipfs.
IN3 ipfsClient = IN3.ForChain(Chain.Ipfs);
// Store the hash since it will be needed to fetch the content back.
string hash = await ipfsClient.Ipfs.Put(toStore);
//
byte[] storedBytes = await ipfsClient.Ipfs.Get(hash);
string storedStging = Encoding.UTF8.GetString(storedBytes, 0, storedBytes.Length);
Console.Out.WriteLine($"The stored string is: {storedStging}");
}
}
}
Logs¶
source : in3-c/dotnet/Examples/Logs//Logs
using System;
using System.Threading;
using System.Threading.Tasks;
using In3;
using In3.Eth1;
namespace Logs
{
class Program
{
static async Task Main()
{
// Define an upper limit for poll since we dont want our application potentially running forever.
int maxIterations = 500;
int oneSecond = 1000; // in ms
// Connect to mainnet.
IN3 mainnetClient = IN3.ForChain(Chain.Mainnet);
// Create a filter object pointing, in this case, to an "eventful" contract address.
LogFilter tetherUsFilter = new LogFilter {Address = "0xdAC17F958D2ee523a2206206994597C13D831ec7"};
// Create the filter to be polled for logs.
long filterId = await mainnetClient.Eth1.NewLogFilter(tetherUsFilter);
// Loop to initiate the poll for the logs.
for (int i = 0; i < maxIterations; i++)
{
// Query for the log events since the creation of the filter or the previous poll (this method in NOT idempotent as it retrieves a diff).
Log[] tetherLogs = await mainnetClient.Eth1.GetFilterChangesFromLogs(filterId);
if (tetherLogs.Length > 0)
{
Console.Out.WriteLine("Logs found: " + tetherLogs.Length);
break;
}
// Wait before next query.
Thread.Sleep(oneSecond);
}
}
}
}
SendTransaction¶
source : in3-c/dotnet/Examples/SendTransaction//SendTransaction
using System;
using System.Threading;
using System.Threading.Tasks;
using In3;
using In3.Crypto;
using In3.Eth1;
namespace SendTransaction
{
public class Program
{
static async Task Main()
{
IN3 goerliClient = IN3.ForChain(Chain.Goerli);
string myPrivateKey = "0x0829B3C639A3A8F2226C8057F100128D4F7AE8102C92048BA6DE38CF4D3BC6F1";
string receivingAddress = "0x6FA33809667A99A805b610C49EE2042863b1bb83";
// Get the wallet, which is the default signer.
SimpleWallet myAccountWallet = (SimpleWallet)goerliClient.Signer;
string myAccount = myAccountWallet.AddRawKey(myPrivateKey);
// Create the transaction request
TransactionRequest transferWei = new TransactionRequest();
transferWei.To = receivingAddress;
transferWei.From = myAccount;
transferWei.Value = 300;
// Get the current gas prices
long currentGasPrice = await goerliClient.Eth1.GetGasPrice();
transferWei.GasPrice = currentGasPrice;
long estimatedSpentGas = await goerliClient.Eth1.EstimateGas(transferWei, BlockParameter.Latest);
Console.Out.WriteLine($"Estimated gas to spend: {estimatedSpentGas}");
string transactionHash = await goerliClient.Eth1.SendTransaction(transferWei);
Console.Out.WriteLine($"Transaction {transactionHash} sent.");
Thread.Sleep(30000);
TransactionReceipt receipt = await goerliClient.Eth1.GetTransactionReceipt(transactionHash);
Console.Out.WriteLine($"Transaction {transactionHash} mined on block {receipt.BlockNumber}.");
}
}
}
Build Examples¶
To setup and run the example projects, simply run on the respective project folder:
dotnet run
To build all of them, on the solution folder, run:
dotnet build
Index¶
- Account
- Api
- Api
- Api
- Api
- GetBlockBytes(blockHash)
- GetBlockHeader(blockHash)
- GetBlockHeaderBytes(blockHash)
- GetBlockWithTxData(blockHash)
- GetBlockWithTxIds(blockHash)
- GetTransaction(txid)
- GetTransactionBytes(txid)
- DecryptKey(pk,passphrase)
- EcRecover(signedData,signature,signatureType)
- Pk2Address(pk)
- Pk2Public(pk)
- Sha3(data)
- SignData(msg,pk,sigType)
- AbiDecode(signature,encodedData)
- AbiEncode(signature,args)
- BlockNumber()
- Call(request,blockNumber)
- ChecksumAddress(address,shouldUseChainId)
- Ens(name,type)
- EstimateGas(request,blockNumber)
- GetBalance(address,blockNumber)
- GetBlockByHash(blockHash,shouldIncludeTransactions)
- GetBlockByNumber(blockNumber,shouldIncludeTransactions)
- GetBlockTransactionCountByHash(blockHash)
- GetBlockTransactionCountByNumber(blockNumber)
- GetChainId()
- GetCode(address,blockNumber)
- GetFilterChangesFromLogs(filterId)
- GetFilterLogs(filterId)
- GetGasPrice()
- GetLogs(filter)
- GetStorageAt(address,position,blockNumber)
- GetTransactionByBlockHashAndIndex(blockHash,index)
- GetTransactionByBlockNumberAndIndex(blockNumber,index)
- GetTransactionByHash(transactionHash)
- GetTransactionCount(address,blockNumber)
- GetTransactionReceipt(transactionHash)
- GetUncleByBlockNumberAndIndex(blockNumber,position)
- GetUncleCountByBlockHash(blockHash)
- GetUncleCountByBlockNumber(blockNumber)
- NewBlockFilter()
- NewLogFilter(filter)
- SendRawTransaction(transactionData)
- SendTransaction(tx)
- UninstallFilter(filterId)
- Get(multihash)
- Put(content)
- Put(content)
- BaseConfiguration
- Block
- BlockHeader
- BlockParameter
- Block`1
- Chain
- ChainConfiguration
- ClientConfiguration
- Context
- DataTypeConverter
- DefaultTransport
- ENSParameter
- IN3
- InMemoryStorage
- Log
- LogFilter
- NodeConfiguration
- Proof
- Props
- RpcException
- ScriptPubKey
- ScriptSig
- SignatureType
- SignedData
- Signer
- SimpleWallet
- Storage
- Transaction
- Transaction
- TransactionBlock
- TransactionHashBlock
- TransactionInput
- TransactionOutput
- TransactionReceipt
- TransactionRequest
- Transport
Account type
¶
In3.Crypto
Composite entity that holds address and public key. It represents and Ethereum acount. Entity returned from EcRecover.
Api type
¶
In3.Crypto
Class that exposes utility methods for cryptographic utilities. Relies on IN3 functionality.
Api type
¶
In3.Eth1
Module based on Ethereum’s api and web3. Works as a general parent for all Ethereum-specific operations.
Api type
¶
In3.Ipfs
API for ipfs realted methods. To be used along with Ipfs on IN3. Ipfs stands for and is a peer-to-peer hypermedia protocol designed to make the web faster, safer, and more open.
GetBlockBytes(blockHash) method
¶
Retrieves the serialized block in bytes.
Returns¶
The bytes of the block.
Parameters¶
- System.String blockHash - The hash of the Block.
Example¶
byte[] blockBytes = in3.Btc.GetBlockBytes("000000000000000000064ba7512ecc70cabd7ed17e31c06f2205d5ecdadd6d22");
GetBlockHeader(blockHash) method
¶
Retrieves the blockheader.
Returns¶
The Block header.
Parameters¶
- System.String blockHash - The hash of the Block.
Example¶
BlockHeader header = in3.Btc.GetBlockHeader("0000000000000000000cd3c5d7638014e78a5fba33be5fa5cb10ef9f03d99e60");
GetBlockHeaderBytes(blockHash) method
¶
Retrieves the byte array representing teh serialized blockheader data.
Returns¶
The Block header in bytes.
Parameters¶
- System.String blockHash - The hash of the Block.
Example¶
byte[] header = in3.Btc.GetBlockHeaderBytes("0000000000000000000cd3c5d7638014e78a5fba33be5fa5cb10ef9f03d99e60");
GetBlockWithTxData(blockHash) method
¶
Retrieves the block including the full transaction data. Use GetBlockWithTxIds for only the transaction ids.
Parameters¶
- System.String blockHash - The hash of the Block.
Example¶
Block{Transaction} block = in3.Btc.GetBlockWithTxData("000000000000000000064ba7512ecc70cabd7ed17e31c06f2205d5ecdadd6d22");
Transaction t1 = block.Tx[0];
GetBlockWithTxIds(blockHash) method
¶
Retrieves the block including only transaction ids. Use GetBlockWithTxData for the full transaction data.
Parameters¶
- System.String blockHash - The hash of the Block.
Example¶
Block{string} block = in3.Btc.GetBlockWithTxIds("000000000000000000064ba7512ecc70cabd7ed17e31c06f2205d5ecdadd6d22");
string t1 = block.Tx[0];
GetTransaction(txid) method
¶
Retrieves the transaction and returns the data as json.
Returns¶
The transaction object.
Parameters¶
- System.String txid - The transaction Id.
Example¶
Transaction desiredTransaction = in3.Btc.GetTransaction("1427c7d1698e61afe061950226f1c149990b8c1e1b157320b0c4acf7d6b5605d");
GetTransactionBytes(txid) method
¶
Retrieves the serialized transaction (bytes).
Returns¶
The byte array for the Transaction.
Parameters¶
- System.String txid - The transaction Id.
Example¶
byte[] serializedTransaction = in3.Btc.GetTransactionBytes("1427c7d1698e61afe061950226f1c149990b8c1e1b157320b0c4acf7d6b5605d");
EcRecover(signedData,signature,signatureType) method
¶
Recovers the account associated with the signed data.
Returns¶
The account.
Parameters¶
- System.String signedData - Data that was signed with.
- System.String signature - The signature.
- In3.Crypto.SignatureType signatureType - One of SignatureType.
Pk2Address(pk) method
¶
Derives an address from the given private (pk
) key using SHA-3 algorithm.
Returns¶
The address.
Pk2Public(pk) method
¶
Derives public key from the given private (pk
) key using SHA-3 algorithm.
Returns¶
The public key.
SignData(msg,pk,sigType) method
¶
Signs the data msg
with a given private key. Refer to SignedData for more information.
Returns¶
The signed data.
Parameters¶
- System.String msg - Data to be signed.
- System.String pk - Private key.
- In3.Crypto.SignatureType sigType - Type of signature, one of SignatureType.
AbiDecode(signature,encodedData) method
¶
ABI decoder. Used to parse rpc responses from the EVM. Based on the Solidity specification .
Returns¶
The decoded argugments for the function call given the encded data.
Parameters¶
- System.String signature - Function signature i.e. or . In case of the latter, the function signature will be ignored and only the return types will be parsed.
- System.String encodedData - Abi encoded values. Usually the string returned from a rpc to the EVM.
AbiEncode(signature,args) method
¶
ABI encoder. Used to serialize a rpc to the EVM. Based on the Solidity specification . Note: Parameters refers to the list of variables in a method declaration. Arguments are the actual values that are passed in when the method is invoked. When you invoke a method, the arguments used must match the declaration’s parameters in type and order.
Returns¶
The encoded data.
Parameters¶
- System.String signature - Function signature, with parameters. i.e. , can contain the return types but will be ignored.
- System.Object[] args - Function parameters, in the same order as in passed on to .
BlockNumber() method
¶
Returns the number of the most recent block the in3 network can collect signatures to verify.
Can be changed by ReplaceLatestBlock.
If you need the very latest block, change SignatureCount to 0
.
Returns¶
The number of the block.
Call(request,blockNumber) method
¶
Calls a smart-contract method. Will be executed locally by Incubed’s EVM or signed and sent over to save the state changes. Check https://ethereum.stackexchange.com/questions/3514/how-to-call-a-contract-method-using-the-eth-call-json-rpc-api for more.
Returns¶
Ddecoded result. If only one return value is expected the Object will be returned, if not an array of objects will be the result.
Parameters¶
- In3.Eth1.TransactionRequest request - The transaction request to be processed.
- System.Numerics.BigInteger blockNumber - Block number or Latest or Earliest.
ChecksumAddress(address,shouldUseChainId) method
¶
Will convert an upper or lowercase Ethereum address
to a checksum address, that uses case to encode values.
See EIP55.
Returns¶
EIP-55 compliant, mixed-case address.
Parameters¶
- System.String address - Ethereum address.
- System.Nullable{System.Boolean} shouldUseChainId - If
true
, the chain id is integrated as well. Default beingfalse
.
Ens(name,type) method
¶
Resolves ENS domain name.
Returns¶
The resolved entity for the domain.
Parameters¶
- System.String name - ENS domain name.
- In3.ENSParameter type - One of ENSParameter.
EstimateGas(request,blockNumber) method
¶
Gas estimation for transaction. Used to fill transaction.gas field. Check RawTransaction docs for more on gas.
Returns¶
Estimated gas in Wei.
Parameters¶
- In3.Eth1.TransactionRequest request - The transaction request whose cost will be estimated.
- System.Numerics.BigInteger blockNumber - Block number or Latest or Earliest.
GetBalance(address,blockNumber) method
¶
Returns the balance of the account of given address
.
Returns¶
The current balance in wei.
Parameters¶
- System.String address - Address to check for balance.
- System.Numerics.BigInteger blockNumber - Block number or Latest or Earliest.
GetBlockByHash(blockHash,shouldIncludeTransactions) method
¶
Blocks can be identified by root hash of the block merkle tree (this), or sequential number in which it was mined GetBlockByNumber.
Parameters¶
- System.String blockHash - Desired block hash.
- System.Boolean shouldIncludeTransactions - If true, returns the full transaction objects, otherwise only its hashes. The default value is
false
.
Remarks¶
Returning Block must be cast to TransactionBlock or TransactionHashBlock to access the transaction data.
GetBlockByNumber(blockNumber,shouldIncludeTransactions) method
¶
Blocks can be identified by sequential number in which it was mined, or root hash of the block merkle tree GetBlockByHash.
Parameters¶
- System.Numerics.BigInteger blockNumber - Desired block number or Latest or Earliest.
- System.Boolean shouldIncludeTransactions - If
true
, returns the full transaction objects, otherwise only its hashes. The default value istrue
.
Example¶
TransactionBlock latest = (TransactionBlock) _client.Eth1.GetBlockByNumber(BlockParameter.Latest, true);
TransactionHashBlock earliest = (TransactionHashBlock) _client.Eth1.GetBlockByNumber(BlockParameter.Earliest, false);
Remarks¶
Returning Block must be cast to TransactionBlock or TransactionHashBlock to access the transaction data.
GetBlockTransactionCountByHash(blockHash) method
¶
The total transactions on a block. See also GetBlockTransactionCountByNumber.
Returns¶
The number (count) of Transaction.
GetBlockTransactionCountByNumber(blockNumber) method
¶
The total transactions on a block. See also GetBlockTransactionCountByHash.
Returns¶
The number (count) of Transaction.
GetCode(address,blockNumber) method
¶
Smart-Contract bytecode in hexadecimal. If the account is a simple wallet the function will return ‘0x’.
Returns¶
Smart-Contract bytecode in hexadecimal.
Parameters¶
- System.String address - Ethereum address.
- System.Numerics.BigInteger blockNumber - Block number or Latest or Earliest.
GetFilterChangesFromLogs(filterId) method
¶
Retrieve the logs for a certain filter. Logs marks changes of state on the chan for events. Equivalent to GetFilterLogs.
Returns¶
Array of logs which occurred since last poll.
Parameters¶
- System.Int64 filterId - Id returned during the filter creation.
Remarks¶
Since the return is the since last poll, executing this multiple times changes the state making this a “non-idempotent” getter.
GetFilterLogs(filterId) method
¶
Retrieve the logs for a certain filter. Logs marks changes of state on the blockchain for events. Equivalent to GetFilterChangesFromLogs.
Returns¶
Array of logs which occurred since last poll.
Parameters¶
- System.Int64 filterId - Id returned during the filter creation.
Remarks¶
Since the return is the Log[]
since last poll, executing this multiple times changes the state making this a “non-idempotent” getter.
GetGasPrice() method
¶
The current gas price in Wei (1 ETH equals 1000000000000000000 Wei ).
Returns¶
The gas price.
GetLogs(filter) method
¶
Retrieve the logs for a certain filter. Logs marks changes of state on the blockchain for events. Unlike GetFilterChangesFromLogs or GetFilterLogs this is made to be used in a non-incremental manner (aka no poll) and will return the Logs that satisfy the filter condition.
Returns¶
Logs that satisfy the filter
.
GetStorageAt(address,position,blockNumber) method
¶
Stored value in designed position at a given address
. Storage can be used to store a smart contract state, constructor or just any data.
Each contract consists of a EVM bytecode handling the execution and a storage to save the state of the contract.
Returns¶
Stored value in designed position.
Parameters¶
- System.String address - Ethereum account address.
- System.Numerics.BigInteger position - Position index, 0x0 up to 100.
- System.Numerics.BigInteger blockNumber - Block number or Latest or Earliest.
GetTransactionByBlockHashAndIndex(blockHash,index) method
¶
Transactions can be identified by root hash of the transaction merkle tree (this) or by its position in the block transactions merkle tree. Every transaction hash is unique for the whole chain. Collision could in theory happen, chances are 67148E-63%. See also GetTransactionByBlockNumberAndIndex.
Returns¶
The Transaction (if it exists).
Parameters¶
- System.String blockHash - Desired block hash.
- System.Int32 index - The index of the Transaction in a Block
GetTransactionByBlockNumberAndIndex(blockNumber,index) method
¶
Transactions can be identified by root hash of the transaction merkle tree (this) or by its position in the block transactions merkle tree. Every transaction hash is unique for the whole chain. Collision could in theory happen, chances are 67148E-63%.
Returns¶
The Transaction (if it exists).
Parameters¶
- System.Numerics.BigInteger blockNumber - Block number or Latest or Earliest.
- System.Int32 index - The index of the Transaction in a Block
GetTransactionByHash(transactionHash) method
¶
Transactions can be identified by root hash of the transaction merkle tree (this) or by its position in the block transactions merkle tree. Every transaction hash is unique for the whole chain. Collision could in theory happen, chances are 67148E-63%.
Returns¶
The Transaction (if it exists).
GetTransactionCount(address,blockNumber) method
¶
Number of transactions mined from this address
. Used to set transaction nonce.
Nonce is a value that will make a transaction fail in case it is different from (transaction count + 1).
It exists to mitigate replay attacks.
Returns¶
Number of transactions mined from this address.
Parameters¶
- System.String address - Ethereum account address.
- System.Numerics.BigInteger blockNumber - Block number or Latest or Earliest.
GetTransactionReceipt(transactionHash) method
¶
After a transaction is received the by the client, it returns the transaction hash. With it, it is possible to gather the receipt, once a miner has mined and it is part of an acknowledged block. Because how it is possible, in distributed systems, that data is asymmetric in different parts of the system, the transaction is only “final” once a certain number of blocks was mined after it, and still it can be possible that the transaction is discarded after some time. But, in general terms, it is accepted that after 6 to 8 blocks from latest, that it is very likely that the transaction will stay in the chain.
Returns¶
The mined transaction data including event logs.
GetUncleByBlockNumberAndIndex(blockNumber,position) method
¶
Retrieve the of uncle of a block for the given blockNumber
and a position. Uncle blocks are valid blocks and are mined in a genuine manner, but get rejected from the main blockchain.
Returns¶
The uncle block.
Parameters¶
- System.Numerics.BigInteger blockNumber - Block number or Latest or Earliest.
- System.Int32 position - Position of the block.
GetUncleCountByBlockHash(blockHash) method
¶
Retrieve the total of uncles of a block for the given blockHash
. Uncle blocks are valid blocks and are mined in a genuine manner, but get rejected from the main blockchain.
See GetUncleCountByBlockNumber.
Returns¶
The number of uncles in a block.
GetUncleCountByBlockNumber(blockNumber) method
¶
Retrieve the total of uncles of a block for the given blockNumber
. Uncle blocks are valid and are mined in a genuine manner, but get rejected from the main blockchain.
See GetUncleCountByBlockHash.
Returns¶
The number of uncles in a block.
NewBlockFilter() method
¶
Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call GetFilterChangesFromLogs. Filters are event catchers running on the Ethereum Client. Incubed has a client-side implementation. An event will be stored in case it is within to and from blocks, or in the block of blockhash, contains a transaction to the designed address, and has a word listed on topics.
Returns¶
The filter id.
Parameters¶
This method has no parameters.
NewLogFilter(filter) method
¶
Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call GetFilterChangesFromLogs. Filters are event catchers running on the Ethereum Client. Incubed has a client-side implementation. An event will be stored in case it is within to and from blocks, or in the block of blockhash, contains a transaction to the designed address, and has a word listed on topics.
Returns¶
The filter id.
Parameters¶
- In3.Eth1.LogFilter filter - Model that holds the data for the filter creation.
SendRawTransaction(transactionData) method
¶
Sends a signed and encoded transaction.
Returns¶
Transaction hash, used to get the receipt and check if the transaction was mined.
Parameters¶
- System.String transactionData - Signed keccak hash of the serialized transaction.
SendTransaction(tx) method
¶
Signs and sends the assigned transaction. The Signer used to sign the transaction is the one set by Signer. Transactions change the state of an account, just the balance, or additionally, the storage and the code. Every transaction has a cost, gas, paid in Wei. The transaction gas is calculated over estimated gas times the gas cost, plus an additional miner fee, if the sender wants to be sure that the transaction will be mined in the latest block.
Returns¶
Transaction hash, used to get the receipt and check if the transaction was mined.
Parameters¶
- In3.Eth1.TransactionRequest tx - All information needed to perform a transaction.
Example¶
SimpleWallet wallet = (SimpleWallet) client.Signer;
TransactionRequest tx = new TransactionRequest();
tx.From = wallet.AddRawKey(pk);;
tx.To = "0x3940256B93c4BE0B1d5931A6A036608c25706B0c";
tx.Gas = 21000;
tx.Value = 100000000;
client.Eth1.SendTransaction(tx);
UninstallFilter(filterId) method
¶
Uninstalls a previously created filter.
Returns¶
The result of the operation, true
on success or false
on failure.
Get(multihash) method
¶
Returns the content associated with specified multihash on success OR on error.
Block type
¶
In3.Eth1
Class that represents as Ethereum block.
ReceiptsRoot property
¶
The roothash of the merkletree containing all transaction receipts of the block.
BlockParameter type
¶
In3
Enum-like class that defines constants to be used with Api.
Latest property
¶
Constant associated with the latest mined block in the chain.
Remarks¶
While the parameter itself is constant the current “latest” block changes everytime a new block is mined. The result of the operations are also related to ReplaceLatestBlock
on ClientConfiguration.
Chain type
¶
In3
Represents the multiple chains supported by Incubed.
Multichain constants
¶
Support for multiple chains, a client can then switch between different chains (but consumes more memory).
ChainConfiguration type
¶
In3.Configuration
Class that represents part of the configuration to be applied on the IN3 (in particular to each chain). This is a child of ClientConfiguration and have many NodeConfiguration.
#ctor(chain,clientConfiguration) constructor
¶
Constructor.
Parameters¶
- In3.Chain chain - One of Chain. The chain that this configuration is related to.
- In3.Configuration.ClientConfiguration clientConfiguration - The configuration for the client whose the chain configuration belongs to.
Example¶
ChainConfiguration goerliConfiguration = new ChainConfiguration(Chain.Goerli, in3Client.Configuration);
NodesConfiguration property
¶
Getter for the list of elements that represent the configuration for each node.
Remarks¶
This is a read-only property. To add configuration for nodes, Use NodeConfiguration constructor.
RegistryId property
¶
Uuid of this incubed network. one chain could contain more than one incubed networks.
ClientConfiguration type
¶
In3.Configuration
Class that represents the configuration to be applied on IN3. Due to the 1-to-1 relationship with the client, this class should never be instantiated. To obtain a reference of the client configuration use Configuration instead.
AutoUpdateList property
¶
If true
the nodelist will be automatically updated. False may compromise data security.
BootWeights property
¶
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.
Finality property
¶
Remarks¶
Beware that the semantics of the values change greatly from chain to chain. The value of 8
would mean 8 blocks mined on top of the requested one while with the POW algorithm while, for POA, it would mean 8% of validators.
MinDeposit property
¶
Only nodes owning at least this amount will be chosen to sign responses to your requests.
NodeProps property
¶
Props define the capabilities of the nodes. Accepts a combination of values.
Proof property
¶
One of Proof. Full gets the whole block Patricia-Merkle-Tree, Standard only verifies the specific tree branch concerning the request, None only verifies the root hashes, like a light-client does.
ReplaceLatestBlock property
¶
Distance considered safe, consensus wise, from the very latest block. Higher values exponentially increases state finality, and therefore data security, as well guaranteeded responses from in3 nodes.
RequestCount property
¶
Useful when SignatureCount is less then 1
. The client will check for consensus in responses.
SignatureCount property
¶
Node signatures attesting the response to your request. Will send a separate request for each.
Context type
¶
In3.Context
Acts as the main orchestrator for the execution of an rpc. Holds a reference to the native context (ctx) and wraps behavior around it.
#ctor(ctx,nativeClient) constructor
¶
Standard constructor, private so people use FromRpc.
Parameters¶
- System.IntPtr ctx - The native rpc context.
- In3.Native.NativeClient nativeClient - Object that encapsulates the native client.
CreateNativeCtx(nativeIn3Ptr,rpc) method
¶
Method to manage the creation of the native ctx request.
Returns¶
Native rpc pointer
Parameters¶
- System.IntPtr nativeIn3Ptr - Native client pointer.
- System.String rpc - The rpc request
Execute() method
¶
Proxy to in3_ctx_execute, every invocation generates a new state.
Returns¶
The state as computed by in3_ctx_execute.
FromRpc(wrapper,rpc) method
¶
Factory-like method to build a Context object from an rpc request.
Returns¶
An instance of context.
Parameters¶
- In3.Native.NativeClient wrapper - The object that encapsulates the native client pointer.
- System.String rpc - The rpc request
GetErrorMessage() method
¶
Retrieve the error result on the context.
Returns¶
A string describing the encountered error.
GetLastWaiting() method
¶
Method responsible to fetch the pending context references in the current context.
Returns¶
A context object.
GetResponse() method
¶
Method to get the consolidated response of a request.
Returns¶
The final result.
HandleRequest() method
¶
Handle rpc request in an asynchronous manner.
HandleSign() method
¶
Handle signing request in an asynchronous manner.
DataTypeConverter type
¶
In3.Utils
General util class for conversion between blockchain types.
HexStringToBigint(source) method
¶
Converts a zero-prefixed hex (e.g.: 0x05) to BigInteger
Returns¶
The number representation of source
.
DefaultTransport type
¶
In3.Transport
Basic implementation for synchronous http transport for Incubed client.
Handle(url,payload) method
¶
Method that handles, sychronously the http requests.
Returns¶
The http json response.
Parameters¶
- System.String url - The url of the node.
- System.String payload - Json for the body of the POST request to the node.
ENSParameter type
¶
In3
Defines the kind of entity associated with the ENS Resolved. Used along with Ens.
IN3 type
¶
In3
Incubed network client. Connect to the blockchain via a list of bootnodes, then gets the latest list of nodes in the network and ask a certain number of the to sign the block header of given list, putting their deposit at stake. Once with the latest list at hand, the client can request any other on-chain information using the same scheme.
Configuration property
¶
Gets ClientConfiguration object. Any changes in the object will be automaticaly applied to the client before each method invocation.
SendRpc(method,args,in3) method
¶
Method used to communicate with the client. In general, its preferably to use the API.
Returns¶
The result of the Rpc operation as JSON.
Parameters¶
- System.String method - Rpc method.
- System.Object[] args - Arguments to the operation.
- System.Collections.Generic.Dictionary{System.String,System.Object} in3 - Internal parameters to be repassed to the server or to change the client behavior.
InMemoryStorage type
¶
In3.Storage
Default implementation of Storage. It caches all cacheable data in memory.
SetItem(key,content) method
¶
Stores a value in memory for a given key.
Parameters¶
- System.String key - A unique identifier for the data that is being cached.
- System.Byte[] content - The value that is being cached.
Log type
¶
In3.Eth1
Logs marks changes of state on the blockchain for events. The Log is a data object with information from logs.
Topics property
¶
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).
TransactionHash property
¶
Hash of the transactions this log was created from. null when its pending log.
LogFilter type
¶
In3.Eth1
Filter configuration for search logs. To be used along with the Api filter and methods.
BlockHash property
¶
Blcok hash of the filtered blocks.
Topics property
¶
Array of 32 Bytes Data topics. Topics are order-dependent. It’s possible to pass in null to match any topic, or a subarray of multiple topics of which one should be matching.
NodeConfiguration type
¶
In3.Configuration
Class that represents part of the configuration to be applied on the IN3 (in particular to each boot node). This is a child of ChainConfiguration.
#ctor(config) constructor
¶
Constructor for the node configuration.
Parameters¶
- In3.Configuration.ChainConfiguration config - The ChainConfiguration of which this node belongs to.
Props property
¶
Props define the capabilities of the node. Accepts a combination of values.
Proof type
¶
In3.Configuration
Alias for verification levels. Verification is done by calculating Ethereum Trie states requested by the Incubed network ans signed as proofs of a certain state.
Props type
¶
In3.Configuration
Enum
that defines the capabilities an incubed node.
NodePropMinblockheight constants
¶
filter out nodes that will sign blocks with lower min block height than specified.
NodePropMultichain constants
¶
filter out nodes other then which have capability of the same RPC endpoint may also accept requests for different chains.
Signer type
¶
In3.Crypto
Minimum interface to be implemented by a kind of signer. Used by SendTransaction. Set it with Signer.
CanSign(account) method
¶
Queries the Signer if it can sign for a certain key.
Returns¶
true
if it can sign, false
if it cant.
Parameters¶
- System.String account - The account derived from the private key used to sign transactions.
Remarks¶
This method is invoked internaly by SendTransaction using From and will throw a SystemException
in case false
is returned.
PrepareTransaction() method
¶
Optional method which allows to change the transaction-data before sending it. This can be used for redirecting it through a multisig. Invoked just before sending a transaction through SendTransaction.
Returns¶
Modified transaction request.
Sign(data,account) method
¶
Signs the transaction data with the private key associated with the invoked account. Both arguments are automaticaly passed by Incubed client base on TransactionRequest data during a SendTransaction.
Returns¶
The signed transaction data.
Parameters¶
- System.String data - Data to be signed.
- System.String account - The account that will sign the transaction.
SimpleWallet type
¶
In3.Crypto
Default implementation of the Signer. Works as an orchestration of the in order to manage multiple accounts.
AddRawKey(privateKey) method
¶
Adds a private key to be managed by the wallet and sign transactions.
Returns¶
The address derived from the privateKey
CanSign(address) method
¶
Check if this address is managed by this wallet.
Returns¶
true
if the address is managed by this wallter, false
if not.
Sign(data,address) method
¶
Signs the transaction data by invoking SignData.
Returns¶
Signed transaction data.
Parameters¶
- System.String data - Data to be signed.
- System.String address - Address managed by the wallet, see AddRawKey
Storage type
¶
In3.Storage
Provider methods to cache data. These data could be nodelists, contract codes or validator changes. Any form of cache should implement Storage and be set with Storage.
Clear() method
¶
Clear the cache.
Returns¶
The result of the operation: true
for success and false
for failure.
SetItem(key,content) method
¶
Stores an item to cache.
Transaction type
¶
In3.Eth1
Class representing a transaction that was accepted by the Ethereum chain.
TransactionBlock type
¶
In3.Eth1
Class that holds a block with its full transaction array: Transaction.
TransactionReceipt type
¶
In3.Eth1
Class that represents a transaction receipt. See GetTransactionReceipt.
BlockNumber property
¶
Number of the block with the transaction which this receipt is associated with.
LogsBloom property
¶
A bloom filter of logs/events generated by contracts during transaction execution. Used to efficiently rule out transactions without expected logs.
Root property
¶
Merkle root of the state trie after the transaction has been executed (optional after Byzantium hard fork EIP609).
TransactionRequest type
¶
In3.Eth1
Class that holds the state for the transaction request to be submited via SendTransaction.
Params property
¶
Array of parameters for the function (in the same order of its signature), see Function
To property
¶
Address to whom the transaction value will be transfered to or the smart contract address whose function will be invoked.
Transport type
¶
In3.Transport
Minimum interface for a custom transport. Transport is a mean of communication with the Incubed server.
Handle(url,payload) method
¶
Method to be implemented that will handle the requests to the server. This method may be called once for each url on each batch of requests.
Returns¶
The rpc response.
Parameters¶
- System.String url - Url of the node.
- System.String payload - Content for the RPC request.