NodeJS Oracle interacts with Forge Smart Contracts on Blockchains. Only Ethereum and Tezos are supported at the moment.
It can:
- Listen to blockchain events
- Send transactions to a blockchain
This project leverage the power of NestJS to expose a GraphQL API to communicate with Blockchains.
- Forge Registration Oracle (FRO): designed to start the process of an issuance, declaration of investors and interests, creation of instruments, and many more procedures. At the beginning of an issuance (bond or EMNT), issuers and investors communicate their parameters to the registrar, who then sends that information to the blockchain via the FRO. This means that the FRO launches the issuance, declares the issuer and each investor, creates the instrument, and even generates the trades and settlement transactions.
- Forge Investment Oracle (FIO): designed to be a listener for investors and issuers on the blockchain. This is the way in which these parties can receive information on the transactions which concern them. This oracle can be used as a source of information in order to receive accurate information on transactions.
- Forge Settlement Oracle (FSO): designed to provide important DvP (Delivery vs Payment) functionalities when the issuer and investor are prepared to complete the trade. This oracle can be connected to an outside entity to extend payment options.
Each oracle has a dedicated GraphQL Playground (/graphql) which can be used as an interface for testing. See the docker-compose.yml
file for the port number of each site as created on the local environment.
Examples of queries and mutations can be found in the directory /docs The following procedure can be performed to test the scenario of a bond issuance:
- In the FRO (localhost:6661/graphql), Run the registryNotification and contractNotification queries in separate tabs in the GraphQL Playground in order to have listeners for these notifications. These same subscriptions can also be launched from the FIO (localhost:6664/graphql).
- Run the whoAmI query on the Ethereum Ledger in order to get the address for the Ethereum Ledger.
- Run the CreateBond mutation. For the CreateBondInput which is needed as an argument, use the
createBond_variables_ETHEREUM.json
file. Once sent, theregistryNotification
subscription will display anInstrumentListed
notification, with the address of the listed instrument. - Run the initiateSubscription mutation. For the SubscriptionInput argument, use the
initiateSubscription_variables_ETHEREUM.json
file. Once sent, thecontractNotification
subcription will display aSubscriptionInitiated
notification. - Run the initiateTrade mutation. Use the accompanying example file for the InitiateTradeInput argument. The seller should have the address previously used for the issuer, and the buyer should have that of the investor. Once sent, the
contractNotification
subcription will display aTradeInitiated
notification. - Now, run the getSettlementTransaction query from the FSO (localhost:6663/graphql). The ID needed should come from the
id
of an object from thelightSettlementTransactions
array found in the TradeInitiation notification. The result shows themovements
, which are the payments made between the buyer, seller, and escrow. Note that the buyer sends cash to the escrow, and a token to the seller. The escrow sends the buyer's cash to the seller. The status of the settlement transaction isACKNOWLEDGED
. - Send the
confirmPaymentReceived
mutation from the FSO. The payment reference to send is that of the buyer to the escrow in the list ofmovements
. This updates the status of the settlement transaction toPROCESSED
. - Send the
confirmPaymentTransferred
mutation from the FSO. The payment reference to send is that of the escrow to the issuer in the list ofmovements
. This updates the status of the settlement transaction toSETTLED
.
.
├── integration Integration tests
├── src
│ ├── constants
│ ├── decorators
│ ├── ethUtils Utility code for ethereum
│ ├── filters Global exception catchers
│ ├── guards Authentication verification
│ ├── modules
│ │ ├── fio
│ │ ├── fmo
│ │ ├── fro
│ │ ├── fso
│ │ └── str
│ ├── shared Code shared between all modules
│ └── utils Utility code
└── tests
└── unit Unit tests
Apache 2.0