The impression of the answer binance
In this article, we will deepen how to print the order response to the Binance platform using the
previous requirements
NPM install the ethers
or
Thread add the ethereal
Print of an order response
To print the order response, we must first create a new order and then recover our answer. Here's an example of implementation:
Const Web3 = required ('web3');
Const ether = demand ('ether');
// Replace the Ethereum node credentials (for example, 'http: //127.0.1: 8545')
Const Ettnodeurl = '
// Create a new web instance
Const Web3 = New Web3 (New EtherS.Providers.jsonrupcprovider (ethnodeurl));
// etzistent your credentials Ethereum node here (replace your real credentials)
const nodeurl = process.env.esthn_node_url || '
// Define the order parameters
Const = 'adabusd' symbol;
Const Bayquantity = 100; // adjust this amount according to your needs
Const Price = 20000; // Replace with the valid price of the Ethereum
// Create an instance of a customer
Const client = new ether.contract ('0x ... your contract address ...', Ethers contract);
// Set the order
order = client wait.
symbol,
Kupitquantity,
price,
'Ack'
);
// Refund of the order response
Constth answer = client waiting.
Console.log (answer);
In this example, we create a new instance of 'Web3' using our credentials Ethereum Noda. Then we define the order parameters (symbol, quantity and price). Finally, we place the order by the method ofclient.limit_buy ()
. This is useful for purification and solving problems.
Bash
Bash
Javascript
Orderlimitbuy ()and recover your answer using the
order of the answer ().
the impression of the answer
The order answer is an object containing several properties, such as:
State ': Order status (for example," on hold "," fulfillment "or" canceled ").
- MSG
: A message that describes the result of surgery.
- The result
: the result of the surgery (for example, the full amount).
To print this answer, you can use the following code:
if (reply.status === 'filling') {)
Console.log ( Iche
otherwise if (answer.status === 'canceled') {)
Console.log (Javascript
Order.id} order has been successfully completed for $ {buyquantity} adabusd on $ {price} .);
ORDER $ {ORDER.ID} CANCED.
Iche
other {{{
Console.log (Error: $ {resform.msg}
);
Iche
` This will print the order response on the console, which will allow you to purify and solve the problems of your Ethereum transactions.
Remember to replace
… your contract address …` The actual address of the Ethereum contract generated by the order.