10 min read
On Feb 29, 2024, Elusiv announced they would be sunsetting the Elusiv platform. The protocol will remain in withdrawal-only mode until January 1, 2025.
Overview
A common barrier to adoption of Web3 technology is the need for more privacy. Blockchain transactions are public, meaning anyone can view the details of a transaction, including the sender and receiver. Though there are many applications where this transparency is beneficial, there are also many cases where users require privacy. For example, if you are a business owner, you may not want your competitors to know how much you pay your employees. Or, if you are a user, you may want to keep your friends from knowing how much you invest. Privacy will become increasingly important as Web3 reaches more users and use cases.
Several protocols are emerging on Solana to enable private transactions. In this guide, we will walk through how to use Elusiv, a zero-knowledge (ZK) privacy protocol on Solana, to create a private SPL token transfer.
What You Will Do
In this guide, you will:
- Learn about Elusiv, a zero-knowledge (ZK) privacy protocol on Solana
- Create a private USDC transfer using the Elusiv SDK
- Verify that the transaction was private
What You Will Need
- Basic knowledge of Solana Fundamentals
- Basic knowledge of Zero Knowledge Proofs
- Node.js (version 18.16 or higher) installed
- TypeScript and ts-node (latest version) installed
What is Elusiv?
Transactions on Solana are public. Anybody with access to an Explorer and a user's public key can track and monitor that user's transaction activity. Elusiv aims to break the link between senders and receivers to enable private transactions. Elusiv is a Solana-based privacy protocol enabled by zero-knowledge cryptography. The protocol enables users and applications to access universal encryption and control, allowing them to choose what gets shared and what does not. Elusiv utilizes zk-SNARKS for private transactions and decentralized compliance solutions.
Elusiv has two primary functions:
- Elusiv Program: Elusiv works by managing a shared pool governed by the Elusiv program. Users can deposit and withdraw funds into the pool (public transactions) and then transfer funds to other users within the pool (private transactions). Though transaction details are private to the payment initiator, the initiator can create viewing keys to enable others to view specific transactions.
- Elusiv Warden: The Elusiv Warden is responsible for relaying client requests to the network and (in the future) will be responsible for managing compliance-based tasks (e.g., preventing blacklisted addresses from transacting).
Elusiv has created a simple application for demonstrating the technology that allows you to create private token transfers. Check it out at https://app.elusiv.io/.
Let's look at the Elusiv SDK to see how to integrate this functionality into our applications.
Create a New Project
mkdir elusiv-demo && cd elusiv-demo && echo > app.ts
Install Solana Web3 dependencies:
yarn init -y
yarn add @solana/web3.js@1 @solana/spl-token @elusiv/sdk @noble/ed25519
or
npm init -y
npm install --save @solana/web3.js@1 @solana/spl-token @elusiv/sdk @noble/ed25519
Import Dependencies
Open app.ts in a code editor of choice, and on line 1, import the following:
import { Connection, Keypair } from '@solana/web3.js';
import { createAssociatedTokenAccountIdempotent } from '@solana/spl-token';
import { airdropToken, Elusiv, getTokenInfo, SEED_MESSAGE } from '@elusiv/sdk';
import { sign } from '@noble/ed25519';
You can now access Logs for your RPC endpoints, helping you troubleshoot issues more effectively. If you encounter an issue with your RPC calls, simply check the logs in your QuickNode dashboard to identify and resolve problems quickly. Learn more about log history limits on our pricing page.
These imports will allow us to connect to the Solana network, create a token, and interact with the Elusiv SDK. We will cover each element in more detail later in the guide.
Create a New Keypair
First, we will need a new Keypair to use for our demo. Generate one using the widget below and copy/paste the output into your code editor.
You should see something like this--make sure to include the secret generated from the widget:
const secret = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...]; // paste your secret here
const keyPair = Keypair.fromSecretKey(new Uint8Array(secret));
You will need to fund the account with some devnet SOL to run transactions on devnet. You can do this by visiting the Solana Faucet and pasting in your new public key or by entering the following command in your terminal:
solana airdrop 1 <your public key> -ud
If you need help, check out our complete guide on airdropping Devnet SOL.
Connect to a Solana Cluster with Your QuickNode Endpoint
To build on Solana, you'll need an API endpoint to connect with the network. You're welcome to use public nodes or deploy and manage your own infrastructure; however, if you'd like 8x faster response times, you can leave the heavy lifting to us.
See why over 50% of projects on Solana choose QuickNode and sign up for a free account here. We're going to use a Solana Devnet endpoint.
Copy the HTTP Provider link:
And then use it to connect to the Solana network with the following code:
const cluster = 'devnet';
const quickNodeEndpoint = 'https://example.solana.quiknode.pro/012345' // 👈 REPLACE THIS WITH YOUR ENDPOINT
const connection = new Connection(quickNodeEndpoint);
Frame the Application
Next, create a main
function and call it at the bottom of the file. This will be where we will write our code.
async function main() {
// code goes here
}
main()
.catch(err =>console.error(err))
.finally(() => process.exit());
Great. We are all set to start building our app.