LogoLogo
  • About
    • Introduction
    • Unlockd SDK
    • Partners & Revenue Sharing
  • Getting Started
    • Installation
    • SDK Modules
      • Action Module
      • Auction Module
      • Market Module
      • Buy Now Module
      • Sell Now Module
      • Wallet Module
      • NFT Batch Transfer Module
    • Code Examples
      • Borrowing Assets
      • Fetch prices
      • Login
      • Borrow Signature
      • Minimum Repay
      • Liquidation Price
      • Health Factor
      • Available to borrow
    • UI Snippets
    • Reservoir Integration
  • USE CASES (code examples)
    • Borrow against RWAs
    • 'Buy Now, Pay Later' financing
  • Resources
    • npmJS Package
    • Best Practices
    • Changelog
    • Support & Contact
    • Unlockd V2
    • Product Documentation
    • Protocol Documentation
    • Risk Documentation
    • External Audits
    • Website
    • X (Twitter)
    • Discord
    • Other links
Powered by GitBook
On this page
Export as PDF
  1. Getting Started
  2. Code Examples

Borrowing Assets

import { UnlockdSDK } from '@unlockd/sdk';

const unlockd = new UnlockdSDK();

async function borrowAssets() {
  try {
    const token = await unlockd.authenticate();
    const amount = 1000000000000000000; // 1 ETH in wei
    const assets = [
      {
        collection: '0x1234567890123456789012345678901234567890',
        tokenId: '1',
      },
    ];
    const signature = {
      v: 28,
      r: '0x1234567890123456789012345678901234567890123456789012345678901234',
      s: '0x1234567890123456789012345678901234567890123456789012345678901234',
      deadline: 1649327432,
    };
    const result = await unlockd.action.borrow(token, amount, assets, signature);
    console.log('Borrow successful:', result);
  } catch (error) {
    console.error('Error:', error);
  }
}

borrowAssets();
PreviousCode ExamplesNextFetch prices

Last updated 11 months ago