Building the bank backend servers 

The backend server is a bridge between the blockchain network, the IPFS network, the postgresql database, and the bank portal frontend. It takes a request from the frontend, processes it, and forwards it to the next component in the workflow.

The backend server extends a set of API endpoints, where the frontend can post requests. The API endpoints are listed as follows:

/customerinfo: Fetches the customer's info, including name, address, account, and balance from the banka or bankb database, and passes it to the bank portal frontend.

/payment: The bank portal frontend posts payment requests to this endpoint. It uploads the transaction documents, including invoices, BOL/BOE, and any other document to the bank server, posts the document to the IPFS network, and then fires the remittance transaction on the blockchain network. On a successful response from the blockchain network, it adds the transaction to the transactions table in the bank database and updates the customer's balance. It then returns the response Transaction successfully submitted to the bank frontend.

 /gettrans: It fetches the customer's transaction details from the bank database and returns a transactions array to the bank portal frontend.

The backend server application contains the following methods:

iwrite: It takes the file path of the uploaded files as an input and adds the files to the IPFS network.

submitTrans: It takes the transaction ID, the transaction details, and the hash of the transaction documents as input parameters, and submits the transaction to the bankchain network.

updateBal: Updates the customer's balance in the database after the transaction has been successfully submitted to the network.

insertTrans: Inserts the transaction into the database after it has been successfully submitted to the blockchain and added to the channel ledger.

Let's start writing the code for the backend server. We'll write it for Bank A. Repeat the following steps for Bank B.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.247.196