Skip to main content

Transfer

POST https://sol.shrine.trade/api/transfer

SOL, or any SPL token, to another wallet. A token transfer creates the recipient's token account when it does not exist yet, paid by the sender.

{ "publicKey": "<sender>", "to": "<recipient>", "amount": 0.1 }
{ "publicKey": "<sender>", "to": "<recipient>", "mint": "<mint>", "amount": "100%" }
FieldNotes
mintOmit for SOL.
amountSOL or tokens in normal units, or a percentage of the balance: "100%", "25%".
priorityFee, jitoTipOptional, SOL.
{ "tx": "<base64>", "blockhash": "…", "mint": null, "amount": 0.1, "amountRaw": 100000000, "feeLamports": 0 }

Example​

Build, sign, send through the relay. The relay broadcasts through our own Solana endpoint, so the script needs no RPC.

import { Keypair, VersionedTransaction } from "@solana/web3.js";
import bs58 from "bs58";

const wallet = Keypair.fromSecretKey(bs58.decode("<your wallet private key, base58>"));

// Every token of this mint the wallet holds, to another wallet.
const { tx } = await (await fetch("https://sol.shrine.trade/api/transfer", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ publicKey: wallet.publicKey.toBase58(), to: "<recipient>", mint: "<mint>", amount: "100%" }),
})).json();

const transaction = VersionedTransaction.deserialize(Buffer.from(tx, "base64"));
transaction.sign([wallet]);

const sent = await (await fetch("https://sol.shrine.trade/api/send", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ signedTx: Buffer.from(transaction.serialize()).toString("base64") }),
})).json();
console.log(sent.status, `https://solscan.io/tx/${sent.signature}`);