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/transactions/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’)
.onBehalfOf
: The reference id of the user you are requesting a transaction signature from.
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.
{
"url": "https://app.gameshift.dev/consent?transaction=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
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.
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 costs will need to be paid by the user, or you can provide a developer account as the fee payer. If you provide a fee payer address in the transaction, that fee payer will be charged all fees, including the signing fee.
Updated 9 months ago