How it works
Resources: Vega Wallet
This section is part of a series on the topic of the Vega Wallet.
Apps:
Develop with the wallet API:
Other resources:
For a transaction to be accepted by a network, it has to be signed by the user.
To sign a transaction, the user uses a cryptographic wallet.
Therefore, for third-party applications to send a transaction to a network, they have to connect to the user's wallet to get the transaction signed, then send it.
Wallet in the Vega ecosystem
Technically speaking, the Vega Wallet is a software that sits between the third-party applications and the network, and is owned by the users of the network.
As a developer, if you want to send a transaction to the network, you will have to integrate with Vega Wallet software to allow the user to approve and sign the transaction. Once signed, the Vega Wallet software will either send it to the network, or pass it to your application to send it.
How the wallet works
The Vega wallet software has 3 main components:
- API: The communication layer used by third-party applications to talk to the wallet.
- Backend: The core of the wallet that is shared by all Vega Wallet implementation. It manages the wallets, their keys and the requests from the third-party applications. It takes the form of a JSON-RPC API and is implementation agnostic.
- Frontend: Displays information about the wallets and the requests from the third-party applications to the user.
Sending a transaction with a third-party app
What happens when a third party application wants to send a transaction on behalf of a user:
- The third-party application requests to send a transaction.
- The API receives the request and delegates it to the backend.
- The backend checks and forwards the transaction to the frontend so the user can review it and approve sending.
- If approved by the user, the backend proceeds to sign the transaction and send it to the network.
- The backend waits for the network response and forwards it to the third-party application.
Handling errors
As you can see, there are several systems involved in sending a transaction, and all of them can prevent it: the user can reject or cancel the connection and the transaction, the Vega wallet software can label the transaction as malformed or breaking the anti-spam rules, the network can reject the transaction, the network connection might fail, etc.
As a result, when a third-party application wants to send a transaction, it's important to account for all these errors.
All errors are documented in the JSON-RPC reference.