Rubic Documents
  • RUBIC
    • Overview
    • Rubic's Ecosystem
    • Security
    • Tokenomics
    • Roadmap
    • Rubic Discord Roles
    • “Swap to Earn” Program on Rubic
    • MEV-bot Protection
    • B2B Cross-Chain Toolkit
      • Use Cases
      • Why Rubic?
    • Refund Guidelines for Stuck Transactions
  • ⚒️Integrate SDK
    • SDK Overview
    • SDK Architecture
    • SDK Advantages
    • SDK Integration
    • 1️⃣Install SDK
    • 2️⃣Set up SDK
    • 3️⃣Trade calculation
    • 4️⃣Swap Execution
    • 📜Advanced documentation
    • Migration from V2 to V3
    • Contact Us
  • Integrate Widget
    • Widget Overview
    • Instruction
    • White Label Widget Integration Instruction
    • Partners
    • Listing of tokens
  • Rubic API
    • 🔐Tokens API
    • Referrer And Rate Limits
    • Rubic API
      • Supported chains
      • Supported providers
      • Request Quote
      • Request Data
      • Get Cross-Chain Status
      • Integration example
        • Swaps from EVM
        • Swaps from Solana
        • Swaps from TON
        • Swaps from Tron
        • Swaps from Bitcoin
        • Swaps VIA deposit
      • Swagger
      • Models
        • OnChainTradeType
        • CrossChainTradeType
        • FeesDto
        • RoutingDto
        • TransactionDto
        • ErrorDto
      • Errors
    • Monetization And Fees
  • FAQ
    • What is Rubic?
    • How to start using Rubic?
    • Who can use our service?
    • Is KYC required?
    • What are the minimum and maximum trade sizes?
    • Should I list my token before using your service?
    • How to create a Swap?
    • How long does it take to complete a transaction?
    • How is the privacy and security of the transaction ensured?
    • How does Rubic unite different DEX platforms?
    • Why does Rubic offer a choice between different providers?
    • How do I add the BNB Smart Chain and Polygon networks to MetaMask?
    • What should I do when I see the message: “Trading on Uniswap is not available?”
    • What should I do if Uniswap doesn’t display any rates?
    • How can we integrate the Rubic Relay widget?
    • How do we get listed on Rubic?
    • How to Complete swaps to/from TON network using Rubic
  • Contacts
    • Community
    • PR Marketing
    • Business Development
    • Support
    • Influencers Collaboration Requests
  • Legal Documentation
    • Privacy Policy
    • Terms of Use
    • Third-Party Software
  • Audits
    • MixBytes Audit
  • Pitch Deck
Powered by GitBook
On this page

Was this helpful?

  1. Integrate SDK

Install SDK

Easy and simple to install

PreviousSDK IntegrationNextSet up SDK

Last updated 11 months ago

Was this helpful?

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 , additional steps are required

npm install rubic-sdk

ℹ️️ Skip the rest of the steps if your have already installed 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 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")}

Installation with npm for Angular

Installing the package from the NPM for Angular is similar, but in case your project does not contain , 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 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;

ℹ️️ Skip the rest of the steps if your have already installed in your project.

⚒️
1️⃣
web3
web3
web3
web3
Advanced documentation