SDK-less
So, as a Web3 developer who loves Kin as much as we do, you'd like to create a DApp that allows users to sign transactions with their own Solana wallet (E.g. Phantom, Solflare, etc) while still taking advantage of the lovely Kin KRE?
Well, here we can show you how to do just that!
Solana Transactions
However you are interacting with the Solana blockchain (in the above example, we used the @solana/web3.js npm package), you need to construct and sign a transaction. In order to be picked up by our ingestor so you can get your KRE rewards, the transaction needs to have the right instructions, and have those instructions come in the right order.
Here's an example of a successful transaction (the one above in the gif).
Memo Containing App Index
REQUIRED - First Instruction
We can see above that the first instruction uses the Memo Program
and contains the data ZaAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
.
Using our Kin Laboratory, we can parse that string to see the details of the memo.
We can also use the Laboratory to create correctly formatted memos in the first place.
Token Transfer
REQUIRED - Second Instruction
This is the step containing the the amount of Kin and where it is going.
Other Instructions
OPTIONAL
In the example above, we've used Memo Program v2
to add some SKU info about the transaction.
How about the code?
To try it yourself, check out our Kin DApp Demo.
Look here if you want to skip straight to creating transactions.
TLDR?
const transaction = new Transaction()
.add(appIndexMemoInstruction) // Must be the first instruction
.add(transferInstruction);
await sendTransaction(transaction, connection);
Did it work?
To check if your transaction was correctly formatted, again head over to our Kin Laboratory and check the status of your transaction.
You should also be able to see the transaction when you log in to the Kin Developer Portal.
And that's it! The specific implementation will be different depending on how you are interacting with Solana, but the basic principle applies, and as long as you've created your transaction correctly, you should be good to go!
If you have any issues, please drop us a line in our Developer Discord and jump into our sdk-less
channel