Links

QuickStart

Interact with Lightstreams node

As it was mentioned above, Lightstreams node is fully ethereum-compatible therefore ethereum JSON RPC API is also available.
To enable those RPC endpoints, we need to specify the APIs we want to enable and the endpoints. At the command line argument, when Lightstreams node is launched, we need to include --rpc --rpcapi eth,net,web3,personal,admin. In case you want to enable the WebSocket endpoints you have to also use--ws
lightchain run --datadir="${HOME}/.lightchain" --rpc --rpcapi eth,net,web3,personal,admin --ws
By default RPC API is exposed over port :8545 and WebSocket over port :8546. In case you want to specify a different port, you may use the following flags --rpcport ${RPC_PORT} or --wsport ${WS_PORT} respectively.
In addition to those, IPC Unix socket is always enabled and you can find it at ${HOME}/.lightchain/database/geth.ipc (according to the values used on above example)

Example

As it is explained above we can interact with Lightstreams node as we would have been interacting with an Ethereum node. For instance, we could attach a Geth to the running Lightstreams node and create a new account and perform a transfer.
Start interactive Geth console
geth attach http://localhost:8545
Create a new account
> personal.newAccount("passphrase")
"0xe7094bd66363c0442bd99ea00fccb19b0d272453"
Transfer tokens
> eth.sendTransaction({from:eth.accounts[0], to:"0xe7094bd66363c0442bd99ea00fccb19b0d272453", value: web3.toWei(0.05, "ether")})
"0x2ca8bce6a70566a0869a9fd2ac74743e05fe19e17ec118d7a4933f07714faeed"
Read receipt
> eth.getTransactionReceipt("0x2ca8bce6a70566a0869a9fd2ac74743e05fe19e17ec118d7a4933f07714faeed")
{
blockHash: "0xc96707c294c79b7d3667a59e5f097f72375d4b7f0135e0055eabc5e70ddec717",
blockNumber: 17793,
contractAddress: null,
cumulativeGasUsed: 21000,
from: "0xc916cfe5c83dd4fc3c3b0bf2ec2d4e401782875e",
gasUsed: 21000,
logs: [],
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
status: "0x1",
to: "0xe7094bd66363c0442bd99ea00fccb19b0d272453",
transactionHash: "0x2ca8bce6a70566a0869a9fd2ac74743e05fe19e17ec118d7a4933f07714faeed",
transactionIndex: 0
}