Blockchain

Solana (SOL)

2025-12-273 min read

Solana (SOL)

์š”์•ฝ

  1. ์ค‘์•™ํ™”๋ฅผ ๋ฒ—์–ด๋‚˜์ง€ ๋ชปํ•จ. ์žฌ๋‹จ์—์„œ ๋„คํŠธ์›Œํฌ๋ฅผ ๊ป๋‹ค ์ผฐ๋‹ค ํ•  ์ˆ˜ ์žˆ์Œ
  2. ๋…ธ๋“œ๊ฐ€ ์—„์ฒญ ์ž˜ ์ฃฝ์Œ (์˜ฌํ•ด๋งŒ ๋ช‡ ๋ฒˆ ์ค‘์ง€๋˜์—ˆ๋Š”์ง€..)
  3. ์†”๋ผ๋‚˜์™€ ์†”๋ผ๋‚˜ ํ”„๋กœ๊ทธ๋žจ(์ปจํŠธ๋ž™ํŠธ) ๊ฐœ๋ฐœ์–ธ์–ด๊ฐ€ ํ†ต์ผ๋˜์–ด ์žˆ๋‹ค๋Š”๊ฒŒ ๋งค์šฐ ๋งค๋ ฅํฌ์ธํŠธ
  4. ์žฌ๋‹จ์—์„œ ์ œ๊ณตํ•˜๋Š” ํˆด๋“ค์ด ๋„ˆ๋ฌด ํ™˜์ƒ์ ์ž„. ์•„์ด๋””์–ด๋งŒ ์žˆ๋‹ค๋ฉด ๋Œ€์ถฉ ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ์„ ์ •๋„
  5. ์ด๊ฒƒ๋„ mempool์ด ์—†์Œ

How to create and manage address or account?

Using Private Key

const account = Keypair.generate()
console.log(JSON.stringify(account.publicKey.toBase58()))
// output: "gVazpxjimX3EP4mto53pEi4YSE36KP2nDwyEvLcKjmR"

Using Mnemonic

const mnemonic =
	'pill tomorrow foster begin walnut borrow virtual kick shift mutual shoe scatter'
const seed = bip39.mnemonicToSeedSync(mnemonic, '') // (mnemonic, password)

// BIP39
const keypair = Keypair.fromSeed(seed.slice(0, 32))

// BIP44
for (let i = 0; i < 10; i++) {
	const path = `m/44'/501'/${i}'/0'`
	const keypair = Keypair.fromSeed(derivePath(path, seed.toString('hex')).key)
	console.log(`${path} => ${keypair.publicKey.toBase58()}`)
}

// Check if a given public key has an associated private key
const key = new PublicKey('5oNDL3swdJJF1g9DzJiZ4ynHXgszjAEpUkxVYejchzrY')
console.log(PublicKey.isOnCurve(key.toBytes()))

How to sign and verify messages with wallets

const message = "The quick brown fox jumps over the lazy dog";
const messageBytes = decodeUTF8(message);

const signature = nacl.sign.detached(messageBytes, keypair.secretKey);
const result = nacl.sign.detached.verify(
  messageBytes,
  signature,
  keypair.publicKey.toBytes()
);

console.log(result);

-------------------------------------------------------------------------------

{
  let recoverTx = Transaction.populate(Message.from(realDataNeedToSign));
  recoverTx.addSignature(feePayer.publicKey, Buffer.from(feePayerSignature));
  recoverTx.addSignature(alice.publicKey, Buffer.from(aliceSignature));

  console.log(
    `txhash: ${await connection.sendRawTransaction(recoverTx.serialize())}`
  );
}

-------------------------------------------------------------------------------

{
  let recoverTx = Transaction.populate(Message.from(realDataNeedToSign), [
    bs58.encode(feePayerSignature),
    bs58.encode(aliceSignature),
  ]);
  console.log(
    `txhash: ${await connection.sendRawTransaction(recoverTx.serialize())}`
  );
}

How to query balance of address on blockchain?

How to query transaction?

How to add a memo to a tx?

const transferTransaction = new Transaction().add(
	SystemProgram.transfer({
		fromPubkey: fromKeypair.publicKey,
		toPubkey: toKeypair.publicKey,
		lamports: lamportsToSend,
	}),
)

await transferTransaction.add(
	new TransactionInstruction({
		keys: [
			{ pubkey: fromKeypair.publicKey, isSigner: true, isWritable: true },
		],
		data: Buffer.from('Data to send in transaction', 'utf-8'),
		programId: new PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr'),
	}),
)

await sendAndConfirmTransaction(connection, transferTransaction, [fromKeypair])

How to estimate fee?

getEstimatedFee
const recentBlockhash = await connection.getLatestBlockhash()
const transaction = new Transaction({
	recentBlockhash: recentBlockhash.blockhash,
}).add(
	SystemProgram.transfer({
		fromPubkey: payer.publicKey,
		toPubkey: payee.publicKey,
		lamports: 10,
	}),
)

const fees = await transaction.getEstimatedFee(connection)
console.log(`Estimated SOL transfer cost: ${fees} lamports`)
// Estimated SOL transfer cost: 5000 lamports

// getFeeForMessage
const message = new Message(messageParams)

const fees = await connection.getFeeForMessage(message)
console.log(`Estimated SOL transfer cost: ${fees.value} lamports`)
// Estimated SOL transfer cost: 5000 lamports

How to Transfer tokens one to another?

// Send SOL
const transferTransaction = new Transaction().add(
	SystemProgram.transfer({
		fromPubkey: fromKeypair.publicKey,
		toPubkey: toKeypair.publicKey,
		lamports: lamportsToSend,
	}),
)

await sendAndConfirmTransaction(connection, transferTransaction, [fromKeypair])

// Send SPL Token
// Add token transfer instructions to transaction
const transaction = new web3.Transaction().add(
	splToken.Token.createTransferInstruction(
		splToken.TOKEN_PROGRAM_ID,
		fromTokenAccount.address,
		toTokenAccount.address,
		fromWallet.publicKey,
		[],
		1,
	),
)

// Sign transaction, broadcast, and confirm
await web3.sendAndConfirmTransaction(connection, transaction, [fromWallet])

Build Frontend and deploy contract to Solana devnet

I using rust, anchor to develop smart contract. All I have to do is initializing some struct, and add methods in main program module. Itโ€™s quite easy to understand, and I think itโ€™s simillar with creating and using gRPC.

Screenshot of Demo project (thx to https://buildspace.so)

Share

Related Articles

Comments

์ด ๋ธ”๋กœ๊ทธ๋Š” ์ œ๊ฐ€ ์•Œ๊ณ  ์žˆ๋Š” ๊ฒƒ๋“ค์„ ์žŠ์ง€ ์•Š๊ธฐ ์œ„ํ•ด ๊ธฐ๋กํ•˜๋Š” ๊ณต๊ฐ„์ž…๋‹ˆ๋‹ค.
์ง์ ‘ ์ž‘์„ฑํ•œ ๊ธ€๋„ ์žˆ๊ณ , AI์˜ ๋„์›€์„ ๋ฐ›์•„ ์ •๋ฆฌํ•œ ๊ธ€๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
์ •ํ™•ํ•˜์ง€ ์•Š์€ ๋‚ด์šฉ์ด ์žˆ์„ ์ˆ˜ ์žˆ์œผ๋‹ˆ ์ฐธ๊ณ ์šฉ์œผ๋กœ ๋ด์ฃผ์„ธ์š”.

ยฉ 2026 Seogyu Kim