Skip to content

Norbaeocystin/solana-dwallet-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dWallet Solana Transfer

⚠️ Not for production use. Tested successfully on Solana mainnet — see tx on Solscan.

Sign and submit Solana transactions using an Ika dWallet (Ed25519 2PC-MPC). No private keys ever exist in one place — the signature is produced jointly by you and the Ika network.

What this does

  • Creates Ed25519 dWallets on Ika (Sui-based) that double as Solana wallets
  • Signs Solana transactions via 2-party MPC — no single point of compromise
  • Solana sees a standard Ed25519 signature, indistinguishable from a normal wallet

Single Secret Design

Everything derives from your mnemonic + a salt (namespace):

Mnemonic (BIP39) + Salt ("default", "ai-agent-1", "trading-bot")
   │
   ├─► Sui keypair       (BIP44 derivation, signs Sui/Ika transactions)
   │
   └─► HKDF-SHA256(mnemonic_seed, salt)
        │
        └─► Encryption seed
             ├─► Class groups keypair  (encrypts dWallet shares)
             └─► Ed25519 signer       (signs encryption proofs)
  • One mnemonic + one salt → unlimited dWallets, each with a unique Solana address.
  • Different salts → completely separate dWallet sets (namespacing).
  • Salt is not secret — just needs to be consistent. Save it with your mnemonic.

Setup

npm install

Set environment variables:

# Required
export MNEMONIC="your twelve word mnemonic goes here"

# Optional
export SHINAMI_KEY="your-shinami-key"       # fast Sui RPC (recommended, otherwise free public RPC)
export ENCRYPTION_SALT="personal"            # namespace for dWallets (default: "default")
export SOLANA_RPC="https://api.mainnet-beta.solana.com"  # Solana RPC (default: mainnet)

Or inline:

MNEMONIC="your words here" npm run create

Prerequisites

  • Node.js 22+
  • A Sui wallet with SUI for gas (the mnemonic derives this)
  • IKA tokens for Ika network fees (get from Ika faucet/exchange)
  • SOL in the dWallet's Solana address (for transfers)

Usage

1. Create a dWallet

npm run create

Creates a new Ed25519 dWallet via 2PC-MPC DKG. Takes ~2-3 minutes. Outputs a dWallet ID and Solana address. Save the dWallet ID.

Each run creates a new wallet with a unique Solana address.

2. Fund the Solana address

Send SOL to the printed Solana address from any wallet or exchange.

3. Check balance

npm run balance -- <DWALLET_ID>

4. Transfer SOL

npm run transfer -- <DWALLET_ID> <RECIPIENT> <AMOUNT_SOL>

Example:

npm run transfer -- 0xabc...123 4FvmYJbYtTe77vmCQMVDMTC1iURvPL3dgSTYCeMTjw3Y 0.001

Transfer takes ~2-3 minutes (presign + sign via MPC network).

How it works

1. Presign (Ika network, ~60-120s, no message needed)
2. Build Solana transaction (fresh blockhash)
3. Sign message via 2PC-MPC (~30-60s)
4. Submit signed transaction to Solana

You (Ed25519 share) + Ika Network (Ed25519 share)
                     ↓ 2PC-MPC
             Ed25519 Signature
                     ↓
           Solana Transaction ✅

The presign runs first (before the Solana transaction is built) so the blockhash stays fresh through the sign step.

Technical Notes

  • Public key extraction: The dWallet public_output is BCS-encoded. The actual Ed25519 signing key is at bytes 2..34 (after a version + length prefix). The last 32 bytes are the user's share public key, not the signing key.
  • Encryption key: Registered once per Sui address on the Ika coordinator. Subsequent dWallet creations reuse it automatically.
  • Blockhash expiry: Solana blockhashes expire after ~60-90 seconds. The flow runs presign first, then builds the tx with a fresh blockhash right before signing.
  • Dependencies: @ika.xyz/sdk, @mysten/sui, @solana/web3.js, @noble/hashes, @scure/bip39

Limitations

  • Only SOL transfers implemented (SPL tokens would need additional instructions)
  • No durable nonce support yet (if sign takes too long, blockhash may expire — just retry)
  • No batching of presigns (could pre-generate presigns for faster subsequent transfers)

About

using ika dwallet to do simple sol transfer on solana via typescript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors