Neo N3 DApp Integration Guide
This guide provides comprehensive information about integrating with Neo N3 DApps through the Neo N3 MCP Server. The server supports several popular Neo N3 DApps, allowing AI assistants to interact with these applications through a standardized interface.
What are Neo N3 DApps?
Neo N3 DApps (Decentralized Applications) are applications that run on the Neo N3 blockchain. They leverage smart contracts to provide various services, from decentralized storage to financial applications, without relying on centralized servers or authorities.
Contract Availability
Not all contracts are available on both mainnet and testnet. The table below shows the availability of each contract:
Contract | Mainnet | Testnet | Description |
---|---|---|---|
NeoFS | ✅ | ✅ | Decentralized storage system |
NeoBurger | ✅ | ❌ | Neo staking service |
Flamingo | ✅ | ❌ | DeFi platform with AMM and staking |
NeoCompound | ✅ | ❌ | Automatic yield farming protocol |
GrandShare | ✅ | ❌ | Profit sharing protocol |
GhostMarket | ✅ | ❌ | NFT marketplace |
Important
Always check contract availability before attempting to interact with a contract. Trying to use a contract that is not available on the selected network will result in an error.
NeoFS
Overview
NeoFS is a distributed, decentralized object storage network built on the Neo blockchain. It allows users to store and retrieve data in a decentralized manner, with data integrity guaranteed by the blockchain.
Contract Information
- Name: NeoFS
- Mainnet Script Hash: 0x50ac1c37690cc2cfc594472833cf57505d5f46de
- Testnet Script Hash: 0xccca29443855a1c455d72a3318cf605debb9e384
- Available on: Mainnet, Testnet
Operations
The following operations are available for the NeoFS contract:
Operation | Description | Parameters |
---|---|---|
createContainer | Create a new storage container |
|
getContainers | Get containers owned by an address |
|
getContainerInfo | Get information about a container |
|
Examples
Creating a Container
const result = await client.callTool('neofs_create_container', {
walletPath: '/path/to/wallet.json',
walletPassword: 'password',
ownerId: 'your-owner-id',
rules: [
{ key: 'Placement', value: 'REP 3 IN X CBF 1 SELECT 1 FROM * AS X' },
{ key: 'StoragePolicy', value: 'REP 3' }
],
network: 'mainnet'
});
console.log('Container created:', result);
Getting Containers
const result = await client.callTool('neofs_get_containers', {
ownerId: 'your-owner-id',
network: 'mainnet'
});
console.log('Containers:', result.containers);
NeoBurger
Overview
NeoBurger is a Neo N3 staking service that simplifies the process of earning GAS rewards. Users can deposit their NEO tokens to earn GAS without the complexity of running a consensus node.
Contract Information
- Name: NeoBurger
- Mainnet Script Hash: 0x48c40d4666f93408be1bef038b6722404d9a4c2a
- Available on: Mainnet only
Operations
The following operations are available for the NeoBurger contract:
Operation | Description | Parameters |
---|---|---|
depositNeo | Deposit NEO to NeoBurger |
|
withdrawNeo | Withdraw NEO from NeoBurger |
|
balanceOf | Get NeoBurger balance |
|
claimGas | Claim GAS rewards |
|
Examples
Depositing NEO
const result = await client.callTool('neoburger_deposit', {
walletPath: '/path/to/wallet.json',
walletPassword: 'password',
network: 'mainnet'
});
console.log('Deposit transaction:', result.txid);
Getting Balance
const result = await client.callTool('neoburger_get_balance', {
address: 'NXV7ZhHaLY2GNjp6R1AYBV9FqrVnGLfQcz',
network: 'mainnet'
});
console.log('NeoBurger balance:', result.amount);
Flamingo
Overview
Flamingo is a Neo N3 DeFi platform that offers various financial services, including an automated market maker (AMM), staking, and yield farming. It allows users to trade tokens, provide liquidity, and earn rewards.
Contract Information
- Name: Flamingo
- Mainnet Script Hash: 0xf970f4ccecd765b63732b821775dc38c25d74b39
- Available on: Mainnet only
Operations
The following operations are available for the Flamingo contract:
Operation | Description | Parameters |
---|---|---|
stake | Stake FLM tokens |
|
unstake | Unstake FLM tokens |
|
getStakedAmount | Get staked amount |
|
claimRewards | Claim staking rewards |
|
Examples
Staking FLM
const result = await client.callTool('flamingo_stake', {
walletPath: '/path/to/wallet.json',
walletPassword: 'password',
amount: '100',
network: 'mainnet'
});
console.log('Stake transaction:', result.txid);
Getting Staked Amount
const result = await client.callTool('flamingo_get_staked_amount', {
address: 'NXV7ZhHaLY2GNjp6R1AYBV9FqrVnGLfQcz',
network: 'mainnet'
});
console.log('Staked amount:', result.amount);
Best Practices
Follow these best practices when integrating with Neo N3 DApps:
-
Check Contract Availability
Always check if a contract is available on your target network before attempting to interact with it:
const contracts = await client.callTool('list_famous_contracts', { network: 'mainnet' }); const isAvailable = contracts.contracts.some( c => c.name.toLowerCase() === 'neoburger' && c.available );
-
Handle Rate Limits
The service implements rate limiting to prevent abuse. Handle potential rate limit errors in your application:
try { const result = await client.callTool('neoburger_deposit', { // parameters }); } catch (error) { if (error.message.includes('Rate limit exceeded')) { // Handle rate limit error console.error('Rate limit exceeded. Please try again later.'); } else { // Handle other errors console.error('Operation failed:', error.message); } }
-
Validate Inputs Client-Side
While the service performs server-side validation, implementing client-side validation can improve user experience by catching errors earlier:
function validateAddress(address) { // Neo N3 addresses are 34 characters long and start with 'N' return typeof address === 'string' && address.length === 34 && address.startsWith('N'); }
-
Monitor Transaction Status
After invoking a write operation, monitor the transaction status to confirm it was successfully processed on the blockchain:
const result = await client.callTool('neoburger_deposit', { // parameters }); // Get the transaction ID const txid = result.txid; // Monitor transaction status const txStatus = await client.callTool('get_transaction', { txid: txid, network: 'mainnet' });
-
Use Testnet First
When developing new integrations, test on the testnet first before moving to mainnet (for contracts that are available on testnet).
Error Handling
The Neo N3 MCP Server uses specific error types to provide clear information about failures:
Error Type | Description | Example |
---|---|---|
ContractError | Thrown when a contract operation fails | "Contract execution failed: FAULT Exception" |
ValidationError | Thrown when input validation fails | "Invalid address format: ABC123" |
NetworkError | Thrown when there are network-related issues | "Failed to connect to RPC endpoint" |
RateLimitError | Thrown when rate limits are exceeded | "Rate limit exceeded. Try again in 60 seconds." |
Example Error Handling
try {
const result = await client.callTool('neoburger_deposit', {
walletPath: '/path/to/wallet.json',
walletPassword: 'password',
network: 'mainnet'
});
console.log('Deposit successful:', result);
} catch (error) {
if (error.message.includes('Contract not available')) {
console.error('NeoBurger contract is not available on this network');
} else if (error.message.includes('Rate limit')) {
console.error('Rate limit exceeded. Please try again later.');
} else if (error.message.includes('Invalid address')) {
console.error('Invalid address format');
} else if (error.message.includes('Failed to connect')) {
console.error('Network connection issue. Please check your internet connection.');
} else {
console.error('Operation failed:', error.message);
}
}