1⃣
Install SDK
Easy and simple to install
Our SDK supports installation through several sources, which include CDN and direct installation through NPM.
To install via CDN, simply insert a link to the js bundle with our SDK.
<script src="https://unpkg.com/rubic-sdk@latest/dist/rubic-sdk.min.js"></script>
To install via NPM, just run one command in the console, but if your project does not contain web3, additional steps are required
npm install rubic-sdk
npm install --save-dev http-browserify https-browserify stream-browserify crypto-browserify
- modify webpack.config.js. If you use create-react-app, run
npm run eject
to extract config- 1.add to
plugins
new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'], process: 'process/browser'}) - 2.add
resolve.fallback
"fallback": { "fs": false, "constants": false, "querystring": false, "url": false, "path": false, "os": false, "http": require.resolve("http-browserify"), "https": require.resolve("https-browserify"), "zlib": false, "stream": require.resolve("stream-browserify"), "crypto": require.resolve("crypto-browserify")}
Installing the package from the NPM for Angular is similar, but in case your project does not contain web3, the additional steps will be different.
npm install rubic-sdk
npm install --save-dev stream-browserify assert https-browserify os-browserify stream-http crypto-browserify process buffer
- Modify tsconfig.json{"compilerOptions": {..."paths": {..."stream": ["./node_modules/stream-browserify"],"assert": ["./node_modules/assert"],"https": ["./node_modules/https-browserify"],"os": ["./node_modules/os-browserify"],"http": ["./node_modules/stream-http"],"crypto": ["./node_modules/crypto-browserify"]}}
- Modify polyfills.tsimport Process = NodeJS.Process;export interface AppWindow extends Window {process: Process;Buffer: Buffer;global?: unknown;}(window as AppWindow).global = window;(window as AppWindow).process = window.process || require('process');(window as AppWindow).Buffer = (window as any).Buffer || require('buffer').Buffer;
Last modified 11mo ago