Arbitrary Transaction Signing
Sign transactions for any on-chain program.
There may be situations where you would like a GameShift user wallet to interact with an on-chain program that isn’t built into GameShift. In these cases, it is possible for you to request the user’s consent to sign a transaction. Transactions signed this way are submitted to the chain automatically after consent is captured.
To request a signature for a transaction, you can make a POST http request to https://api.gameshift.dev/nx/users/{id-of-user}/sign
.
You will need to provide the following fields in the request body:
serializedTransaction
: This is the transaction you are requesting a signature for. The transaction must be serialized into ahex
string. In addition, you must serialize just theMessage
within the transaction. As an example, if you have a transaction you created using@solana/web3.js
, you could create the value for this field by callingtransaction.serializeMessage().toString(‘hex’)
.
You may, in addition, optionally provide the following fields:
description
: Helps inform the user of what it is they are signing.
All requests will return an object containing a “consent URL” that you must navigate the user to in order to complete the transaction.
{
"consentUrl": "https://app.gameshift.dev/consent?transaction=dd574516-f036-4aba-891e-7ea206d73dc9",
"transactionId": "dd574516-f036-4aba-891e-7ea206d73dc9"
}
When the user visits the consent URL, they will be presented with a UI where they can sign and complete the transaction.
As a safeguard, if the transaction would result in the user transferring assets or tokens, they will be asked to confirm they want to proceed with the transaction. They will be presented with a UI that will look similar to this:
If the user click to “proceed”, they will see the remainder of the transaction signature flow.
Fees
If the user is registered with a wallet provisioned by GameShift, transaction signing fees are handled by GameShift. The user does not need to maintain a balance of network tokens in order to pay signing fees. However, if the user is registered with an external wallet, fees will need to be paid by the user.
Any additional fees imposed by the network for the transaction are not handled by GameShift. These may include rent costs for establishing new accounts on chain. These fees are paid for through GameShift api usage fees in the case of GameShift provisioned wallets, and by the user in the case of external wallets.
Updated 4 months ago