The SingularityNET command line interface (CLI) is the primary tool for interacting with the platform’s smart contracts, managing deployed services, and managing funds. It is aimed at service providers. In the near future, it will be supplemented by a web-based dashboard and control panel.
The CLI provides commands to interface with the Blockchain in the following ways:
The CLI also provides service development and deployment support. It can set up new services by generating service metadata, Protobuf specs, and code templates provided by the SingularityNET Foundation. The CLI interacts with daemons for each service. Security-wise, the CLI follows the same guidelines as provided by Ethereum for storing the private keys. When user identities are created and registered with a client, the CLI safely stores the details on the local machine and retrieves them only when it needs to interact with the Blockchain.
The CLI requires and connects to four critical components:
This tool is used extensively in our tutorials and guides, to install it, follow the setup guide.
See the CLI documentation for full details of actions the tool allows.
pip3 install snet-cli #if not done already
snet identity create user-ropsten mnemonic --mnemonic "YOUR MNEMONICS" --network ropsten
snet identity user-ropsten
snet account balance # check balance (all tokens belongs to this idenity)
snet account deposit 0.000001 # Deposit Token to MPE and Open a payment channel to the new service:
snet channel open-init <org_id> <group_name> 0.000001 +2days # Now open a Channel and transfer AGIX in to the Channel
While protocol buffers are used for communication, call parameters are represented as JSON on the command line.
There are three ways of passing this JSON:
For example, in this platform example we need to pass the following JSON as a parameter for the “add” method to our service:
{"a": 10, "b": 32}
We can use three ways:
snet client call <org_id> <service_id> <group_name> add '{"a":10,"b":32}'
echo '{"a":10,"b":32}' > p.txt
snet client call <org_id> <service_id> <group_name> add p.txt
echo '{"a":10,"b":32}' | snet client call <org_id> <service_id> <group_name> add
We’ve implemented several modifiers for this JSON parameter in order to simplify passing big files and to have the possibility to pass binary data (and not only base64 encoded data).
There are 3 possible modifiers:
For example, if you pass the following JSON as a parameter, then as an “image” parameter we will use the base64 encoded content of “1.jpeg”
'{"image_type": "jpg", "file@b64encode@image": "1.jpeg"}'
If we remove the b64encode modifier from the previous example, then we will pass 1.jpeg image in binary format without base64 encoding.
Last modified on : 04-Sep-24