0.0.1 • Published 2 years ago
@tradeparadex/paradex v0.0.1
Paradex SDK
Install
npm install --save @tradeparadex/paradexyarn add @tradeparadex/paradexUse cases
Get Paradex account address from Ethereum signer
This example uses ethers as a dependency to provide an Ethereum signer. If you need support for other libraries, get in touch.
import { ethers } from 'ethers';
import * as Paradex from '@tradeparadex/paradex';
// 1. Fetch Paradex config for the relevant environment
// Supported environments:
// - 'testnet' (Sepolia Testnet)
// - 'mainnet' (Ethereum Mainnet)
const config = await Paradex.Config.fetchConfig('testnet');
// 2. Get ethers signer (example with injected provider)
const ethersProvider = new ethers.BrowserProvider(window.ethereum);
const ethersSigner = await ethersProvider.getSigner();
// 3. Create Ethereum signer based on ethers signer
const signer = Paradex.Signer.ethersSignerAdapter(ethersSigner);
// 4. Initialize the account with config and Ethereum signer
const account = await Paradex.Account.fromEthSigner({ config, signer });
console.log(`Account address: ${account.address}`);
// => Account address: 0x...Notes on browser usage
To use the Paradex SDK in the browser you will need to polyfill Buffer from node and define process.env.NODE_DEBUG to satisfy @starkware-industries/starkware-crypto-utils.
Get in touch
Have a feature to request or a bug to report?
Drop us a message on Discord.
0.0.1
2 years ago