1️⃣Install SDK
Easy and simple to install
Our SDK supports installation through several sources, which include CDN and direct installation through NPM, which is recommended way.
Install with CDN
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>
Install with NPM and webpack
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
ℹ️️ Skip the rest of the steps if your have already installed web3 in your project.
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 configadd to
plugins
new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'], process: 'process/browser'})
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")}
Installation with npm for Angular
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
ℹ️️ Skip the rest of the steps if your have already installed web3 in your project.
npm install --save-dev stream-browserify assert https-browserify os-browserify stream-http crypto-browserify process buffer browserify-zlib browserify-fs querystring-es3
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"], "querystring": ["./node_modules/querystring-es3"], "fs": ["node_modules/browserify-fs"], "zlib": ["node_modules/browserify-zlib"] } }
Modify polyfills.ts
import 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 updated
Was this helpful?