Metal X
API DocsMetal XWebAuth WalletLoan Protocol
  • DEX
    • What is Metal X?
      • Trading Interface
      • Trading on Metal X DEX
      • DEX fees and discounts
      • Referral program
      • Metal X FAQ
  • Developers DEX
    • Smart Contract
      • Contract Address
      • Tables
      • Actions
    • Contract Mappings
      • Order Types
      • Fill Types
      • Order Status
      • Order Side
      • Status codes for markets
      • Common Errors
    • Examples
      • Installation + Initialization
      • Submit DEX Order
      • Cancel DEX Order
      • Order Lifecycle
    • Audit
    • Oracles
  • Swap, Pools & Farms
    • What is Metal X Swap?
      • Trading Interface
      • Swap fees and discounts
      • Liquidity Pools
      • Farming
      • Metal X Swap FAQ
  • Developers Swap
    • Tables
      • Actions
      • Contracts
      • Audit
  • XPR Network
    • XPR Network & Ecosystem
  • dex bot
    • About
    • Installation
  • Support
    • Guides
Powered by GitBook
On this page
  1. Developers DEX
  2. Examples

Installation + Initialization

DEX orders can be submitted through both JS and python library. Below are the instructions to install.

PreviousExamplesNextSubmit DEX Order

Last updated 1 year ago

Install:

npm i @proton/js
npm i node-fetch@2

is the library used for DEX.

Below are the instructions to install it on different Operating Systems.

MAC and Linux(ubuntu):

python3 -m pip install -U pip
python3 -m pip install pyeoskit

Windows:

python -m pip install -U pip
python -m pip install pyeoskit

M1/M2 Mac:

brew install go cython
python3 -m pip install cmake

xcode-select --install
in case if you see the error message "xcode-select: error: command line tools are already installed, use "Software Update" to install updates" for above command, fix the with the following command
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

python3 -m pip install -U pip
python3 -m pip install pyeoskit
python3 -m pip install -U pip
python3 -m pip install pyeoskit

Initialize API:

const {JsonRpc, Api, JsSignatureProvider} = require('@proton/js')

// For testnet use https://testnet-rpc.api.protondex.com
const ENDPOINTS = [
   'https://mainnet-rpc.api.protondex.com',
]

// To export private key from your wallet, follow:
// https://help.proton.org/hc/en-us/articles/4410313687703-How-do-I-backup-my-private-key-in-the-WebAuth-Wallet-
const PRIVATE_KEY = 'PVT_K1_2fdW4UGdbgG59mUaTiMXLy1rFv3afbmSWEZGWFz6zF8dR1VZPb'

// Authorization
const username = 'metaltest1'
const authorization = [{
    actor: 'pbonblockc',
    permission: 'active'
}]

// Initialize
const rpc = new JsonRpc(ENDPOINTS)

const api = new Api({
   rpc,
   signatureProvider: new JsSignatureProvider([PRIVATE_KEY])
})

const transact = (actions) => api.transact({actions}, {
    blocksBehind: 300,
    expireSeconds: 3000,
})
import os
from pyeoskit import eosapi, wallet
#import your account private key here
wallet.import_key('mywallet', 'PVT_K1_2fdW4UGdbgG59mUaTiMXLy1rFv3afbmSWEZGWFz6zF8dR1VZPb')

username = "user1"
#For testnet use https://testnet-rpc.api.protondex.com
eosapi.set_node('https://mainnet-rpc.api.protondex.com')
info = eosapi.get_info()
print(info)

pyeoskit