Skip to content

Latest commit

 

History

History

docs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

minichain

Subjects

Setup

Node
A basic node which cannot create a block.

var node = new EndpointNode();

// There's no `Start` method in `EndpointNode`.

Miner
You can operate mining node if you want to create a block and get mining rewards. Miner node will consume lots of CPU resources.

var node = new Miner();

node.Start();

p2p

Connect to peer

node.peers.AddPeer("ws://localhost:9916");

Chain

Current block (last confirmed block)

var block = node.chain.currentBlock;

var blockNo = block.blockNo;
var nonce = block.nonce; // solution
var difficulty = block.difficulty; // a difficulty number used to mine this block.
var merkleRootHash = block.merkleRootHash;

Retrive balance

var currentBalance = node.chain.GetBalance("ADDRESS");

var balanceAtSpecificBlock = node.chain.GetBalanceInBlock("ADDRESS", "BLOCK_HASH");

Contract

Deploy

var tx = node.wallet.CreateDeployTransaction("PROGRAM", "CTOR_SIGNATURE");
var contractAddress = tx.receiverAddr;
node.SendTransaction(tx);

Call method

var tx = node.wallet.CreateCallTransaction(
  contractAddress, "METHOD_SIGNATURE", 
  new object[] { 10, 20 });
node.SendTransaction(tx);

Read field data

var val = node.chain.GetPublicField(contractAddress, "FIELD_SIGNATURE");

Wallet

Import and Export

// Exports wallet data (this also includes PRIVATE-KEY)
var json = node.wallet.Export();

node.wallet.Import(json);

Retrive balance

var currentBalance = node.wallet.GetBalance();

var balanceAtSpecificBlock = node.wallet.GetBalanceInBlock("BLOCK_HASH");

Create a signed transaction

node.wallet.CreateSignedPaymentTransaction("RECEIVER_ADDR", VALUE_AMOUNT);