The following command runs a trace that includes creating, reading, writing, and deleting the oracle. A transcript of the output is in example.log.
mantra-oracle -- trace Êþ CORN FARM PIGY 1000000 0
Here CORN is the control token, FARM the datum token, and PIGY the fee token: these are assets under the cafe currency symbol. The minimum fee for using the oracle in a contract is 1000000 PIGY.
The PAB example uses three executables:
-
First start the simulate Plutus application backend (PAB), and leave it running. Wait until three
[INFO] Activated instancemessages are printed before running the oracle in step #2: this lets enough slots pass to create the oracle and transfer newly minted funds to the other wallet(s). In this example,BRIOis the control token,SOFRthe datum token, andPIGYthe fee token: these are assets under the a newly created currency symbol. The minimum fee for using the oracle in a contract is1000000 PIGY. Wallet #1, which controls the oracle, will be created with0 PIGYand its Contract ID (CID) will be stored in the fileoracle.cid; wallet #2 will have2500000 PIGYand its CID stored inwallet-2.cid.mantra-oracle pab-simulate CORN FORM PIGY 1000000 0 '[(1, 0, "oracle.cid"), (2, 2500000, "wallet-2.cid")]'
-
Next run the oracle data source, and leave this running. This periodically polls the data source and posts data when it changes. In this example, we poll the New York Federal Reserve Bank SOFR API every 300 seconds, connect to the PAB at
127.0.0.1:9080, and call thewriteendpoint for the Contract ID (CID) in the fileoracle.cid.mantra-oracle/mantra-oracle pab-control 300 127.0.0.1 9080 oracle.cid
-
Each time we want to use the oracle data in a bare-bones contract, we can run the following. In this example, we connect to the PAB at
127.0.0.1:8080and call thereadendpoint for the Contract ID (CID) in the filewallet-2.cid. If we call the end point more than twice, reading the oracle will fail due to insufficient funds.mantis-oracle pab-employ 127.0.0.1 9080 wallet-2.cid