pyStratis provides a python interface to a running Strax or Cirrus node's API. Therefore, to use pystratis, you will need a running node daemon.
The information in this tutorial describes some basic steps to set up a Strax/Cirrus node for use with pystratis. For more information on the StratisFullNode architecture, please refer to the Stratis Academy base documentation or the Academy's developer API reference.
Finally, a quick reference on the pystratis package can be found at pystratis.readthedocs.io
The most up-to-date version of the Strax Wallet can be found at https://github.com/stratisproject/StraxUI/releases/.
- Installation files are available for Windows, MacOS, and Linux platforms.
- When running, the wallet provides a user-interface to the Strax node running as a background daemon.
Clone the repository from GitHub, checkout the latest release, and enter the directory.
git clone https://github.com/stratisproject/StratisFullNode.git
git checkout -b release/1.1.1.0
cd StratisFullNode\src\Stratis.StraxD
The node daemon can be started with dotnet run.
- Configuration settings can be updated in the stratis.conf file in the data directory or through command line args.
- Important (optional) args:
-txindex=1For retrieving individual transaction details. Needed for some API calls.-addressindex=1For retrieving balance details for individual addresses. Needed for some API calls.-apiuri=0.0.0.0If node is being run on a remote device on your network (i.e. headless RPi) to access API outside of ssh tunnel.-datadir=<custom datadir path>Change your node's data directory.-testnetConnect the node to the testnet blockchain.-regtestRegression testing network.-port=12344Change the default connection port.-apiport=12345Change the api port.-rpcport=12346Change the rpc port (if active, inactive by default).-signalrport=12347Change the signalrport.- Other arguments can be discovered in the stratis.conf file or by running the
dotnet run helpcommand.
The most up-to-date version of the Cirrus Wallet can be found at https://github.com/stratisproject/CirrusCore/releases/.
- Installation files are available for Windows, MacOs, and Linux platforms.
- When running, the wallet provides a user-interface to the Cirrus node running as a background daemon.
Clone the repository from GitHub, checkout the latest release, and enter the directory.
git clone https://github.com/stratisproject/StratisFullNode.git
git checkout -b release/1.1.1.0
cd StratisFullNode\src\Stratis.CirrusD
The node daemon can be started with dotnet run.
- See above for information on useful command line args.
Masternode setup is more complex. Please see official documentation for information on registering and running a masternode.
The pystratis.nodes namespace defines the primary node types used on the Stratis/Cirrus blockchains.
Each node instance can take two arguments at initialization:
- ipaddr: The node's ip address. Update if connecting to a node remotely.
- Defaults to
http://localhost.
- Defaults to
- blockchainnetwork: The type of network the node is running.
- Defaults to
StraxMain()for strax nodes. - Defaults to
CirrusMain()for cirrus nodes.
- Defaults to
# Example of connecting to a node at 192.168.3.1 running on Strax Testnet.
from pystratis.nodes import StraxNode
from pystratis.core.networks import StraxTest
node = StraxNode(ipaddr='192.168.3.1', blockchainnetwork=StraxTest())- Please see the respective network class definition for overriding network defaults if your node uses non-standard port numbers.
- StraxNode - The primary node type for the Strax network.
from pystratis.nodes import StraxNode
node = StraxNode()- CirrusNode - The primary node type for the Cirrus sidechain.
from pystratis.nodes import CirrusNode
node = CirrusNode()- InterfluxStraxNode - The Strax member of the multisig Interflux Gateway pair.
- InterfluxCirrusNode - The Cirrus member of the multisig Interflux Gateway pair.
from pystratis.nodes import InterfluxStraxNode, InterfluxCirrusNode
strax_node = InterfluxStraxNode()
cirrus_node = InterfluxCirrusNode()- StraxMasterNode - The Strax member of the standard masternode pair.
- CirrusMasterNode - The Cirrus member of the standard masternode pair.
from pystratis.nodes import StraxMasterNode, CirrusMasterNode
strax_node = StraxMasterNode()
cirrus_node = CirrusMasterNode()At this point, you should have:
- A running node daemon.
- An initialized pystratis.node instance.
Active API routes are implemented as class properties.
API endpoints can be called as in the following example:
# API endpoint: http://localhost:17103/api/node/status
from pystratis.nodes import StraxNode
strax_node = StraxNode()
strax_node.node.status()Please see the pystratis.api namespace documentation (or other tutorials) for more information on calling specific API endpoints.