Transaction Relayer
Transaction Relayer, allows you to seamlessly enable gas-less transactions for your users.
It first creates a custodial wallet which gets mapped to your Shyft API key. On creation, it returns the wallet address associated with you SHYFT API key. You have to use this wallet address as,fee_payer while constructing your transactions. Then, you can send the transactions that need to be signed on the relayer’s sign endpoint. Relayer will retrieve the credentials associated with your API key, sign the transaction and send it to the blockchain.
Create Relayer
Create a new transaction relayer.
POST /sol/v1/txn_relayer/create
Headers:
x-api-key: Your API key
var myHeaders = new Headers();
myHeaders.append("x-api-key", "<YOUR-API-KEY>");
var requestOptions = {
method: 'POST',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://api.shyft.to/sol/v1/txn_relayer/create", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));{
"success": true,
"message": "A wallet bound with your API Key",
"result": {
"wallet": "GzMBRTvt5iyRsVizd5qKqJrKRJ4F2cyrdisRhUKEevTi"
}
}Sign Transaction
Sign and send a transaction using the relayer. Takes encoded_transaction and network as input request parameters.
POST /sol/v1/txn_relayer/sign
Params:
network:Solana blockchain environment (testnet/devnet/mainnet-beta)encoded_transaction:Serialized transaction (base64 string).
var myHeaders = new Headers();
myHeaders.append("x-api-key", "<YOUR-API-KEY>");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"network": "devnet",
"encoded_transaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAED7ZA6LXrHCu2nMYL1uyosskVZS/5V3xX/aeLk2dgUQhnJNUkOyHbKRR9ttDUZUf+0UV49qJjw/Iaqn4vwoq/rpQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVPLSs0MqmtWZZIaLQKUkawi9RhixVRLZ4CWP96oToVkBAgIAAQwCAAAAgJaYAAAAAAA="
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.shyft.to/sol/v1/txn_relayer/sign", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));{
"success": true,
"message": "Transaction executed successfully",
"result": {
"tx": "VSR2TqG5H6223hPMvvarEJTTWLWkGgoD3MxGcQsaUHJ8goSGj66KXC5D3CFRjgbU9A3wwS8B5kc6FnTk4RNZhuB"
}
}Sign Multiple Transactions
Sign and send multiple transactions using the relayer. Takes encoded_transactions and network as input request parameters.
POST /sol/v1/txn_relayer/sign_many
Params:
network:Solana blockchain environment (testnet/devnet/mainnet-beta)encoded_transactions:An array of serialized transactions (base64 string).commitment (optional): If the response is needed after a certain commitment level reaches all the transactions, pass the desired commitment level (allowed
processed,confirmed,finalized).
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("x-api-key", "YOUR_API_KEY");
var raw = JSON.stringify({
"network": "devnet",
"encoded_transactions": [
"AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDX26hu/mTZjDVkpJ2jU6FftnXFJGy5KcBJoXAaXHIMdpALAeVfwkorAqlrAeN8dOn8Jeu6H4u3ofHzGz4FntQPwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0ihHHsVZsH9hW04rx4QZ+LTAoGxUuyawjkhtv3ao2aEBAgIAAQwCAAAAQEIPAAAAAAA=",
"AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDX26hu/mTZjDVkpJ2jU6FftnXFJGy5KcBJoXAaXHIMdosLagmF5c4a6vJhMr74YTUznxniMs9+z4QYlMJ1x2b+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHubOmafFh4bvNPqY+AdQdzrv43WzBksnfAcdQd03Y40BAgIAAQwCAAAAgIQeAAAAA"
],
"commitment": "finalized"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.shyft.to/sol/v1/txn_relayer/sign_many", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));{
"success": true,
"message": "Transactions executed successfully",
"result": [
{
"id": 1,
"signature": "5Njh861JEgiEhoSTUiVvR653MohGZrU8LfkmzkuYubCrfRggALyxe1hmVXbYZyAaPuoqeFNzrcZWtfpPpR2L6sT5",
"status": "finalized"
},
{
"id": 2,
"error": {
"code": -32002,
"message": "Transaction simulation failed: Error processing Instruction 0: invalid instruction data",
"data": {
"accounts": null,
"err": {
"InstructionError": [
0,
"InvalidInstructionData"
]
},
"logs": [
"Program 11111111111111111111111111111111 invoke [1]",
"Program 11111111111111111111111111111111 failed: invalid instruction data"
],
"returnData": null,
"unitsConsumed": 0
}
},
"status": null
}
]
}Last updated
Was this helpful?