@coti-io/coti-snap
v1.0.19-8ac5b7
Published
COTI Snap - MetaMask Snap for managing confidential tokens and confidential transactions
Readme
COTI AES Key Manager Snap
A MetaMask Snap for managing AES keys and confidential tokens on the COTI network.
Features
- 🔐 AES Key Management: Securely store and manage AES keys in MetaMask
- 🪙 Confidential Tokens: View and manage confidential ERC-20 tokens
- 🖼️ NFT Support: Handle confidential NFTs with metadata
- 🔄 Token Operations: Transfer and deposit tokens
- 🛡️ Secure Storage: Encrypted storage within MetaMask's secure environment
- 🔗 COTI Network: Native support for COTI's confidential blockchain
Installation
For Users
- Install MetaMask if you haven't already
- Visit the companion dapp: https://metamask.coti.io
- Connect your wallet and follow the installation prompts
- Generate your AES key to start managing confidential tokens
For Developers
# Clone the repository
git clone https://github.com/coti-io/coti-snap.git
cd coti-snap
# Install dependencies
yarn install
# Build the snap
yarn workspace @coti-io/coti-snap build
# Run tests
yarn workspace @coti-io/coti-snap test
# Start development server
yarn workspace @coti-io/coti-snap startUsage
AES Key Management
// Check if user has AES key
const hasKey = await invokeSnap({ method: 'has-aes-key' });
// Get AES key (requires user confirmation)
const aesKey = await invokeSnap({ method: 'get-aes-key' });
// Set AES key
await invokeSnap({
method: 'set-aes-key',
params: { newUserAesKey: 'your-aes-key' }
});
// Delete AES key
await invokeSnap({ method: 'delete-aes-key' });Encryption/Decryption
// Encrypt data
const encrypted = await invokeSnap({
method: 'encrypt',
params: { value: 'data-to-encrypt' }
});
// Decrypt data
const decrypted = await invokeSnap({
method: 'decrypt',
params: { value: encryptedData }
});API Reference
RPC Methods
| Method | Description | Parameters |
|--------|-------------|------------|
| has-aes-key | Check if AES key exists | None |
| get-aes-key | Retrieve AES key | None |
| set-aes-key | Store AES key | { newUserAesKey: string } |
| delete-aes-key | Remove AES key | None |
| encrypt | Encrypt data | { value: string } |
| decrypt | Decrypt data | { value: string } |
| connect-to-wallet | Connect to MetaMask | None |
| get-permissions | Get wallet permissions | None |
Permissions
The snap requires the following permissions:
snap_dialog: For user confirmationssnap_manageState: For secure state storageendowment:ethereum-provider: For blockchain interactionsendowment:network-access: For API callsendowment:rpc: For dapp communication
Security
- AES keys are stored securely in MetaMask's encrypted storage
- All operations require user confirmation through MetaMask dialogs
- State is isolated per chain and address
- No sensitive data is logged or exposed
Development
Project Structure
packages/snap/
├── src/
│ ├── components/ # Snap UI components
│ ├── config/ # Configuration files
│ ├── utils/ # Utility functions
│ ├── test/ # Test files
│ └── index.tsx # Main snap entry point
├── images/ # Snap icons
├── snap.manifest.json # Snap manifest
└── package.json # Package configurationBuilding
# Development build with watch mode
yarn workspace @coti-io/coti-snap start
# Production build
yarn workspace @coti-io/coti-snap build
# Clean build
yarn workspace @coti-io/coti-snap build:cleanTesting
# Run all tests
yarn workspace @coti-io/coti-snap test
# Run tests in watch mode
yarn workspace @coti-io/coti-snap test --watchContributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
MIT License - see LICENSE for details.
Support
- Documentation: https://docs.coti.io
- Discord: COTI Community
- GitHub Issues: Report bugs here
Version History
- v1.0.0: Initial production release with AES key management and confidential token support
