SingularityNET CLI
These instructions are for the development and use of the SingularityNET CLI. For further details, please check our full Documentation.
You should have python with version >= 3.6.5 and pip installed.
Additionally you should install the following packages:
- libudev
- libusb 1.0
If you use Ubuntu (or any Linux distribution with APT package support) you should do the following:
sudo apt-get install libudev-dev libusb-1.0-0-dev
$ pip3 install snet-cli
If you want to enable auto completion of commands, you should install the following package
- python-argcomplete
On ubuntu (or any Linux distribution with APT package support), you should do the following
sudo apt install python-argcomplete
After the package is installed, activate autocomplete
sudo activate-global-python-argcomplete
Note: Changes will not take effect until shell is restarted.
echo 'eval "$(register-python-argcomplete snet)"' >> ~/.bashrc
then
source ~/.bashrc
Below is a summary of some commands (check the full documentation here):
usage: snet [-h] [--print-traceback] COMMAND ...
Show version and exit
snet version [-h]
Manage identities
snet identity [-h] COMMAND ...
List of identities
snet identity list [-h]
Create a new identity
snet identity create IDENTITY_NAME IDENTITY_TYPE [--mnemonic MNEMONIC]
[--private-key PRIVATE_KEY]
[--keystore-path KEYSTORE_PATH]
[--eth-rpc-endpoint ETH_RPC_ENDPOINT]
IDENTITY_NAME
: name of identity to create; must be unique among identitiesIDENTITY_TYPE
: type of identity (eitherrpc
,mnemonic
,key
,ledger
, ortrezor
)MNEMONIC
: required only formnemonic
identity type; bip39 mnemonic for wallet derivationPRIVATE_KEY
: required only forkey
identity type; hex-encoded private Ethereum keyKEYSTORE_PATH
: required only forkeystore
identity type; local path of the encrypted JSON fileETH_RPC_ENDPOINT
: required only forrpc
identity type; Ethereum JSON-RPC endpoint that manages target account
Delete an identity
snet identity delete [-h] IDENTITY_NAME
snet identity ID_NAME [-h]
Manage networks
snet network [-h] NETWORK ...
List of networks
snet network list [-h]
Create a new network
snet network create [-h] [--default-gas-price DEFAULT_GAS_PRICE]
[--skip-check]
network_name eth_rpc_endpoint
network_name
: name of network to createeth_rpc_endpoint
: ethereum rpc endpoint
snet network network_name [-h]
View session state
snet session [-h]
Set session keys
snet set [-h] KEY VALUE
KEY
: session key to set from['default_gas_price', 'current_registry_at', 'current_multipartyescrow_at', 'current_singularitynettoken_at', 'default_eth_rpc_endpoint', 'default_wallet_index', 'default_ipfs_endpoint']
VALUE
: desired value of session key
Unset session keys
snet unset [-h] KEY
KEY
: session key to set from['default_gas_price', 'current_registry_at', 'current_multipartyescrow_at', 'current_singularitynettoken_at']
Interact with contracts at a low level
snet contract [-h] CONTRACT ...
Interact with SingularityNET Organizations
snet organization [-h] COMMAND ...
List of Organizations Ids
snet organization list [-h] [--registry-at REGISTRY_ADDRESS]
[--wallet-index WALLET_INDEX]
List Organizations Names and Ids
snet organization list-org-names [-h] [--registry-at REGISTRY_ADDRESS]
[--wallet-index WALLET_INDEX]
Print organization which has the current identity as the owner or as a member
snet organization list-my [-h] [--registry-at REGISTRY_ADDRESS]
[--wallet-index WALLET_INDEX]
Organization’s Information
snet organization info [-h] [--registry-at REGISTRY_ADDRESS]
[--wallet-index WALLET_INDEX]
org_id
org_id
: name of the organization
Create an Organization
snet organization create [-h] (--org-id ORG_ID | --auto)
[--members ORG_MEMBERS] [--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
[--registry-at REGISTRY_ADDRESS]
ORG_NAME
ORG_NAME
: name of the organization--org-id ORG_ID
: unique organization Id--auto
: generate organization Id (by default random id is generated)--members ORG_MEMBERS[]
: list of members to be added to the organization (comma-separated)
Delete an Organization
snet organization delete [-h] [--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
[--registry-at REGISTRY_ADDRESS]
org_id
org_id
: id of the Organization
List Organization’s services
snet organization list-services [-h] [--registry-at REGISTRY_ADDRESS]
[--wallet-index WALLET_INDEX]
org_id
org_id
: id of the Organization
Change Organization’s name
snet organization change-name [-h] [--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
[--registry-at REGISTRY_ADDRESS]
org_id ORG_NEW_NAME
org_id
: id of the OrganizationORG_NEW_NAME
: the new Organization's name
Change Organization’s owner
snet organization change-owner [-h] [--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
[--registry-at REGISTRY_ADDRESS]
org_id OWNER_ADDRESS
org_id
: id of the OrganizationOWNER_ADDRESS
: address of the new Organization's owner
Add members to Organization
snet organization add-members [-h] [--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
[--registry-at REGISTRY_ADDRESS]
org_id ORG_MEMBERS
org_id
: id of the OrganizationORG_MEMBERS[]
: list of members to be added to the organization
Remove members from Organization
snet organization rem-members [-h] [--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
[--registry-at REGISTRY_ADDRESS]
org_id ORG_MEMBERS
org_id
: id of the OrganizationORG_MEMBERS[]
: list of members to be removed from the organization
AGI account
snet account [-h] COMMAND ...
Print the current ETH account
snet account print [-h] [--wallet-index WALLET_INDEX]
Print balance of AGI tokens and balance of MPE wallet
snet account balance [-h] [--account ACCOUNT]
[--singularitynettoken-at SINGULARITYNETTOKEN_AT]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--wallet-index WALLET_INDEX]
--account ACCOUNT
: account to print balance for (default is the current identity)
Deposit AGI tokens to MPE wallet
snet account deposit [-h] [--singularitynettoken-at SINGULARITYNETTOKEN_AT]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--gas-price GAS_PRICE] [--wallet-index WALLET_INDEX]
[--yes] [--verbose | --quiet]
amount
amount
: amount of AGI tokens to deposit in MPE wallet
Withdraw AGI tokens from MPE wallet
snet account withdraw [-h] [--multipartyescrow-at MULTIPARTYESCROW_AT]
[--gas-price GAS_PRICE] [--wallet-index WALLET_INDEX]
[--yes] [--verbose | --quiet]
amount
amount
: amount of AGI tokens to deposit in MPE wallet
Transfer AGI tokens inside MPE wallet
snet account transfer [-h] [--multipartyescrow-at MULTIPARTYESCROW_AT]
[--gas-price GAS_PRICE] [--wallet-index WALLET_INDEX]
[--yes] [--verbose | --quiet]
receiver amount
receiver
: address of the receiveramount
: amount of AGI tokens to deposit in MPE wallet
Interact with SingularityNET payment channels
snet channel [-h] COMMAND ...
Initialize channel taking service metadata from Registry
snet channel init [-h] [--registry-at REGISTRY_AT]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
org_id service_id channel_id
org_id
: id of the Organizationservice_id
: id of servicechannel_id
: channel_id
Initialize channel using service metadata
snet channel init-metadata [-h] [--registry-at REGISTRY_AT]
[--metadata-file METADATA_FILE]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--wallet-index WALLET_INDEX]
org_id service_id channel_id
org_id
: id of the Organizationservice_id
: id of servicechannel_id
: channel_id
Open and initialize channel using metadata from Registry
snet channel open-init [-h] [--registry-at REGISTRY_AT] [--force]
[--signer SIGNER] [--group-name GROUP_NAME]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--gas-price GAS_PRICE] [--wallet-index WALLET_INDEX]
[--yes] [--verbose | --quiet] [--open-new-anyway]
[--from-block FROM_BLOCK]
org_id service_id amount expiration
org_id
: id of the Organizationservice_id
: id of serviceamount
: amount of AGI tokens to put in the new channelexpiration
: expiration time in blocks (int), or in blocks related to the current_block (+int_blocks), or in days related to the current_block and assuming 15 sec/block (+int_days)
Open and initialize channel using service metadata
snet channel open-init-metadata [-h] [--registry-at REGISTRY_AT] [--force]
[--signer SIGNER] [--group-name GROUP_NAME]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet] [--open-new-anyway]
[--from-block FROM_BLOCK]
[--metadata-file METADATA_FILE]
org_id service_id amount expiration
org_id
: id of the Organizationservice_id
: id of serviceamount
: amount of AGI tokens to put in the new channelexpiration
: expiration time in blocks (int), or in blocks related to the current_block (+int_blocks), or in days related to the current_block and assuming 15 sec/block (+int_days)
--metadata-file METADATA_FILE
: service metadata json file (defaultservice_metadata.json
)
Claim timeout of the channel
snet channel claim-timeout [-h] [--multipartyescrow-at MULTIPARTYESCROW_AT]
[--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
channel_id
channel_id
: channel_id
Claim timeout for all channels which have current identity as a sender.
snet channel claim-timeout-all [-h]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet] [--from-block FROM_BLOCK]
Set new expiration for the channel and add funds
snet channel extend-add [-h] [--expiration EXPIRATION] [--force]
[--amount AMOUNT]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--gas-price GAS_PRICE] [--wallet-index WALLET_INDEX]
[--yes] [--verbose | --quiet]
channel_id
channel_id
: channel_id
--expiration EXPIRATION
: expiration time in blocks (int), or in blocks related to the current_block (+int_blocks), or in days related to the current_block and assuming 15 sec/block (+int_days)--force
: skip check for very high (>6 month) expiration time--amount AMOUNT
: amount of AGI tokens to add to the channel
Set new expiration and add funds for the channel for the given service
snet channel extend-add-for-service [-h] [--registry-at REGISTRY_AT]
[--expiration EXPIRATION] [--force]
[--amount AMOUNT]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
[--group-name GROUP_NAME]
[--channel-id CHANNEL_ID]
[--from-block FROM_BLOCK]
org_id service_id
org_id
: id of the Organizationservice_id
: id of service
--expiration EXPIRATION
: expiration time in blocks (int), or in blocks related to the current_block (+int_blocks), or in days related to the current_block and assuming 15 sec/block (+int_days)--force
: skip check for very high (>6 month) expiration time--amount AMOUNT
: amount of AGI tokens to add to the channel
Print the last ethereum block number
snet channel block-number [-h]
Print initialized channels.
snet channel print-initialized [-h] [--only-id]
[--filter-sender | --filter-signer | --filter-my]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--wallet-index WALLET_INDEX]
[--registry-at REGISTRY_AT]
--only-id
: print only id of channels--filter-sender
: print only channels in which current identity is sender--filter-signer
: print only channels in which current identity is signer--filter-my
: print only channels in which current identity is sender or signer
Print initialized channels for the given service (all payment group).
snet channel print-initialized-filter-service [-h] [--registry-at REGISTRY_AT]
[--only-id]
[--filter-sender | --filter-signer | --filter-my]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--wallet-index WALLET_INDEX]
org_id service_id
org_id
: id of the Organizationservice_id
: id of service
--only-id
: print only id of channels--filter-sender
: print only channels in which current identity is sender--filter-signer
: print only channels in which current identity is signer--filter-my
: print only channels in which current identity is sender or signer
Print all channels for the given sender.
snet channel print-all-filter-sender [-h] [--only-id]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--from-block FROM_BLOCK]
[--wallet-index WALLET_INDEX]
[--sender SENDER]
--only-id
: print only id of channels--sender SENDER
: account to set as sender (by default we use the current identity)
Print all channels for the given recipient.
snet channel print-all-filter-recipient [-h] [--only-id]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--from-block FROM_BLOCK]
[--wallet-index WALLET_INDEX]
[--recipient RECIPIENT]
--only-id
: print only id of channels--recipient RECIPIENT
: account to set as recipient (by default we use the current identity)
Print all channels for the given service.
snet channel print-all-filter-group [-h] [--registry-at REGISTRY_AT]
[--group-name GROUP_NAME] [--only-id]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--from-block FROM_BLOCK]
[--wallet-index WALLET_INDEX]
org_id service_id
org_id
: id of the Organizationservice_id
: id of service
--group-name GROUP_NAME
: name of the payment group. Parameter should be specified only for services with several payment groups--only-id
: print only id of channels
Print all channels for the given group and sender.
snet channel print-all-filter-group-sender [-h] [--registry-at REGISTRY_AT]
[--group-name GROUP_NAME]
[--only-id]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--from-block FROM_BLOCK]
[--wallet-index WALLET_INDEX]
[--sender SENDER]
org_id service_id
org_id
: id of the Organizationservice_id
: id of service
--group-name GROUP_NAME
: name of the payment group. Parameter should be specified only for services with several payment groups--only-id
: print only id of channels--sender SENDER
: account to set as sender (by default we use the current identity)
Interact with SingularityNET services
snet client [-h] COMMAND ...
call server. We ask state of the channel from the server if needed. Channel should be already initialized.
snet client call [-h] [--service SERVICE] [--wallet-index WALLET_INDEX]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--save-response FILENAME]
[--save-field SAVE_FIELD SAVE_FIELD] [--endpoint ENDPOINT]
[--group-name GROUP_NAME] [--channel-id CHANNEL_ID]
[--from-block FROM_BLOCK] [--yes] [--skip-update-check]
org_id service_id method [params]
org_id
: id of the Organizationservice_id
: id of servicemethod
: target service's method name to callparams
: json-serialized parameters object or path containing json-serialized parameters object (leave emtpy to read from stdin)
--service SERVICE
: name of protobuf service to call. It should be specified in case of method name conflict.--save-response FILENAME
: save response in the file--save-field SAVE_FIELD SAVE_FIELD
: save specific field in the file (two arguments 'field' and 'file_name' should be specified)--endpoint ENDPOINT
: service endpoint (by default we read it from metadata)--group-name GROUP_NAME
: name of the payment group. Parameter should be specified only for services with several payment groups--channel-id CHANNEL_ID
: channel_id (only in case of multiply initialized channels for the same payment group)
Low level function for calling the server. Service should be already initialized.
snet client call-lowlevel [-h] [--service SERVICE]
[--wallet-index WALLET_INDEX]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--save-response FILENAME]
[--save-field SAVE_FIELD SAVE_FIELD]
[--endpoint ENDPOINT] [--group-name GROUP_NAME]
org_id service_id channel_id nonce amount_in_cogs
method [params]
org_id
: id of the Organizationservice_id
: id of servicechannel_id
: channel_idmethod
: target service's method name to callparams
: json-serialized parameters object or path containing json-serialized parameters object (leave emtpy to read from stdin)
Get channel state in stateless manner
snet client get-channel-state [-h] [--multipartyescrow-at MULTIPARTYESCROW_AT]
[--wallet-index WALLET_INDEX]
channel_id endpoint
channel_id
: channel_idendpoint
: service endpoint
Create, publish, register, and update SingularityNET services
snet service [-h] COMMAND ...
Init metadata file with providing protobuf directory (which we publish in IPFS) and display_name (optionally encoding, service_type and payment_expiration_threshold)
snet service metadata-init [-h] [--metadata-file METADATA_FILE]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--group-name GROUP_NAME] [--encoding {proto,json}]
[--service-type {grpc,jsonrpc,process}]
[--payment-expiration-threshold PAYMENT_EXPIRATION_THRESHOLD]
[--endpoints [ENDPOINTS [ENDPOINTS ...]]]
[--fixed-price FIXED_PRICE]
protodir display_name payment_address
protodir
: directory which contains protobuf filesdisplay_name
: service display namepayment_address
: payment_address for the first payment group
Publish protobuf model in ipfs and update existed metadata file
snet service metadata-set-model [-h] [--metadata-file METADATA_FILE] protodir
protodir
: directory which contains protobuf files
Set pricing model as fixed price for all methods
snet service metadata-set-fixed-price [-h] [--metadata-file METADATA_FILE] price
price
: set fixed price in AGI token for all methods
Add new group of replicas
snet service metadata-add-group [-h] [--metadata-file METADATA_FILE]
group_name payment_address
group_name
: name of the new payment grouppayment_address
: payment_address for this group
Add endpoints to the groups
snet service metadata-add-endpoints [-h] [--group-name GROUP_NAME]
[--metadata-file METADATA_FILE]
endpoints [endpoints ...]
endpoints
: endpoints
Remove all endpoints from metadata
snet service metadata-remove-all-endpoints [-h]
[--metadata-file METADATA_FILE]
Remove all endpoints from the group and add new ones
snet service metadata-update-endpoints [-h] [--group-name GROUP_NAME]
[--metadata-file METADATA_FILE]
endpoints [endpoints ...]
endpoints
: endpoints
Add service description
snet service metadata-add-description [-h] [--json JSON] [--url URL]
[--description DESCRIPTION]
[--metadata-file METADATA_FILE]
--json JSON
: service description in json--url URL
: URL to provide more details of the service--description DESCRIPTION
: some description of what the service does
Publish metadata only in IPFS, without publishing in Registry
snet service publish-in-ipfs [-h] [--metadata-file METADATA_FILE]
[--update-mpe-address]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
Publish service with given metadata
snet service publish [-h] [--metadata-file METADATA_FILE]
[--update-mpe-address]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--registry-at REGISTRY_AT] [--tags [TAGS [TAGS ...]]]
[--gas-price GAS_PRICE] [--wallet-index WALLET_INDEX]
[--yes] [--verbose | --quiet]
org_id service_id
org_id
: id of the Organizationservice_id
: id of service--tags [TAGS [TAGS ...]]
: tags for service
Publish metadata in IPFS and update existed service
snet service update-metadata [-h] [--metadata-file METADATA_FILE]
[--update-mpe-address]
[--multipartyescrow-at MULTIPARTYESCROW_AT]
[--registry-at REGISTRY_AT]
[--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
org_id service_id
org_id
: id of the Organizationservice_id
: id of service
Add tags to existed service registration
snet service update-add-tags [-h] [--registry-at REGISTRY_AT]
[--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
org_id service_id tags [tags ...]
org_id
: id of the Organizationservice_id
: id of servicetags
: tags which will be add
Remove tags from existed service registration
snet service update-remove-tags [-h] [--registry-at REGISTRY_AT]
[--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
org_id service_id tags [tags ...]
org_id
: id of the Organizationservice_id
: id of servicetags
: tags which will be removed
Print service metadata from registry
snet service print-metadata [-h] [--registry-at REGISTRY_AT] org_id service_id
org_id
: id of the Organizationservice_id
: id of service
Print tags for given service from registry
snet service print-tags [-h] [--registry-at REGISTRY_AT] org_id service_id
org_id
: id of the Organizationservice_id
: id of service
Extract service api (model) to the given protodir. Get model_ipfs_hash from metadata
snet service get-api-metadata [-h] [--metadata-file METADATA_FILE] protodir
protodir
: directory to which extract api (model)
Extract service api (model) to the given protodir. Get metadata from registry
snet service get-api-registry [-h] [--registry-at REGISTRY_AT]
org_id service_id protodir
org_id
: id of the Organizationservice_id
: id of serviceprotodir
: directory to which extract api (model)
Delete service registration from registry
snet service delete [-h] [--registry-at REGISTRY_AT] [--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
org_id service_id
org_id
: id of the Organizationservice_id
: id of service
Treasurer logic
snet treasurer [-h] COMMAND ...
Print unclaimed payments
snet treasurer print-unclaimed [-h] --endpoint ENDPOINT
[--wallet-index WALLET_INDEX]
--endpoint ENDPOINT
: daemon endpoint
Claim given channels. We also claim all pending ‘payments in progress’ in case we ‘lost’ some payments.
snet treasurer claim [-h] --endpoint ENDPOINT [--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
channels [channels ...]
channels
: channels to claim
--endpoint ENDPOINT
: daemon endpoint
Claim all channels. We also claim all pending ‘payments in progress’ in case we ‘lost’ some payments.
snet treasurer claim-all [-h] --endpoint ENDPOINT [--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
--endpoint ENDPOINT
: daemon endpoint
Claim all channels which are close to expiration date. We also claim all pending ‘payments in progress’ in case we ‘lost’ some payments.
snet treasurer claim-expired [-h]
[--expiration-threshold EXPIRATION_THRESHOLD]
--endpoint ENDPOINT [--gas-price GAS_PRICE]
[--wallet-index WALLET_INDEX] [--yes]
[--verbose | --quiet]
--endpoint ENDPOINT
: daemon endpoint
Generate client libraries to call SingularityNET services using your language of choice
snet sdk [-h] COMMAND ...
Generate compiled client libraries to call services using your language of choice
snet sdk generate-client-library [-h] [--registry-at REGISTRY_AT]
[--wallet-index WALLET_INDEX]
LANGUAGE org_id service_id [PROTODIR]
LANGUAGE
: choose target language for the generated client library from ['python']org_id
: id of the Organizationservice_id
: id of servicePROTODIR
: directory where to output the generated client libraries
- Clone the git repository
$ git clone git@github.com:singnet/snet-cli.git
$ cd snet-cli
- Install development/test blockchain dependencies
$ ./scripts/blockchain install
- Install the package in development/editable mode
$ pip3 install -e .
This project is published to PyPI.
We use SemVer for versioning. For the versions available, see the tags on this repository.
This project is licensed under the MIT License - see the LICENSE file for details.