Installation + Initialization

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

Install:

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

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,
})

Last updated