SKU with KRE Demo --DO_NOT_MERGE--#1
Open
richardmands wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Outcome:
Adding a simple SKU / Identifier to transactions while still allowing transactions to be picked up by the ingestor for the KRE.
Explanation:
We can do this by taking advantage of the 'foreign key' part of the Kin Memo:
https://developer.kin.org/docs/how-it-works/#kin-binary-memo-format
The SDKs currently use this to store a reference to an invoice when invoices are passed along with 'submitPayment':
https://developer.kin.org/docs/how-it-works/#invoices
We can see when the foreign key has been used as the memo stored for the transaction looks like this:



RaAFTNHJgbTVzdGBiJWByOSAjKGFyc2BvMmBsJXNzbk=instead of this:
RaAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=Check out https://laboratory.kin.org/memo to see that the memo formats both output correctly from a KRE perspective.
Here's the transaction (
3bM1GzCxmEVAAS6xrzMwzxq7cvYomKVbFMDPh467RvM67SZP9MkdFubtAoDXASC7PotruRaKYryVyUrcRN8qr1Wt) on explorer:https://explorer.solana.com/tx/3bM1GzCxmEVAAS6xrzMwzxq7cvYomKVbFMDPh467RvM67SZP9MkdFubtAoDXASC7PotruRaKYryVyUrcRN8qr1Wt?
Here it is being picked up on the Kin Developer Portal:

KRE
The memo must be recreated correctly or you won't get credit for your transaction from the KRE!
Invoices
When using invoices, the memo does not store the invoice itself, just a reference that is used by Agora to look up the stored invoice. So the invoice itself is not being stored 'on chain'.
To get around this, we can simply encode an identifying string of some kind with a length of 29 characters or less and pass it into the Memo as the foreign key.
Accessing the On-Chain Data
The contents of this memo are not returned by SDK methods that pick up transaction details, e.g.
getTransaction. This means you'll have to use Solana directly to get the transaction data and extract the memo.Once you have the memo, our Npm package
kin-tools/kin-memoprovides a classKinMemothat can help to extract the foreign key Buffer which can then be decoded back to the original string.e.g.