JS SDK Migration Guide
Our new JS SDKs depend on the new backwards breaking web3.js version. Their new design comes with a lot of improvements, like tree-shaking, improved customization or decreased supply chain risk among other awesome enhancements.
The trade-off for being able to make use of these upgrades is that web3.js 2.0.0 is backwards incompatible and hasn't seen as much adoption yet. We are one of the first few products on solana that adapt their SDK clients to that standard.
To make the transition to this new standard as smooth as possible for developers, who want to build on top of our SDKs, there are 2 possibilities - both of which have example repositories that directly show the implementation process in detail.
Using web3.js 2.0.0 directly as a dependency (recommended)
For natively switching over to web3.js 2.0.0 you simply have to change your @solana/web3.js
dependency from one of the older versions (1.x.x) to the new version (^2.0.0) in your package.json
.
Pros
- get all the above mentioned improvements (tree-shaking, better customization, modern javascript etc.)
- natively use and integrate our SDKs
- adapt to the new web3.js standard early to avoid migrations later
Cons
- existing web3.js functionality has to be rewritten to match the new standard
- possibility of dependency issues with other SDKs that haven't adapted the new standard (this is annoying but solvable with alias dependencies!)
Examples
All the linked example folders in SDKs and Examples show concrete usage of the new standard, so you have plenty of example code to look into.
Using the compat package (easier lift)
While we highly encourage you to adapt the new standard, we understand that having to rewrite existing functionality might be too time-intensive. That's why there is an alternative option, which easier to use. For that you only have to add @solana/compat
and @tensor-foundation/compat-helpers
as additional dependencies to your package.json
. By doing that, you can use the old web3.js (1.x.x) version as direct dependency and only have to wrap arguments that you use for tensor SDK calls.
Pros
- easy integration of tensor SDKs without having to rewrite existing web3.js functionality
Cons
- you don't get the improvements of web3.js 2.0.0
Examples
For an explanation of how to use the compat package for interacting with Tensor's SDKs, we've prepared an compatibility example repository. Every needed argument wrapper is explained step-by-step in a short example script here.
If you think that there are any integration examples missing, please feel free to reach out to us or make a PR!
And, of course, if you struggle with integrating our new SDKs, reach out to us in the #api-sdk-questions channel of our Discord! We're very happy to help you resolve any issues or clear any existing confusion!
Updated 2 months ago