How to use Vega Wallet APIs
Introduction
To submit orders and other commands on Vega, users need to sign transactions with a private and public key pair. Users on Vega are pseudonymous and are referenced by their public keys. To assist with API integration there is a REST API service served from the Vega Wallet software providing signing and key management.
For more detail on how keys or signing work on a Vega network, see the section on Wallets and Signing.
The Vega Wallet software can store many wallets, and each wallet can store many key pairs.
Common actions for a wallet include; logging in, retrieving a key pair and signing transactions (such as an order submission). There are several useful how-to guides below that will help with management of keys and signing.
Logging in to an existing wallet
Connect to a Vega Wallet server and log in. This can be either a hosted wallet, one you run yourself locally or stored in the cloud. The resulting token
will be used to authenticate with the wallet for other actions (such as signing):
See also Wallet API reference for further query detail.
See also Wallet API reference for further query detail.
Make sure vegaapiclient
is installed (from PyPI):
pip install --upgrade Vega-API-client
This Python snippet code shows how to log in to an existing wallet:
See also Wallet API reference for further query detail.
If successful, the response will include:
Field | Description |
---|---|
token |
A JSON Web Token (JWT) used to provide authentication with methods on the wallet service (pass in headers as Bearer token). |
Creating a new wallet
Connect to a wallet server to create a new wallet. As mentioned earlier, this can be either a hosted wallet, one you run yourself locally or stored in the cloud. Just like logging in, once a new wallet has been created, a token
will be returned and it will be used to authenticate with the wallet for other actions (such as signing):
See also Wallet API reference for further query detail.
See also Wallet API reference for further query detail.
Make sure vegaapiclient
is installed (from PyPI):
pip install --upgrade Vega-API-client
This Python snippet code shows how to create a new wallet:
See also Wallet API reference for further query detail.
If successful, the response will include:
Field | Description |
---|---|
token |
A JSON Web Token (JWT) used to provide authentication with methods on the wallet service (pass in headers as Bearer token). |
Generating a new private and public key pair
Once authenticated with Vega Wallet, it is possible to generate one or more new key pairs (private and public keys) to sign transactions for the Vega network. For detailed information on key pairs, see the section on Wallets and Signing. Note that the private key is not returned. Your public key will be used as your party
identifier on Vega:
See also Wallet API reference for further query detail.
See also Wallet API reference for further query detail.
Make sure vegaapiclient
is installed (from PyPI):
pip install --upgrade Vega-API-client
This Python snippet code shows how to generate a new key pair:
See also Wallet API reference for further query detail.
If successful, the response will include:
Field | Description |
---|---|
algo |
The encryption algorithm used. |
meta |
Any meta-data associated with the public/private key pair. As passed with the creation request. |
pub |
The public key value. |
tainted |
true if the key is tainted, false otherwise. |
Listing key pairs for a wallet
Retrieve a list of all key pairs for a wallet. Note that private keys are not returned:
See also Wallet API reference for further query detail.
See also Wallet API reference for further query detail.
Make sure vegaapiclient
is installed (from PyPI):
pip install --upgrade Vega-API-client
This Python snippet code shows how to query for key pairs:
See also Wallet API reference for further query detail.
If successful, the response will include:
Field | Description |
---|---|
keys |
A list of zero or more keys for the authenticated wallet. See example response (below). |
Signing a transaction
Connect and call sign transaction on a Vega Wallet server. Note: it is possible to set the propagate
field to true
. This instructs the wallet to submit the signed transaction directly to the Vega node specified in its config file:
See also Wallet API reference for further query detail.
See also Wallet API reference for further query detail.
Make sure vegaapiclient
is installed (from PyPI):
pip install --upgrade Vega-API-client
This Python snippet code shows how to sign a transaction:
See also Wallet API reference for further query detail.
If successful, the response will include:
Field | Description |
---|---|
sig |
The signature info including encryption algorithm and version. |
tx |
Base64 encoded Vega command message e.g. OrderSubmission , OrderAmendment , etc. |
What’s next?
- Learn how to Submit an order or Cancel orders.