Skip to content

Instantly share code, notes, and snippets.

@AlexBHarley
Created November 27, 2021 18:46
Show Gist options
  • Save AlexBHarley/f2a0c515d9063f58afa110619e4b33db to your computer and use it in GitHub Desktop.
Save AlexBHarley/f2a0c515d9063f58afa110619e4b33db to your computer and use it in GitHub Desktop.
import {
ASSOCIATED_TOKEN_PROGRAM_ID,
Token,
TOKEN_PROGRAM_ID,
} from '@solana/spl-token';
import { Connection, PublicKey } from '@solana/web3.js';
const STSOL = new PublicKey('7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj');
const SUNNY = new PublicKey('SUNNYWgPQmFxe9wTZzNK7iPnJ3vYDrkgnxJRJm1s3ag');
const ADDRESS = new PublicKey('83vertij8i4hZpN5UHj2FGjuyCkWKsaypecS8FvNK4Ah');
(async function () {
const connection = new Connection(
'https://solana-api.projectserum.com',
'confirmed'
);
const sunnyAddress = await Token.getAssociatedTokenAddress(
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
SUNNY,
ADDRESS
);
const stsolAddress = await Token.getAssociatedTokenAddress(
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
STSOL,
ADDRESS
);
console.log(sunnyAddress.toBase58(), stsolAddress.toBase58());
const sunny = new Token(connection, SUNNY, TOKEN_PROGRAM_ID, null);
const stsol = new Token(connection, STSOL, TOKEN_PROGRAM_ID, null);
console.log('sunny', await sunny.getAccountInfo(sunnyAddress));
console.log('stsol', await stsol.getAccountInfo(stsolAddress));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment