Transaction Signing
Solana only. Ethereum and Polygon coming soon.
Fractal API allows you to request user approval to sign on-chain transactions on their behalf using wallets associated with thier Fractal Account. This is useful for applications that want to allow users to sign transactions accross all platforms without of any extensions, plugins or seed phrase importing.
Transaction Signing Flow
Transaction signing endpoints require a valid project API token passed in the Authorization
header, not a user authentication token and should always be executed on your backend and URL then transfered to the game client.
This is required to prevent a malicious party from tampering with the transaction that is generated on behalf of your project.
-
Send the unsigned, base58 encoded transaction bytes to our
TransactionService
. You will then receive a url and a code. -
Redirect the user to the url, where they will see a human-readable summary of the transaction, and a button to approve or deny the transaction.
-
Optionally, you can use the provided code to check whether the transaction has been successfully signed and sent to the blockchain.
As you can tell, this flow is very similar to the authentication flow. The only difference is that the user is approving a transaction via the URL, instead of logging in.
1. Get Transaction Approval URL and Code
To get a transaction approval URL, you need to send a request to the /sdk/transaction/authorize (opens in a new tab) POST endpoint. The request body should contain a JSON with the following attributes:
Atribute | Content |
---|---|
unsignedMessage | The unsigned transaction bytes encoded in base58. |
Example
curl --request POST \
--url 'https://api.fractal.is/sdk/transaction/authorize' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <CLIENT_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"unsignedMessage": "<UNSIGNED_TX_BASE58>"
}'
Atribute | Content |
---|---|
code | A unique code that you can use to check if the user has approved the transaction. |
url | The URL that you need to redirect the user to sign transaction. |
{
"code": "646ca818-2b48-4259-a8d0-9339e08c58a3",
"url": "https://fractal.is/approve/v2/ede713085042ac6d4da27336149b38c0e5..."
}
2. Redirect User to URL
Transfer the returned URL to the game client and redirect your users to sign with their Fractal account.
Recommendation - Open the signing URL in a new tab, so that the user can easily go back to your game once they approve the authentication request. If the game is a desktop app, you can open the URL in the default browser.
The user will go through the following flow:
- The URL will open on Fractal's domain, and will prompt to sign the transaction.
- Users will always see a human-readable summary of the transaction.
- Once they click approve, they can go back to your game and the poller (see next section) should succeed and return tranasction signature.
3. (Optional) Verify Transaction Status
To verify the transaction status, execute a request to the sdk/transaction/signed_result (opens in a new tab) POST The query requires the following parameters:
Atribute | Content |
---|---|
code | The verification code returned in the step 1. |
Example
curl --request GET \
--url 'https://api.fractal.is/sdk/transaction/signed_result?code=<code>' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <CLIENT_TOKEN>'
Once the user has approved the transaction on their side, this endpoint will return JSON with the following attributes:
Atribute | Content |
---|---|
userId | Fractal ID of the user that approved the transaction. |
signedSignature | A signed signature of the transaction. |