wallet.html•16.9 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wallet Operations - Neo N3 MCP Examples</title>
<meta name="description" content="Learn wallet operations with Neo N3 MCP Server: create wallets, check balances, and transfer assets.">
<meta name="keywords" content="neo, blockchain, mcp, wallet, examples">
<!-- Favicon -->
<link rel="icon" type="image/svg+xml" href="/assets/favicon.svg">
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
<!-- Modern Theme -->
<link rel="stylesheet" href="/assets/css/modern-theme.css">
<style>
.breadcrumb {
color: var(--text-secondary);
margin-bottom: var(--spacing-lg);
}
.breadcrumb a {
color: var(--primary);
text-decoration: none;
}
.example-section {
margin-bottom: var(--spacing-3xl);
}
.example-section h2 {
font-family: var(--font-heading);
font-size: 1.75rem;
font-weight: 600;
margin-bottom: var(--spacing-lg);
color: var(--text-primary);
}
.next-steps {
margin-top: var(--spacing-3xl);
text-align: center;
}
.step-cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: var(--spacing-lg);
margin-top: var(--spacing-xl);
}
.step-card {
background: var(--bg-card);
padding: var(--spacing-xl);
border-radius: var(--radius-lg);
border: 1px solid var(--border-primary);
text-decoration: none;
color: inherit;
transition: var(--transition);
}
.step-card:hover {
transform: translateY(-4px);
box-shadow: var(--shadow-lg);
border-color: var(--primary);
}
.step-card h3 {
font-family: var(--font-heading);
font-size: 1.2rem;
font-weight: 600;
margin-bottom: var(--spacing-sm);
color: var(--text-primary);
}
.step-card p {
color: var(--text-secondary);
margin: 0;
}
</style>
</head>
<body>
<!-- Navigation -->
<nav class="nav" id="nav">
<div class="nav-container">
<a href="/" class="nav-logo">Neo N3 MCP</a>
<div class="nav-menu">
<a href="/" class="nav-link">Home</a>
<a href="/#features" class="nav-link">Features</a>
<a href="/docs" class="nav-link">Docs</a>
<a href="/examples" class="nav-link active">Examples</a>
<a href="https://github.com/r3e-network/neo-n3-mcp" class="btn btn-primary" target="_blank">Get Started</a>
</div>
</div>
</nav>
<div class="page-container">
<div class="breadcrumb">
<a href="/examples">Examples</a> > Wallet Operations
</div>
<header style="text-align: center; margin-bottom: 3rem;">
<h1 class="section-title">Wallet Operations</h1>
<p class="section-subtitle">
Complete guide to wallet management with Neo N3 MCP Server
</p>
</header>
<div class="example-section">
<h2>🆕 Creating a New Wallet</h2>
<p>Create a secure wallet with encrypted private key storage:</p>
<div class="code-window">
<div class="code-header">
<span class="code-lang">Create Wallet</span>
</div>
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<div class="code-content">
<pre>// Using MCP Tools
const result = await tools.create_wallet({
password: "secure_password_123",
name: "MyWallet"
});
console.log("Wallet created:", result);
// Output:
// {
// "address": "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj",
// "publicKey": "03c6aa6e12638b36c....",
// "encrypted": true,
// "name": "MyWallet"
// }</pre>
</div>
</div>
</div>
<div class="example-section">
<h2>📥 Importing an Existing Wallet</h2>
<p>Import a wallet using WIF (Wallet Import Format) or private key:</p>
<div class="code-window">
<div class="code-header">
<span class="code-lang">Import Wallet</span>
</div>
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<div class="code-content">
<pre>// Import from WIF
const walletFromWIF = await tools.import_wallet({
wif: "KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr",
password: "new_password_123",
name: "ImportedWallet"
});
// Import from private key
const walletFromKey = await tools.import_wallet({
privateKey: "1dd37fba80fec4e6a6f13fd708d8dcb3b29def768017052f6c930fa1c5d90bbb",
password: "secure_password",
name: "ImportedFromKey"
});</pre>
</div>
</div>
</div>
<div class="example-section">
<h2>💰 Checking Wallet Balance</h2>
<p>Get comprehensive balance information for NEO, GAS, and NEP-17 tokens:</p>
<div class="code-window">
<div class="code-header">
<span class="code-lang">Check Balance</span>
</div>
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<div class="code-content">
<pre>// Get balance for specific address
const balance = await tools.get_balance({
address: "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj"
});
console.log("Wallet balance:", balance);
// Output:
// {
// "NEO": "100",
// "GAS": "15.5234",
// "tokens": {
// "fWMP2dkWM": "1000.00", // Flamingo token
// "d2a4cFF31": "50.25" // Other NEP-17 token
// },
// "totalValueUSD": "1250.75"
// }</pre>
</div>
</div>
</div>
<div class="example-section">
<h2>💸 Transferring Assets</h2>
<p>Send NEO, GAS, or NEP-17 tokens to other addresses:</p>
<div class="code-window">
<div class="code-header">
<span class="code-lang">Transfer NEO</span>
</div>
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<div class="code-content">
<pre>// Transfer NEO tokens
const neoTransfer = await tools.transfer_neo({
fromAddress: "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj",
toAddress: "NYjzhdekseMYWvYpSoAeypqMiwMuEUDhKB",
amount: "10",
password: "wallet_password"
});
// Transfer GAS tokens
const gasTransfer = await tools.transfer_gas({
fromAddress: "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj",
toAddress: "NYjzhdekseMYWvYpSoAeypqMiwMuEUDhKB",
amount: "5.5",
password: "wallet_password"
});
console.log("Transfer completed:", gasTransfer);
// Output:
// {
// "txid": "0x1234567890abcdef...",
// "gasConsumed": "0.0234567",
// "confirmations": 1,
// "success": true
// }</pre>
</div>
</div>
</div>
<div class="example-section">
<h2>🪙 NEP-17 Token Operations</h2>
<p>Work with custom NEP-17 tokens:</p>
<div class="code-window">
<div class="code-header">
<span class="code-lang">NEP-17 Token Transfer</span>
</div>
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<div class="code-content">
<pre>// Get token information
const tokenInfo = await tools.get_nep17_token_info({
contractHash: "0xd2a4cff31913016155e38e474a2c06d08be276cf"
});
// Transfer NEP-17 tokens
const tokenTransfer = await tools.transfer_nep17({
fromAddress: "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj",
toAddress: "NYjzhdekseMYWvYpSoAeypqMiwMuEUDhKB",
contractHash: "0xd2a4cff31913016155e38e474a2c06d08be276cf",
amount: "100.5",
password: "wallet_password"
});
console.log("Token info:", tokenInfo);
// Output:
// {
// "symbol": "FLM",
// "decimals": 8,
// "totalSupply": "150000000.00000000",
// "name": "Flamingo"
// }</pre>
</div>
</div>
</div>
<div class="example-section">
<h2>📜 Transaction History</h2>
<p>Get transaction history for wallet addresses:</p>
<div class="code-window">
<div class="code-header">
<span class="code-lang">Get Transaction History</span>
</div>
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<div class="code-content">
<pre>// Get recent transactions
const history = await tools.get_address_transactions({
address: "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj",
limit: 10
});
console.log("Transaction history:", history);
// Output:
// {
// "transactions": [
// {
// "txid": "0xabcdef1234567890...",
// "blockHeight": 5678901,
// "timestamp": 1640995200,
// "type": "NEP17Transfer",
// "amount": "10.00000000",
// "asset": "NEO",
// "from": "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj",
// "to": "NYjzhdekseMYWvYpSoAeypqMiwMuEUDhKB"
// }
// ]
// }</pre>
</div>
</div>
</div>
<div class="example-section">
<h2>🏗️ Complete Wallet Manager Example</h2>
<p>A comprehensive wallet management class:</p>
<div class="code-window">
<div class="code-header">
<span class="code-lang">Wallet Manager Class</span>
</div>
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
<div class="code-content">
<pre>class NeoWalletManager {
constructor(mcpTools) {
this.tools = mcpTools;
this.wallets = new Map();
}
async createWallet(name, password) {
try {
const wallet = await this.tools.create_wallet({
name,
password
});
this.wallets.set(name, wallet);
console.log(`✅ Wallet "${name}" created successfully`);
return wallet;
} catch (error) {
console.error("❌ Failed to create wallet:", error);
throw error;
}
}
async getPortfolioValue(address) {
const balance = await this.tools.get_balance({ address });
const prices = await this.tools.get_asset_prices();
let totalValue = 0;
totalValue += parseFloat(balance.NEO || 0) * prices.NEO;
totalValue += parseFloat(balance.GAS || 0) * prices.GAS;
// Calculate token values
for (const [token, amount] of Object.entries(balance.tokens || {})) {
if (prices[token]) {
totalValue += parseFloat(amount) * prices[token];
}
}
return {
totalValueUSD: totalValue.toFixed(2),
breakdown: {
NEO: (parseFloat(balance.NEO || 0) * prices.NEO).toFixed(2),
GAS: (parseFloat(balance.GAS || 0) * prices.GAS).toFixed(2),
tokens: balance.tokens
}
};
}
async transferWithConfirmation(from, to, asset, amount, password) {
console.log(`🔄 Initiating transfer: ${amount} ${asset}`);
// Estimate fees first
const feeEstimate = await this.tools.estimate_transfer_fee({
fromAddress: from,
toAddress: to,
asset,
amount
});
console.log(`💰 Estimated fee: ${feeEstimate.fee} GAS`);
// Execute transfer
let result;
if (asset === 'NEO') {
result = await this.tools.transfer_neo({
fromAddress: from,
toAddress: to,
amount,
password
});
} else if (asset === 'GAS') {
result = await this.tools.transfer_gas({
fromAddress: from,
toAddress: to,
amount,
password
});
}
console.log(`✅ Transfer completed: ${result.txid}`);
return result;
}
}
// Usage example
const walletManager = new NeoWalletManager(mcpTools);
// Create and manage wallets
await walletManager.createWallet("MainWallet", "secure123");
const portfolio = await walletManager.getPortfolioValue("NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj");
console.log("Portfolio value:", portfolio);</pre>
</div>
</div>
</div>
<div class="next-steps">
<h2>Next Steps</h2>
<div class="step-cards">
<a href="/examples/contracts" class="step-card">
<h3>Smart Contract Interaction</h3>
<p>Learn to interact with Neo N3 smart contracts</p>
</a>
<a href="/examples/explorer" class="step-card">
<h3>Blockchain Explorer</h3>
<p>Query blockchain data and transaction details</p>
</a>
<a href="/docs/api" class="step-card">
<h3>Full API Reference</h3>
<p>Complete documentation of all available tools</p>
</a>
</div>
</div>
</div>
<!-- Footer -->
<footer class="footer">
<div class="footer-container">
<div class="footer-grid">
<div>
<div class="footer-brand">Neo N3 MCP</div>
<p class="footer-description">
The most advanced Neo N3 blockchain development platform.
Build powerful dApps with enterprise-grade tools and security.
</p>
</div>
<div>
<h4 class="footer-title">Product</h4>
<div class="footer-links">
<a href="/docs" class="footer-link">Documentation</a>
<a href="/examples" class="footer-link">Examples</a>
<a href="/changelog" class="footer-link">Changelog</a>
</div>
</div>
<div>
<h4 class="footer-title">Resources</h4>
<div class="footer-links">
<a href="https://docs.neo.org/" class="footer-link" target="_blank">Neo N3 Docs</a>
<a href="https://modelcontextprotocol.io/" class="footer-link" target="_blank">MCP Protocol</a>
<a href="https://www.npmjs.com/package/@r3e/neo-n3-mcp" class="footer-link" target="_blank">NPM Package</a>
</div>
</div>
<div>
<h4 class="footer-title">Community</h4>
<div class="footer-links">
<a href="https://github.com/r3e-network/neo-n3-mcp" class="footer-link" target="_blank">GitHub</a>
<a href="https://github.com/r3e-network/neo-n3-mcp/discussions" class="footer-link" target="_blank">Discussions</a>
<a href="https://discord.gg/neo" class="footer-link" target="_blank">Discord</a>
</div>
</div>
</div>
<div class="footer-bottom">
<p>© 2025 Neo N3 MCP. Open source under MIT License.</p>
<p>Built with ❤️ for the Neo ecosystem</p>
</div>
</div>
</footer>
<script>
// Navigation scroll effect
window.addEventListener('scroll', () => {
const nav = document.getElementById('nav');
if (window.scrollY > 50) {
nav.classList.add('scrolled');
} else {
nav.classList.remove('scrolled');
}
});
function copyCode(button) {
const codeBlock = button.nextElementSibling.querySelector('pre');
const text = codeBlock.textContent;
navigator.clipboard.writeText(text).then(() => {
button.textContent = 'Copied!';
setTimeout(() => {
button.textContent = 'Copy';
}, 2000);
});
}
</script>
</body>
</html>