Cover image
DEC 19, 2023

ACS airdrop to Saga owners

by Vlad, Access Protocol

Saga owners are getting ACS! Learn the technical details of how we did it and how you can do it as well!
Vlad is a Fullstack Software Engineer at Access Protocol. You can reach out to him on X (@mmatdev) or via e-mail at vladislav@accessprotocol.co.
Solana Mobile Saga phones became a hot topic in the recent month. After being overlooked since their release in May 2023 they started gaining traction after the recent surge of the $BONK token. As every new Saga owner is getting 30M $BONK currently valued at around USD 600, the phones became practically free and sold out overnight.
There has been a lot of gossip about another airdrops that the new Saga owners might be getting. Let's confirm one of these:
Access Protocol is dropping 100,000 ACS to all Saga owners. These tokens are claimable at https://hub.accessprotocol.co/saga-airdrop using an in app browser in Phantom or Solflare app on your Saga phone.

How we identify Saga phone owners

The thing that makes Solana Phones unique is the “Secure Element” for private key management and its ability to interact directly with the Web3 native apps that are deployed on the Solana dApp Store. But to identify these phones in your app, there is one more thing that is unique - each Saga phone comes with a soul-bound (non-transferable) NFT called Saga Genesis Token, that can be used to distinguish these devices from any other wallet.
So the only challenge when dropping any tokens to Saga owners is identifying if the wallet interacting with your application owns the Saga Genesis Token. As all these tokens are in one NFT collection, this is no different to dropping tokens to e.g. Mad Lads.

Writing apps for the Saga phone

If you want your app to be usable on the Saga phone, you have two options:
  • Implement it as a Solana React Native dApp. To get started, you can have a look at this repo: https://github.com/solana-mobile/solana-mobile-dapp-scaffold
  • Make the Saga users interact with your application using the browser in Phantom or Solflare wallet app. These applications allow you to use your device's wallet owning the Saga Genesis Token.
Even though the first option offers a better UX, if your goal is to get to your users as soon as possible, you might consider the second option as well. That's what we at Access Protocol have decided to do for the ACS airdrop.

Technical solution for the airdrop

You have two options when dropping tokens to the Saga owners:
a) List the owners of all the NFTs in the collection 46pcSL5gmjBrPqGKFaLbbCmR6iVuLJbnQy13hAe7s6CC, create associated token accounts when applicable and send the tokens to them. Even though this is a simple one-time solution it has multiple disadvantages:
  • You only send tokens to the current owners of the Saga mobile and you are excluding all the future owners.
  • You have to pay for the Associated Token Account creation.
  • You don't get the users to actively try out your app.
b) Make the users claim the airdrop in your app or on your site. This solution:
  • includes every owner of Saga in perpetuity (or until you disable it),
  • makes the users pay their own transaction and account creation fees,
  • brings new users to your app.
As the second solution is clearly superior to the first one, I'll describe its implementation. The main points that you have to ensure when implementing the airdrop claim are:
  • Only the wallets owning the Saga Genesis Token are able to claim.
  • Each wallet is only able to claim once.
  • The token supply that you want to distribute is in an a wallet owned by your backend service, so that the distribution can be automated.

Eligibility check

To only allow claiming to the Saga mobile owners, you need to implement a conditional check that only enables claiming to the wallets owning the Saga Genesis Token.
You can do this two ways: I would recommend you using the searchAssets method of Helius' DAS API with the request body looking as follows:
{ "jsonrpc": "2.0", "id": "<your id>", "method": "searchAssets", "params": { "ownerAddress": "<owner address>", "grouping": [ "collection", "46pcSL5gmjBrPqGKFaLbbCmR6iVuLJbnQy13hAe7s6CC" ], "page": 1, "limit": 1 }, "displayOptions": { "showUnverifiedCollections": false, "showGrandTotal": true } }
You only allow minting if the response has "result"."total" > 0.
If you use another RPC provider, you can do the same thing directly by using Metaplex @metaplex-foundation/js library like this:
const metaplex = new Metaplex(connection); const allNFTs = await metaplex .nfts() .findAllByOwner({ owner: <owner address> }); const genesisToken = allNFTs.find( nft => nft.collection && nft.collection.verified && nft.collection.address.toBase58() === COLLECTION_ADDRESS, ); const eligible = !!genesisToken;

Transaction preparation

After you check the wallet eligibility, you have to construct the appropriate transaction for the wallet owner to sign and send it to your backend. This transaction consists of an Associated Token Account creation, if applicable, and the token transfer (airdrop) itself:
const ixs = []; const ataAddress = getAssociatedTokenAddressSync(<mintAddress>, <owner>); const ataAccount = await connection.getAccountInfo(ataAddress); if (!ataAccount || ataAccount?.data.length === 0) { const ataIx = createAssociatedTokenAccountInstruction( <owner> ataAddress, <owner, <mintAddress>, ) ixs.push(ataIx); } const sourceATA = getAssociatedTokenAddressSync(<mintAddress>, <backend airdropper wallet>); const transferIx = createTransferInstruction( sourceATA, ataAddress, <backend airdropper wallet>, <airdrop amount>, ); ixs.push(transferIx); const tx = new Transaction().add(...ixs); tx.feePayer = publicKey; tx.recentBlockhash = (await connection.getLatestBlockhash()).blockhash; if (signTransaction) { const signedTx = await signTransaction(tx); <send the signedTx to your backend> }

Backend handling

On the backend you need to deserialize the transaction and check that it is indeed the correct one. This includes:
  • Checking again that the airdrop recipient is an owner of Saga Genesis Token.
  • Checking that the transaction amount is correct.
  • Checking that the destination account belongs to the airdrop recipient.
  • Checking that this wallet has not claimed the airdrop yet - using any database or key-value storage.
Only if all these check pass, you can sign the transaction with the airdrop wallet and send it to Solana. Don't forget to record in your database that the claim has happened.
The code for a similar process can be found in one of my previous posts: https://scribe.accessprotocol.co/access-protocol/whos-gonna-pay-for-it-clomza48i0001ll08evxk0x2j

Conclusion

Creating an airdrop claim page for the Saga mobile owners is quite simple and can significantly improve the visibility of your project. Moreover, it is a fun project to be working on.
Looking forward to more of you trying this, let me know how it goes or if you have any issues.
Oh, and enjoy your ACS airdrop!
Comments
To comment, please sign in.
Crypto Alpha
last year
Great Idea for Mass Onboarding Users, especially the ones who can afford to pay and stay...
2
7Q34..5Gqx
last year
Let's go! Nicely done!
2