/safe-tx-cli

gnosis safe-tx cli client

Primary LanguageShell

Gnosis Safe Transaction Service API Bash client

Overview

This is a Bash client script for accessing Gnosis Safe Transaction Service API service.

The script uses cURL underneath for making all REST calls.

Usage

# Make sure the script has executable rights
$ chmod u+x 

# Print the list of operations available on the service
$ ./ -h

# Print the service description
$ ./ --about

# Print detailed information about specific operation
$ ./ <operationId> -h

# Make GET request
./ --host http://<hostname>:<port> --accept xml <operationId> <queryParam1>=<value1> <header_key1>:<header_value2>

# Make GET request using arbitrary curl options (must be passed before <operationId>) to an SSL service using username:password
 -k -sS --tlsv1.2 --host https://<hostname> -u <user>:<password> --accept xml <operationId> <queryParam1>=<value1> <header_key1>:<header_value2>

# Make POST request
$ echo '<body_content>' |  --host <hostname> --content-type json <operationId> -

# Make POST request with simple JSON content, e.g.:
# {
#   "key1": "value1",
#   "key2": "value2",
#   "key3": 23
# }
$ echo '<body_content>' |  --host <hostname> --content-type json <operationId> key1==value1 key2=value2 key3:=23 -

# Preview the cURL command without actually executing it
$  --host http://<hostname>:<port> --dry-run <operationid>

Docker image

You can easily create a Docker image containing a preconfigured environment for using the REST Bash client including working autocompletion and short welcome message with basic instructions, using the generated Dockerfile:

docker build -t my-rest-client .
docker run -it my-rest-client

By default you will be logged into a Zsh environment which has much more advanced auto completion, but you can switch to Bash, where basic autocompletion is also available.

Shell completion

Bash

The generated bash-completion script can be either directly loaded to the current Bash session using:

source .bash-completion

Alternatively, the script can be copied to the /etc/bash-completion.d (or on OSX with Homebrew to /usr/local/etc/bash-completion.d):

sudo cp .bash-completion /etc/bash-completion.d/

OS X

On OSX you might need to install bash-completion using Homebrew:

brew install bash-completion

and add the following to the ~/.bashrc:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi

Zsh

In Zsh, the generated _ Zsh completion file must be copied to one of the folders under $FPATH variable.

Documentation for API Endpoints

All URIs are relative to /api/v1

Class Method HTTP request Description
AboutApi aboutList GET /about/
AboutApi aboutMasterCopiesList GET /about/master-copies/
AnalyticsApi analyticsMultisigTransactionsByOriginList GET /analytics/multisig-transactions/by-origin/
AnalyticsApi analyticsMultisigTransactionsBySafeList GET /analytics/multisig-transactions/by-safe/
ContractsApi contractsList GET /contracts/
ContractsApi contractsRead GET /contracts/{address}/
MultisigTransactionsApi multisigTransactionsConfirmationsCreate POST /multisig-transactions/{safe_tx_hash}/confirmations/
MultisigTransactionsApi multisigTransactionsConfirmationsList GET /multisig-transactions/{safe_tx_hash}/confirmations/
MultisigTransactionsApi multisigTransactionsRead GET /multisig-transactions/{safe_tx_hash}/
NotificationsApi notificationsDevicesCreate POST /notifications/devices/
NotificationsApi notificationsDevicesDelete DELETE /notifications/devices/{uuid}/
NotificationsApi notificationsDevicesSafesDelete DELETE /notifications/devices/{uuid}/safes/{address}/
OwnersApi ownersRead GET /owners/{address}/
SafesApi safesAllTransactionsList GET /safes/{address}/all-transactions/
SafesApi safesBalancesList GET /safes/{address}/balances/
SafesApi safesBalancesUsdList GET /safes/{address}/balances/usd/
SafesApi safesCollectiblesList GET /safes/{address}/collectibles/
SafesApi safesCreationList GET /safes/{address}/creation/
SafesApi safesDelegatesCreate POST /safes/{address}/delegates/
SafesApi safesDelegatesDelete DELETE /safes/{address}/delegates/{delegate_address}/
SafesApi safesDelegatesList GET /safes/{address}/delegates/
SafesApi safesIncomingTransactionsList GET /safes/{address}/incoming-transactions/
SafesApi safesIncomingTransfersList GET /safes/{address}/incoming-transfers/
SafesApi safesModuleTransactionsList GET /safes/{address}/module-transactions/
SafesApi safesMultisigTransactionsCreate POST /safes/{address}/multisig-transactions/
SafesApi safesMultisigTransactionsList GET /safes/{address}/multisig-transactions/
SafesApi safesRead GET /safes/{address}/
SafesApi safesTransactionsCreate POST /safes/{address}/transactions/
SafesApi safesTransactionsList GET /safes/{address}/transactions/
SafesApi safesTransfersList GET /safes/{address}/transfers/
TokensApi tokensList GET /tokens/
TokensApi tokensRead GET /tokens/{address}/
TransactionsApi transactionsRead GET /transactions/{safe_tx_hash}/

Documentation For Models

Documentation For Authorization

Basic

  • Type: HTTP basic authentication