Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spike: Research Solana JavaScript SDK integration in Masa SDK #334

Closed
3 tasks done
Tracked by #24
H34D opened this issue Jul 23, 2024 · 2 comments
Closed
3 tasks done
Tracked by #24

Spike: Research Solana JavaScript SDK integration in Masa SDK #334

H34D opened this issue Jul 23, 2024 · 2 comments
Labels

Comments

@H34D
Copy link
Contributor

H34D commented Jul 23, 2024

We are planning to deploy contracts to solana. To be able to use them we have to attest the changes that are required to add the solana SDK to the masa sdk and make it connect to solana.

Acceptance Criteria

  • Add Solana SDK to Masa SDK
  • Connect to solana testnet/devnet
  • Transact on solana testnet/devnet

Output

Smart Contracts

There is no concept called smart contracts at Solana. Instead they follow a concept that is called Program. There is a default program called splToken which is very similar to ERC20 tokens on EVM and comes with its own factory. Based on the findings with the OFT implementation on Solana we might or might not use that Program for the Masa Token. To ship functionality like staking we need a custom staking program. There is no known code generation framework like we are using with ABIs and ethers.js so we might up ending keeping the using code and in the SDK and the contract itself in sync manually.

Wallets

My implementation of Solana here is based on a connection / keypair construct similar to the wallet construct from ethers.js. Since we are not exactly sure what a wallet connection in the browser would deliver we can go ahead with the keypair solution for now. It works very well in the cli. It enables us to use public keys as addresses. I used it to transact to send SOL from one to another wallet. All of the wallets are derived from a seedphrase in the cli right now. We must make sure we can properly inject the provider once we have solved this in masa-react.

Networks

I added two of three solana networks to the networks collection that are flagged as "non evm" so we must ignore them when ever we do something evm related. In the cli the network switching worked like on all the other evm networks. I am not sure how a web provider like phantom would react on a network switch.

Utils

The tooling supplied by the solana web3 sdk itself is basic. I was able to send around SOL and do balance calculation based on that but i have not seen any tooling to access custom programs.

@juanmanso
Copy link
Contributor

Super convoluted but if there's a particular doubt while looking this up, there's this OpenSource wallet that might be of use:

Sadly, it's a large codebase as far as I could look but like I said, it might be useful to troubleshoot some specific use case

@H34D
Copy link
Contributor Author

H34D commented Jul 29, 2024

The biggest problems are as usually the wallets and endpoints. I am using this:

https://solanacookbook.com/references/keypairs-and-wallets.html#how-to-generate-a-new-keypair
https://solana.com/docs/core/clusters
https://solana.com/docs/clients/javascript

It is getting interesting if we talk about something like ABI and other convenience things.

@H34D H34D closed this as completed Aug 1, 2024
@H34D H34D removed their assignment Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants