销毁
POST https://sol.shrine.trade/api/burn
永久销毁代币。全部销毁时还会关闭代币账户,退还其租金。
{ "publicKey": "<wallet>", "mint": "<mint>", "amount": "100%" }
| 字段 | 说明 |
|---|---|
amount | 以常规单位表示的代币数量,或余额的百分比。 |
priorityFee、jitoTip | 可选,单位 SOL。 |
示例
构建、签名、通过中继发送。中继通过我们自己的 Solana 节点广播,所以脚本不需要 RPC。
- JavaScript
- Python
import { Keypair, VersionedTransaction } from "@solana/web3.js";
import bs58 from "bs58";
const wallet = Keypair.fromSecretKey(bs58.decode("<your wallet private key, base58>"));
// 全部销毁并关闭账户。
const { tx } = await (await fetch("https://sol.shrine.trade/api/burn", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ publicKey: wallet.publicKey.toBase58(), 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}`);
import base64, requests
from solders.keypair import Keypair
from solders.transaction import VersionedTransaction
wallet = Keypair.from_base58_string("<your wallet private key, base58>")
# 全部销毁并关闭账户。
r = requests.post("https://sol.shrine.trade/api/burn",
json={"publicKey": str(wallet.pubkey()), "mint": "<mint>", "amount": "100%"}).json()
raw = VersionedTransaction.from_bytes(base64.b64decode(r["tx"]))
signed = VersionedTransaction(raw.message, [wallet])
sent = requests.post("https://sol.shrine.trade/api/send",
json={"signedTx": base64.b64encode(bytes(signed)).decode()}).json()
print(sent["status"], sent["explorer"])