COTI Snap - MetaMask Snap for managing confidential tokens and confidential transactions
npm install @coti-io/coti-snapA MetaMask Snap for managing AES keys and confidential tokens on the COTI network.
- š 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
1. Install MetaMask if you haven't already
2. Visit the companion dapp: https://metamask.coti.io
3. Connect your wallet and follow the installation prompts
4. Generate your AES key to start managing confidential tokens
``bashClone the repository
git clone https://github.com/coti-io/coti-snap.git
cd coti-snap
Usage
$3
`typescript
// 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' });
`$3
`typescript
// 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
$3
| 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 |$3
The snap requires the following permissions:
-
snap_dialog: For user confirmations
- snap_manageState: For secure state storage
- endowment:ethereum-provider: For blockchain interactions
- endowment:network-access: For API calls
- endowment:rpc: For dapp communicationSecurity
- 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
$3
`
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 configuration
`$3
`bash
Development build with watch mode
yarn workspace @coti-io/coti-snap startProduction build
yarn workspace @coti-io/coti-snap buildClean build
yarn workspace @coti-io/coti-snap build:clean
`$3
`bash
Run all tests
yarn workspace @coti-io/coti-snap testRun tests in watch mode
yarn workspace @coti-io/coti-snap test --watch
``1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests for new functionality
5. Ensure all tests pass
6. Submit a pull request
MIT License - see LICENSE for details.
- Documentation: https://docs.coti.io
- Discord: COTI Community
- GitHub Issues: Report bugs here
- v1.0.0: Initial production release with AES key management and confidential token support