10. Integration Guide

This guide is for developers who want to integrate the Amadeus Wallet Extension into their decentralized applications (dApps).

Overview

The Amadeus Wallet Extension provides a JavaScript API that dApps can use to interact with user wallets. This allows users to sign transactions and interact with smart contracts directly from web applications.

API Reference

Checking Wallet Availability

Before using the wallet API, check if it's available:

if (typeof window.amadeus !== 'undefined') {
	// Wallet is available
	console.log('Amadeus wallet detected')
} else {
	// Wallet not installed
	console.log('Amadeus wallet not found')
}

Requesting Accounts

Request access to user's wallet accounts:

try {
	const accounts = await window.amadeus.requestAccounts()
	console.log('Connected accounts:', accounts)
	// Returns: ['5KJvsngHeMoo884xkJ6Cyb5StvnRN6f9tYiqwqJzLpQq']
} catch (error) {
	console.error('Failed to connect:', error.message)
}

Response:

  • Array of account addresses (Base58 encoded)

  • User must approve connection request

  • Returns current account if already connected

Signing Transactions

Sign a transaction request:

Parameters:

  • contract (string): Contract name or address

  • method (string): Function name to call

  • args (array): Function arguments

  • description (string, optional): Human-readable description

Response:

  • txHash (string): Transaction hash

  • txPacked (Uint8Array): Packed transaction bytes

Event Listeners

Listen for wallet connection/disconnection:

Integration Examples

Basic Connection Flow

Token Transfer Example

Contract Interaction Example

Error Handling

Common Errors

Best Practices

User Experience

  1. Check Availability First

  2. Handle Rejections Gracefully

  3. Provide Clear Descriptions

  4. Show Loading States

Security

  1. Validate Inputs

    • Verify addresses before requesting signatures

    • Validate amounts and parameters

    • Check contract addresses

  2. Handle Errors Properly

    • Don't expose sensitive information

    • Provide helpful error messages

    • Log errors for debugging

  3. Verify Transactions

    • Verify transaction hash after signing

    • Check transaction status on blockchain

    • Handle failed transactions

TypeScript Support

If using TypeScript, you can define types:

Testing

Testnet Testing

Always test on Testnet first:

  1. Ensure users are on Testnet

  2. Use Testnet tokens for testing

  3. Verify transactions on Testnet explorer

Mock Implementation

For development without extension:

React Integration Example

We provide a complete React + TypeScript demo application that showcases how to integrate the Amadeus Wallet Extension into a modern React application.

Repository

GitHub: amadeus-wallet-extension-react-demoarrow-up-right

Live Demo: amadeus-wallet-extension-react-demo.vercel.apparrow-up-right

Features Demonstrated

The demo includes working examples of:

  • Provider Detection: Automatically detects wallet availability and listens for initialization events

  • Account Management: Connect/disconnect flows with requestAccounts() and accountsChanged event handling

  • Token Transfers: Complete AMA token transfer flow with signing and submission

  • Custom Contract Calls: Sign arbitrary contract calls with custom arguments

  • Transaction History: Track signed transactions with status updates

  • Event Logging: Real-time event logging for debugging and observability

  • Network Configuration: Configurable API endpoint for local node testing

Tech Stack

  • React 19

  • TypeScript

  • Vite

  • Tailwind CSS

  • shadcn/ui components

Getting Started

Key Hooks and Components

The demo provides reusable React hooks:

  • useAmadeus(): Core wallet integration hook

  • useWallet(): Wallet connection state management

  • useTransfer(): Token transfer operations

  • useCustomCall(): Custom contract call handling

  • useTransactionHistory(): Transaction tracking

These hooks can be adapted for your own React applications. See the repository's README for detailed documentation on each hook and component.

Resources

Support

For integration support:

  • Check extension documentation

  • Review SDK documentation

  • Test on Testnet first

  • Report issues through official channels

Last updated