ENC Protocol wallet module for Tether WDK
ENC Protocol wallet module for Tether WDK. Registers ENC as a "blockchain" in WDK alongside EVM, BTC, TON, etc.
npm install @enc-protocol/wdk-wallet-enc @tetherto/wdkimport WDK from '@tetherto/wdk'
import { WalletEvm } from '@tetherto/wdk-wallet-evm'
import { WalletEnc } from '@enc-protocol/wdk-wallet-enc'
const wdk = new WDK(seedPhrase)
wdk.register(new WalletEvm({ provider: rpcUrl }))
wdk.register(new WalletEnc({ nodeUrl: 'https://node.enc.dev' }))
// Same seed, two identities
const evm = await wdk.getAccount('evm') // EVM address
const enc = await wdk.getAccount('enc') // ENC identity
// ENC account
enc.getAddress() // x-only pubkey hex (ENC identity)
enc.getEvmAddress() // EVM address (same key, ECDSA)
enc.sign(message) // Schnorr signature
enc.ecdh(theirPub) // ECDH shared secret (DM encryption)
enc.keyPair // { publicKey, privateKey } raw bytesUses the same BIP-44 path as EVM: m/44'/60'/0'/0/{index}. The same 32-byte secp256k1 private key serves both:
Works everywhere WDK works:
new WalletEnc({ nodeUrl, registryUrl })Extends WalletManager. Registered via wdk.register().
| Method | Returns | Description |
|---|---|---|
getAddress() | string | x-only pubkey hex (64 chars) |
getEvmAddress() | string | EVM address from same key |
sign(message) | Uint8Array | BIP-340 Schnorr signature |
verify(message, sig) | boolean | Verify Schnorr signature |
ecdh(theirPubHex) | Uint8Array | ECDH shared secret |
keyPair | { publicKey, privateKey } | Raw key bytes |
pubHex | string | Shorthand for x-only pubkey hex |
dispose() | void | Securely wipe private key |
| Method | Description |
|---|---|
WalletAccountEnc.encPubToEvmAddress(hex) | Resolve x-only → [evenY, oddY] EVM candidates |
Wraps EVM transfer() to automatically create encrypted DM messages with tx_hash when payments succeed.
import WDK from '@tetherto/wdk'
import { WalletEvm } from '@tetherto/wdk-wallet-evm'
import { WalletEnc, createPaymentMiddleware } from '@enc-protocol/wdk-wallet-enc'
import { DMSDK } from '@enc-protocol/dm'
const wdk = new WDK(seedPhrase)
wdk.register(new WalletEvm({ provider: rpcUrl }))
wdk.register(new WalletEnc({ nodeUrl }))
const enc = await wdk.getAccount('enc')
const dm = new DMSDK({ privateKey: enc.keyPair.privateKey, nodeUrl, registryUrl })
// Register middleware — wraps EVM transfers with DM notifications
wdk.registerMiddleware('ethereum', createPaymentMiddleware({
dmSdk: dm,
resolvePub: async (evmAddr) => {
// Resolve EVM address → ENC pubkey via registry
return registry.lookupByEvmAddress(evmAddr)
},
onCommit: (result) => console.log('DM sent:', result),
onError: (err) => console.warn('DM failed (payment succeeded):', err),
}))
// Now any EVM transfer auto-creates a DM
const evm = await wdk.getAccount('evm')
await evm.transfer({
token: 'USDT0',
recipient: '0xBob...',
amount: '10.00',
})
// → USDT0 sent on-chain
// → Encrypted DM "Sent 10.00 USDT0" with tx_hash auto-sent to BobOptions:
| Option | Type | Description | |
|---|---|---|---|
dmSdk | DMSDK | Initialized DM SDK instance | |
resolvePub | `async (evmAddr) => string \ | null` | Resolve EVM address to ENC pubkey. If null, DM is skipped. |
onCommit | async (result) => void | Called after DM commit succeeds | |
onError | (err) => void | Called if DM fails (payment still succeeds) |
Behavior: Payment is the primary action — if it fails, nothing happens. DM is best-effort: if the ENC commit fails, the payment still succeeds and the error is passed to onError. The user can retry the DM manually.