Add example client file

This commit is contained in:
mgild 2022-07-26 16:57:27 -04:00
parent 53894837d0
commit 7a272c0200
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
import { Connection, Keypair, PublicKey, Transaction } from "@solana/web3.js";
import { readResult } from "./instructions/readResult";
async function main() {
const payer = Keypair.fromSecretKey(
new Uint8Array(
JSON.parse(require("fs").readFileSync(process.argv[2], "utf8"))
)
);
const connection = new Connection(
"https://switchboard.devnet.rpcpool.com/f9fe774d81ba4527a418f5b19477",
"confirmed"
);
const ix = readResult(
{ params: { maxConfidenceInterval: null } },
{
aggregator: new PublicKey("8SXvChNYFhRq4EZuZvnhjrB3jJRQCv4k3P4W6hesH3Ee"),
}
);
const tx = new Transaction();
tx.add(ix);
tx.feePayer = payer.publicKey;
const sig = await connection.sendTransaction(tx, [payer]);
console.log(`https://explorer.solana.com/tx/${sig}?cluster=devnet`);
}
(async () => await main())();