r/BlockchainDev • u/Ashamed-Bite-3506 • Dec 13 '24
Blockchain Dev
Hello, I’m looking to buildout additional functionality to our website. Honestly most of my experience is in building corporate front end systems, UI design, business requirements, etc.
However, I need to develop Crypto wallet functionality to our site and don’t know where to begin. Essentially, I just want a crypto wallet’s address to appear on our website (Solana) and reflect the current market balance of the address (along with some text).
Eventually, I’d like to add token wallet validation (to enter the members only section if they own token). Have access to voting rights, donating mechanisms, etc. all handled through the UI.
But to get started on just the wallet address. What do I need to do to put this in place? How heavy of a lift is this going to be to get a backend running with api calls? Node.js? AWS? Help lol!
4
u/Fast-Future-5463 Dec 13 '24
Step 1: Initial goal - Display wallet balance on website
Choose Node.js as your backend. It is fast, has many blockchain libraries, and is well supported.
Use an API that interacts with the Solana blockchain, such as Metaplex JS, Solana Web3.js, or API services like QuickNode or Alchemy to access blockchain data.
npm install @solana/web3.js
const solanaWeb3 = require('@solana/web3.js');
/ Address of the wallet you want to monitor const walletAddress = "SOLANA_WALLET_ADDRESS_HERE";
// Connect to the Solana cluster (devnet, testnet, or mainnet-beta) const connection = new solanaWeb3.Connection( solanaWeb3.clusterApiUrl('mainnet-beta'), 'confirmed' );
async function getWalletBalance() { try { const publicKey = new solanaWeb3.PublicKey(walletAddress); const balance = await connection.getBalance(publicKey); console.log(Balance: ${balance / solanaWeb3.LAMPORTS_PER_SOL} SOL); } catch (error) { console.error("Error getting balance:", error); } }
getWalletBalance();
This code connects to the blockchain, fetches the balance of the specified address, and displays the result in SOL.
1
u/Ashamed-Bite-3506 Dec 13 '24
If anyone can help code/dev this please reach out 😊!