The blxr_tx endpoint is expecting raw transaction bytes. Constructing the transaction is typically done using a library like web3 or ethers. The below examples demonstrate constructing a raw transaction and submitting it to blxr_tx .
Examples - Create a Simple Transfer raw transaction and submit it to blxr_tx api
constWebSocket=require('ws')constEthereumTx=require('ethereumjs-tx').Transaction// Needed for BSC// const Common = require('ethereumjs-common').defaultconstWeb3=require('web3')constweb3=newWeb3('PROVIDER_URL')constaccount='YOUR_ADDRESS'constprivateKey=Buffer.from('YOUR_PRIVATE_KEY','hex',)// const BSC = Common.forCustomChain(// 'mainnet',// {// name: 'Binance Smart Chain Mainnet',// networkId: 56,// chainId: 56,// url: 'https://bsc-dataseed.binance.org/'// },// 'istanbul',// )constmain=async () => {consttx=newEthereumTx({ to:'TO_ADDRESS', nonce: nonce,// Pass in decimal number for fields below gasPrice:web3.utils.toHex(), gas:web3.utils.toHex(), value:web3.utils.toHex(), chainId:1// If using BSC// chainId: 56 } //, { common: BSC } )tx.sign(privateKey)constserializedTx=tx.serialize()constrawTx=serializedTx.toString('hex')constws=newWebSocket("ws://127.0.0.1:28333/ws", { headers: { "Authorization": <YOUR-AUTHORIZATION-HEADER> }, rejectUnauthorized: false, } ); function proceed() {ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "${rawTx}"}}`) } function handle(response) {console.log(response.toString()) // Or process it generally } ws.on('open', proceed) ws.on('message', handle)}
Examples - Create a Token Swap raw transaction and submit it to blxr_tx api