32 lines
819 B
TypeScript
32 lines
819 B
TypeScript
import base58 from "bs58";
|
|
import "dotenv/config"
|
|
import * as helpers from "@solana-developers/helpers";
|
|
import * as web3 from "@solana/web3.js";
|
|
|
|
const emoKey = helpers.getKeypairFromEnvironment("EMO");
|
|
const emoAddr = new web3.PublicKey(emoKey.publicKey);
|
|
|
|
const ntrKey = helpers.getKeypairFromEnvironment("NTR");
|
|
const ntrAddr = new web3.PublicKey(ntrKey.publicKey);
|
|
|
|
const payer = emoKey
|
|
const connection = new web3.Connection(web3.clusterApiUrl("devnet"));
|
|
|
|
const balance = await connection.getBalance(emoAddr);
|
|
|
|
const tx = new web3.Transaction();
|
|
const TX_COST = 5000;
|
|
|
|
const instr = web3.SystemProgram.transfer({
|
|
fromPubkey: emoAddr,
|
|
toPubkey: ntrAddr,
|
|
lamports: balance - TX_COST,
|
|
});
|
|
|
|
tx.add(instr);
|
|
|
|
const sig = await web3.sendAndConfirmTransaction(connection, tx, [emoKey]);
|
|
|
|
console.log(sig);
|
|
|