Gasless Transaction
Applications can pay for the transactions fees of behalf of their users. This allows users to execute transactions (exchanging NFTs, tokens, etc.) without holding SOL.
getGaslessPublicKey
Method to get the public key of feePayer. Please contact us on hello@tor.us
to setup the necessary infrastructure.
Example
const network = "<NETWORK_URL>";
const connection = new Connection(network);t
const blockhash = (await connection.getRecentBlockhash("finalized")).blockhash;
const TransactionInstruction = SystemProgram.transfer({
fromPubkey: new PublicKey(publicKeys[0]),
toPubkey: new PublicKey(publicKeys[1]),
lamports: 0.1 * LAMPORTS_PER_SOL
});
const gaslessPublicKey = await torus.getGaslessPublicKey(); // scoped to application
let transaction = new Transaction({
recentBlockhash: blockhash,
feePayer: new PublicKey(gaslessPublicKey)
}).add(TransactionInstruction);
const res_tx = await torus.sendTransaction(transaction);
Reference
getGaslessPublicKey(relay: string): Promise<string>;