Transaction Signing
The most powerful capability our wallet provides is the ability to sign transactions from any game client. We know this is paramount to a good in-game experience, and we will be bringing more options for seamless signing in the future. For now, we have our client-agnostic API implementation which is just a couple lines of code, and our even easier to use web SDK. Below is an overview of how the flow works, but you can also jump into the code with the snippets below.
Overview
To prompt a user to sign a transaction, 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. You can use the provided code to check whether the transaction has been successfully signed and sent to the blockchain.
Dive In
Next, let's dig into what the code looks like to prompt a user to sign a transaction.
# You can test out the signing flow in our API reference starting at https://reference.fractal.is/reference/authorize
# Step 1: Get signing url using your project API token and an unsigned base58 encoded transaction. You should proxy through your backend to do this.
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>"
}
'
# You will receive a code in the above response which will be used in Step 2 below.
# Step 2: Redirect the user to the returned url and kick off a poller to check for the signing status.
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 signed and submitted the transaction, the following API call will return a transaction signature.