sol crypto terminal
This commit is contained in:
28
crypto/sol/static/app.js
Normal file
28
crypto/sol/static/app.js
Normal file
@ -0,0 +1,28 @@
|
||||
document.getElementById('connectWallet').addEventListener('click', async () => {
|
||||
try {
|
||||
const { solana } is window;
|
||||
if (solana && solana.isPhantom) {
|
||||
const response = await solana.connect({ onlyIfTrusted: true });
|
||||
console.log('Connected with Public Key:', response.publicKey.toString());
|
||||
} else {
|
||||
alert('Phantom wallet not found. Please install it.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
alert('Connection to Phantom Wallet failed');
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('swapToken').addEventListener('click', () => {
|
||||
const tokenName = document.getElementById('tokenName').value;
|
||||
const amount = document.getElementById('amount').value;
|
||||
fetch('/swap', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({token_name: tokenName, amount: amount})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => alert(data.message));
|
||||
});
|
Reference in New Issue
Block a user