import * as web3 from "@solana/web3.js";
const BN = require ("bn.js");
const connection = new web3.Connection(web3.clusterApiUrl("devnet"));
async function main() {
const key: Uint8Array = Uint8Array.from([PRIVATE KEY del que paga]);
const signer: web3.Keypair = web3.Keypair.fromSecretKey(key);
let programId: web3.PublicKey = new web3.PublicKey("Tu ProgramId");
const data: Buffer = Buffer.from(
Uint8Array.of(0, ...new BN(VALOR ENTERO DE 8 BITS).toArray("le",8))
);
let transaction: web3.Transaction = new web3.Transaction();
transaction.add(
new web3.TransactionInstruction({
keys: [],
programId,
data
})
);
await web3.sendAndConfirmTransaction(
connection, transaction, [signer])
.then((sig) => {
console.log("signature:{}",sig);
});
}
main()
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter