New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cowprotocol/widget-lib

Package Overview
Dependencies
Maintainers
5
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cowprotocol/widget-lib

CoW Swap Widget Library. Allows you to easily embed a CoW Swap widget on your website.

0.7.0
Source
npm
Version published
Maintainers
5
Created
Source

CoW Swap Widget Library

Integrate the power of CowSwap into your product! With the widget, you can create an incredible trading interface. Specify the required pair of currencies, customize the look and much more!

Live example

See the widget in action in the widget configurator

Docs

You can find a detailed description of all widget parameters in the documentation

Quick start

npm install @cowprotocol/widget-lib --save
yarn add @cowprotocol/widget-lib

Create a container somewhere in your website, the widget will be rendered inside it:

<div id="cowswap-widget"></div>

Import the widget and initialise it:

import { cowSwapWidget, CowSwapWidgetParams } from '@cowprotocol/widget-lib'

// Initialise the widget
const widgetContainer = document.getElementById('cowswap-widget')

const params: CowSwapWidgetParams = {
  appCode: '<YOUR_APP_KEY>', // Just an unique identifier for your app
  sell: { asset: 'DAI' },
  buy: { asset: 'USDC', amount: '0.1' },
  // instantiate your own web3 provider
  provider: window.ethereum,
}

const updateWidget = cowSwapWidget(
  widgetContainer,
  // Optionally, you can provide some additional params to customise your widget
  params
)

// You also can change widget configuration on the fly
updateWidget({ ...params, tradeType: 'limit' })

Developers

Test
nx test widget-lib
Build the library
nx build widget-lib

Keywords

cowprotocol

FAQs

Package last updated on 22 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts