{"id":13629841,"url":"https://github.com/tqtezos/priced-event-oracle","last_synced_at":"2025-04-17T09:36:46.897Z","repository":{"id":48672964,"uuid":"346501956","full_name":"tqtezos/priced-event-oracle","owner":"tqtezos","description":"An oracle contract that accepts queries for a Tez price","archived":false,"fork":false,"pushed_at":"2021-07-21T01:48:49.000Z","size":30,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-08T20:46:30.288Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tqtezos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-10T21:52:14.000Z","updated_at":"2022-05-26T23:33:57.000Z","dependencies_parsed_at":"2022-08-27T07:31:42.405Z","dependency_job_id":null,"html_url":"https://github.com/tqtezos/priced-event-oracle","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tqtezos%2Fpriced-event-oracle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tqtezos%2Fpriced-event-oracle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tqtezos%2Fpriced-event-oracle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tqtezos%2Fpriced-event-oracle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tqtezos","download_url":"https://codeload.github.com/tqtezos/priced-event-oracle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249331996,"owners_count":21252674,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T22:01:21.406Z","updated_at":"2025-04-17T09:36:46.580Z","avatar_url":"https://github.com/tqtezos.png","language":"Haskell","funding_links":[],"categories":["Haskell"],"sub_categories":[],"readme":"\n# Priced Event Oracle\n\nThis repo includes the _Priced Event Oracle_, an implementation of a\ntwo-way priced oracle that uses off-chain events to return data to the caller:\n\n```haskell\nparameter (or (pair %ask (contract (pair string\n                                         nat))\n                         string)\n              (lambda %admin (pair address\n                                   mutez)\n                             (pair (list operation)\n                                   (pair address\n                                         mutez))));\nstorage (pair (address %owner)\n              (mutez %price));\n```\n\n### Contract source\n\nThe Michelson source for this contract and any variants may be found in\n[/contracts](/contracts).\n\n\n## Specification\n\nThe contract stores its administrator `(address %owner)` and the current\n`(mutez price)`.\n\nIt has two entrypoints:\n- `ask`\n  * Accepts a `pair` of:\n    + The \"return\" or callback `contract` reference: `(contract (pair string nat))`\n    + The query as a `string`\n  * Rejects any calls that do not transfer the exact `price` in Tez to the contract\n- `admin`\n  * Accepts a `lambda` whose:\n    + Input is the current `owner` `address` and `price` in `mutez`\n    + Output is the new `owner`, new `price`, and any `operation`'s to emit\n  * Rejects any `SENDER` other than the `owner`\n\n## Use\n\n1. A user calls the `ask` entrypoint with his `query` `string` and callback\n  `contract` reference\n2. An off-chain indexer detects the `ask` contract call and calculates a response\n3. The oracle's host calls the `contract` reference from the `ask` with the\n  `pair` of:\n  - `(string %query_response)`\n  - `(nat %counter)`\n    + Used to distinguish responses to a repeated query\n    + Equal to the number of _previously completed_ responses to this `query`\n      and `contract`, i.e. it's `0` for the first response to a pair of `query`,\n      `contract (pair string nat)`, `1` for the second response, etc.\n\n## Verification\n\nThis contract has a formal proof in Coq using Mi-Cho-Coq.\n\nA merge request containing it may be found [here](https://gitlab.com/tqgroup/mi-cho-coq/-/merge_requests/1).\n\n\n## Demo on Delphinet\n\n\nContract on Delphi [better-call.dev](https://better-call.dev/delphinet/KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm/operations)\n\nOriginate:\n\n```bash\n❯❯❯ alpha-client --wait none originate contract LambdaAdminOracle3 \\\n  transferring 0 from $BOB_ADDRESS running \\\n  \"$(cat lambda_admin_oracle_2.tz | tr -d '\\n')\" \\\n  --init \"(Pair \\\"$BOB_ADDRESS\\\" 1)\" \\\n  --burn-cap 0.127\nWaiting for the node to be bootstrapped before injection...\nCurrent head: BMAk1ar2GRSF (timestamp: 2021-02-03T22:32:57-00:00, validation: 2021-02-03T22:33:15-00:00)\nNode is bootstrapped, ready for injecting operations.\nEstimated gas: 2483.822 units (will add 100 for safety)\nEstimated storage: 508 bytes added (will add 20 for safety)\nOperation successfully injected in the node.\nOperation hash is 'opRb971eCbVJb9ZSU22Go4GKLtPDWUBJSXiWGSbkaZnvZLLk6a3'\nNOT waiting for the operation to be included.\nUse command\n  tezos-client wait for opRb971eCbVJb9ZSU22Go4GKLtPDWUBJSXiWGSbkaZnvZLLk6a3 to be included --confirmations 30 --branch BMAk1ar2GRSFZQig3bcycqn865URmnY1jBjnYmZJ6Wg6x2puDgH\nand/or an external block explorer to make sure that it has been included.\nThis sequence of operations was run:\n  Manager signed operations:\n    From: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n    Fee to the baker: ꜩ0.000753\n    Expected counter: 526617\n    Gas limit: 2584\n    Storage limit: 528 bytes\n    Balance updates:\n      tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm ............. -ꜩ0.000753\n      fees(tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU,204) ... +ꜩ0.000753\n    Origination:\n      From: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n      Credit: ꜩ0\n      Script:\n        { parameter\n            (or (pair %ask (contract (pair string nat)) string)\n                (lambda %admin (pair address mutez) (pair (list operation) (pair address mutez)))) ;\n          storage (pair (address %owner) (mutez %price)) ;\n          code { DUP ;\n                 CDR ;\n                 SWAP ;\n                 CAR ;\n                 IF_LEFT\n                   { DROP ;\n                     DUP ;\n                     CDR ;\n                     AMOUNT ;\n                     COMPARE ;\n                     EQ ;\n                     IF { NIL operation ; PAIR } { PUSH string \"wrong price\" ; FAILWITH } }\n                   { SWAP ;\n                     DUP ;\n                     CAR ;\n                     SENDER ;\n                     COMPARE ;\n                     EQ ;\n                     IF { EXEC } { PUSH string \"not admin\" ; FAILWITH } } } }\n        Initial storage: (Pair \"tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\" 1)\n        No delegate for this contract\n        This origination was successfully applied\n        Originated contracts:\n          KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm\n        Storage size: 251 bytes\n        Paid storage size diff: 251 bytes\n        Consumed gas: 2483.822\n        Balance updates:\n          tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm ... -ꜩ0.06275\n          tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm ... -ꜩ0.06425\n\nNew contract KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm originated.\nContract memorized as LambdaAdminOracle3.\n```\n\nAsk:\n\n```bash\n~/C/m/lorentz-contract-vesting ❯❯❯ alpha-client --wait none transfer 0.000001 from $BOB_ADDRESS to KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm \\\n  --entrypoint ask --arg 'Pair \"KT1HHgfN2v47ogDikDLRKigaXaDAW2rSdyk9\" \"my_query\"'\nWaiting for the node to be bootstrapped before injection...\nCurrent head: BLL1JWxNy3QR (timestamp: 2021-02-03T22:34:27-00:00, validation: 2021-02-03T22:34:35-00:00)\nNode is bootstrapped, ready for injecting operations.\nEstimated gas: 4050.339 units (will add 100 for safety)\nEstimated storage: no bytes added\nOperation successfully injected in the node.\nOperation hash is 'ookvVazPMc8cDPPVmqLopdHWG5yWyFWnSTHKH8rv8ixGCnjyFrQ'\nNOT waiting for the operation to be included.\nUse command\n  tezos-client wait for ookvVazPMc8cDPPVmqLopdHWG5yWyFWnSTHKH8rv8ixGCnjyFrQ to be included --confirmations 30 --branch BLL1JWxNy3QRSskj12b7fgLiutntgoruJjhEuCw3D5iYibYwfrc\nand/or an external block explorer to make sure that it has been included.\nThis sequence of operations was run:\n  Manager signed operations:\n    From: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n    Fee to the baker: ꜩ0.000731\n    Expected counter: 526618\n    Gas limit: 4151\n    Storage limit: 0 bytes\n    Balance updates:\n      tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm ............. -ꜩ0.000731\n      fees(tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU,204) ... +ꜩ0.000731\n    Transaction:\n      Amount: ꜩ0.000001\n      From: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n      To: KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm\n      Entrypoint: ask\n      Parameter: (Pair \"KT1HHgfN2v47ogDikDLRKigaXaDAW2rSdyk9\" \"my_query\")\n      This transaction was successfully applied\n      Updated storage:\n        (Pair 0x0000aad02222472cdf9892a3011c01caf6407f027081 1)\n      Storage size: 251 bytes\n      Consumed gas: 4050.339\n      Balance updates:\n        tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm ... -ꜩ0.000001\n        KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm ... +ꜩ0.000001\n```\n\nMake Fred the owner:\n\n```bash\n❯❯❯ alpha-client --wait none transfer 0 from $BOB_ADDRESS to KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm \\\n  --entrypoint admin --arg '{ CDR; PUSH address \"tz1RwoEdg4efDQHarsw6aKtMUYvg278Gv1ir\"; PAIR; NIL operation; PAIR }'\nWaiting for the node to be bootstrapped before injection...\nCurrent head: BLXqbDdeAiFa (timestamp: 2021-02-03T22:45:47-00:00, validation: 2021-02-03T22:46:14-00:00)\nNode is bootstrapped, ready for injecting operations.\nEstimated gas: 3550.653 units (will add 100 for safety)\nEstimated storage: no bytes added\nOperation successfully injected in the node.\nOperation hash is 'op1QEQKK2JuCf6MfDDMT76ZYiicWQ9AJiX6uF1z3TVu82xBd3mp'\nNOT waiting for the operation to be included.\nUse command\n  tezos-client wait for op1QEQKK2JuCf6MfDDMT76ZYiicWQ9AJiX6uF1z3TVu82xBd3mp to be included --confirmations 30 --branch BLXqbDdeAiFa91V3B3mbqxt977SU9q673QpnahJtNQ9AjFjj9C5\nand/or an external block explorer to make sure that it has been included.\nThis sequence of operations was run:\n  Manager signed operations:\n    From: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n    Fee to the baker: ꜩ0.000687\n    Expected counter: 526619\n    Gas limit: 3651\n    Storage limit: 0 bytes\n    Balance updates:\n      tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm ............. -ꜩ0.000687\n      fees(tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU,204) ... +ꜩ0.000687\n    Transaction:\n      Amount: ꜩ0\n      From: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n      To: KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm\n      Entrypoint: admin\n      Parameter: { CDR ;\n                   PUSH address \"tz1RwoEdg4efDQHarsw6aKtMUYvg278Gv1ir\" ;\n                   PAIR ;\n                   NIL operation ;\n                   PAIR }\n      This transaction was successfully applied\n      Updated storage:\n        (Pair 0x0000452d024b72d5897f14a02dc1a3b8e012c802cc3d 1)\n      Storage size: 251 bytes\n      Consumed gas: 3550.653\n```\n\nSet the price to `2 mutez`:\n\n```bash\n❯❯❯ alpha-client --wait none transfer 0 from $BOB_ADDRESS to KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm \\\n  --entrypoint admin --arg '{ CAR; PUSH mutez 2; SWAP; PAIR; NIL operation; PAIR }'\nWaiting for the node to be bootstrapped before injection...\nCurrent head: BKvisxu111qX (timestamp: 2021-02-03T22:48:47-00:00, validation: 2021-02-03T22:49:05-00:00)\nNode is bootstrapped, ready for injecting operations.\nThis simulation failed:\n  Manager signed operations:\n    From: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n    Fee to the baker: ꜩ0\n    Expected counter: 526620\n    Gas limit: 1040000\n    Storage limit: 60000 bytes\n    Transaction:\n      Amount: ꜩ0\n      From: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n      To: KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm\n      Entrypoint: admin\n      Parameter: { CAR ; PUSH mutez 2 ; SWAP ; PAIR ; NIL operation ; PAIR }\n      This operation FAILED.\n\nRuntime error in contract KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm:\n  01: { parameter\n  02:     (or (pair %ask (contract (pair string nat)) string)\n  03:         (lambda %admin (pair address mutez) (pair (list operation) (pair address mutez)))) ;\n  04:   storage (pair (address %owner) (mutez %price)) ;\n  05:   code { DUP ;\n  06:          CDR ;\n  07:          SWAP ;\n  08:          CAR ;\n  09:          IF_LEFT\n  10:            { DROP ;\n  11:              DUP ;\n  12:              CDR ;\n  13:              AMOUNT ;\n  14:              COMPARE ;\n  15:              EQ ;\n  16:              IF { NIL operation ; PAIR } { PUSH string \"wrong price\" ; FAILWITH } }\n  17:            { SWAP ;\n  18:              DUP ;\n  19:              CAR ;\n  20:              SENDER ;\n  21:              COMPARE ;\n  22:              EQ ;\n  23:              IF { EXEC } { PUSH string \"not admin\" ; FAILWITH } } } }\nAt line 23 characters 53 to 61,\nscript reached FAILWITH instruction\nwith \"not admin\"\nFatal error:\n  transfer simulation failed\n```\n\nBut Bob is no longer the admin, so this fails:\n\n```bash\n❯❯❯ alpha-client --wait none transfer 0 from $BOB_ADDRESS to KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm \\\n  --entrypoint admin --arg '{ CAR; PUSH mutez 2; SWAP; PAIR; NIL operation; PAIR }'\nWaiting for the node to be bootstrapped before injection...\nCurrent head: BKvisxu111qX (timestamp: 2021-02-03T22:48:47-00:00, validation: 2021-02-03T22:49:05-00:00)\nNode is bootstrapped, ready for injecting operations.\nThis simulation failed:\n  Manager signed operations:\n    From: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n    Fee to the baker: ꜩ0\n    Expected counter: 526620\n    Gas limit: 1040000\n    Storage limit: 60000 bytes\n    Transaction:\n      Amount: ꜩ0\n      From: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n      To: KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm\n      Entrypoint: admin\n      Parameter: { CAR ; PUSH mutez 2 ; SWAP ; PAIR ; NIL operation ; PAIR }\n      This operation FAILED.\n\nRuntime error in contract KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm:\n  01: { parameter\n  02:     (or (pair %ask (contract (pair string nat)) string)\n  03:         (lambda %admin (pair address mutez) (pair (list operation) (pair address mutez)))) ;\n  04:   storage (pair (address %owner) (mutez %price)) ;\n  05:   code { DUP ;\n  06:          CDR ;\n  07:          SWAP ;\n  08:          CAR ;\n  09:          IF_LEFT\n  10:            { DROP ;\n  11:              DUP ;\n  12:              CDR ;\n  13:              AMOUNT ;\n  14:              COMPARE ;\n  15:              EQ ;\n  16:              IF { NIL operation ; PAIR } { PUSH string \"wrong price\" ; FAILWITH } }\n  17:            { SWAP ;\n  18:              DUP ;\n  19:              CAR ;\n  20:              SENDER ;\n  21:              COMPARE ;\n  22:              EQ ;\n  23:              IF { EXEC } { PUSH string \"not admin\" ; FAILWITH } } } }\nAt line 23 characters 53 to 61,\nscript reached FAILWITH instruction\nwith \"not admin\"\nFatal error:\n  transfer simulation failed\n```\n\nFred can update it to `2 mutez`, however:\n\n```bash\n❯❯❯ alpha-client --wait none transfer 0 from $FRED_ADDRESS to KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm \\\n  --entrypoint admin --arg '{ CAR; PUSH mutez 2; SWAP; PAIR; NIL operation; PAIR }'\nWaiting for the node to be bootstrapped before injection...\nCurrent head: BKwRQxtfx6oY (timestamp: 2021-02-03T22:51:37-00:00, validation: 2021-02-03T22:51:50-00:00)\nNode is bootstrapped, ready for injecting operations.\nEstimated gas: 3499.533 units (will add 100 for safety)\nEstimated storage: no bytes added\nOperation successfully injected in the node.\nOperation hash is 'opQKw7eAnahYi6NFsgCMbqeU6RfQ89k9Y2R7BEvWwU4pAAnnZCr'\nNOT waiting for the operation to be included.\nUse command\n  tezos-client wait for opQKw7eAnahYi6NFsgCMbqeU6RfQ89k9Y2R7BEvWwU4pAAnnZCr to be included --confirmations 30 --branch BKwRQxtfx6oYTdPqAQP4RAqqkAQfS4Ar15uj1xsHcnGLFmo6oLo\nand/or an external block explorer to make sure that it has been included.\nThis sequence of operations was run:\n  Manager signed operations:\n    From: tz1RwoEdg4efDQHarsw6aKtMUYvg278Gv1ir\n    Fee to the baker: ꜩ0.001259\n    Expected counter: 1242109\n    Gas limit: 10000\n    Storage limit: 0 bytes\n    Balance updates:\n      tz1RwoEdg4efDQHarsw6aKtMUYvg278Gv1ir ............. -ꜩ0.001259\n      fees(tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU,204) ... +ꜩ0.001259\n    Revelation of manager public key:\n      Contract: tz1RwoEdg4efDQHarsw6aKtMUYvg278Gv1ir\n      Key: edpkvMCwX3MyDg92HckSwFVofR8hcZEjAqrhWJ8SGQgkGjgK1V1gPo\n      This revelation was successfully applied\n      Consumed gas: 1000\n  Manager signed operations:\n    From: tz1RwoEdg4efDQHarsw6aKtMUYvg278Gv1ir\n    Fee to the baker: ꜩ0.000548\n    Expected counter: 1242110\n    Gas limit: 3600\n    Storage limit: 0 bytes\n    Balance updates:\n      tz1RwoEdg4efDQHarsw6aKtMUYvg278Gv1ir ............. -ꜩ0.000548\n      fees(tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU,204) ... +ꜩ0.000548\n    Transaction:\n      Amount: ꜩ0\n      From: tz1RwoEdg4efDQHarsw6aKtMUYvg278Gv1ir\n      To: KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm\n      Entrypoint: admin\n      Parameter: { CAR ; PUSH mutez 2 ; SWAP ; PAIR ; NIL operation ; PAIR }\n      This transaction was successfully applied\n      Updated storage:\n        (Pair 0x0000452d024b72d5897f14a02dc1a3b8e012c802cc3d 2)\n      Storage size: 251 bytes\n      Consumed gas: 3499.533\n```\n\nBob now tries to ask with only `1 mutez`:\n\n```bash\n❯❯❯ alpha-client --wait none transfer 0.000001 from $BOB_ADDRESS to KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm \\\n  --entrypoint ask --arg 'Pair \"KT1HHgfN2v47ogDikDLRKigaXaDAW2rSdyk9\" \"my_query\"'\nWaiting for the node to be bootstrapped before injection...\nCurrent head: BMAT8i5MGPt2 (timestamp: 2021-02-03T22:53:37-00:00, validation: 2021-02-03T22:53:53-00:00)\nNode is bootstrapped, ready for injecting operations.\nThis simulation failed:\n  Manager signed operations:\n    From: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n    Fee to the baker: ꜩ0\n    Expected counter: 526620\n    Gas limit: 1040000\n    Storage limit: 60000 bytes\n    Transaction:\n      Amount: ꜩ0.000001\n      From: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n      To: KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm\n      Entrypoint: ask\n      Parameter: (Pair \"KT1HHgfN2v47ogDikDLRKigaXaDAW2rSdyk9\" \"my_query\")\n      This operation FAILED.\n\nRuntime error in contract KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm:\n  01: { parameter\n  02:     (or (pair %ask (contract (pair string nat)) string)\n  03:         (lambda %admin (pair address mutez) (pair (list operation) (pair address mutez)))) ;\n  04:   storage (pair (address %owner) (mutez %price)) ;\n  05:   code { DUP ;\n  06:          CDR ;\n  07:          SWAP ;\n  08:          CAR ;\n  09:          IF_LEFT\n  10:            { DROP ;\n  11:              DUP ;\n  12:              CDR ;\n  13:              AMOUNT ;\n  14:              COMPARE ;\n  15:              EQ ;\n  16:              IF { NIL operation ; PAIR } { PUSH string \"wrong price\" ; FAILWITH } }\n  17:            { SWAP ;\n  18:              DUP ;\n  19:              CAR ;\n  20:              SENDER ;\n  21:              COMPARE ;\n  22:              EQ ;\n  23:              IF { EXEC } { PUSH string \"not admin\" ; FAILWITH } } } }\nAt line 16 characters 71 to 79,\nscript reached FAILWITH instruction\nwith \"wrong price\"\nFatal error:\n  transfer simulation failed\n```\n\nBut it fails, since the price has been updated to `2 mutez`.\n\nBob then tries to ask with `2 mutez`:\n\n```bash\n❯❯❯ alpha-client --wait none transfer 0.000002 from $BOB_ADDRESS to KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm \\\n  --entrypoint ask --arg 'Pair \"KT1HHgfN2v47ogDikDLRKigaXaDAW2rSdyk9\" \"my_query\"'\nWaiting for the node to be bootstrapped before injection...\nCurrent head: BLTJP9yYX7aP (timestamp: 2021-02-03T22:54:37-00:00, validation: 2021-02-03T22:54:58-00:00)\nNode is bootstrapped, ready for injecting operations.\nEstimated gas: 4050.339 units (will add 100 for safety)\nEstimated storage: no bytes added\nOperation successfully injected in the node.\nOperation hash is 'opMaxM1iqD8SbzYd9URMPnXG8jZDXRUDSo3mrYH4K5g52tui9yX'\nNOT waiting for the operation to be included.\nUse command\n  tezos-client wait for opMaxM1iqD8SbzYd9URMPnXG8jZDXRUDSo3mrYH4K5g52tui9yX to be included --confirmations 30 --branch BLTJP9yYX7aPea6unhsvzJwKYRvUZuh7Wpqjx6GAJmgoLyingDM\nand/or an external block explorer to make sure that it has been included.\nThis sequence of operations was run:\n  Manager signed operations:\n    From: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n    Fee to the baker: ꜩ0.000731\n    Expected counter: 526620\n    Gas limit: 4151\n    Storage limit: 0 bytes\n    Balance updates:\n      tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm ............. -ꜩ0.000731\n      fees(tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU,204) ... +ꜩ0.000731\n    Transaction:\n      Amount: ꜩ0.000002\n      From: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n      To: KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm\n      Entrypoint: ask\n      Parameter: (Pair \"KT1HHgfN2v47ogDikDLRKigaXaDAW2rSdyk9\" \"my_query\")\n      This transaction was successfully applied\n      Updated storage:\n        (Pair 0x0000452d024b72d5897f14a02dc1a3b8e012c802cc3d 2)\n      Storage size: 251 bytes\n      Consumed gas: 4050.339\n      Balance updates:\n        tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm ... -ꜩ0.000002\n        KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm ... +ꜩ0.000002\n```\n\nAnd it succeeds.\n\nWe can now verify that the oracle contract holds `3 mutez`:\n\n```bash\n❯❯❯ alpha-client get balance for KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm\n\n0.000003 ꜩ\n```\n\nFred decides to send the entire balance to Bob:\n\n```bash\n❯❯❯ alpha-client --wait none transfer 0 from $FRED_ADDRESS to KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm \\\n  --entrypoint admin --arg \"{ NIL operation; PUSH address \\\"$BOB_ADDRESS\\\"; CONTRACT unit; IF_NONE { PUSH string \\\"not receiver\\\";FAILWITH } { PUSH mutez 3;UNIT;TRANSFER_TOKENS;CONS;PAIR } }\"\n\nWaiting for the node to be bootstrapped before injection...\nCurrent head: BMS2Vkyw5Bgq (timestamp: 2021-02-03T23:00:08-00:00, validation: 2021-02-03T23:00:23-00:00)\nNode is bootstrapped, ready for injecting operations.\nEstimated gas: 5414.383 units (will add 100 for safety)\nEstimated storage: no bytes added\nOperation successfully injected in the node.\nOperation hash is 'onhhCv9Fshn73KbDosiYRnZvov29xCcYmNduzE4hCtNzU8awszW'\nNOT waiting for the operation to be included.\nUse command\n  tezos-client wait for onhhCv9Fshn73KbDosiYRnZvov29xCcYmNduzE4hCtNzU8awszW to be included --confirmations 30 --branch BMS2Vkyw5BgqpdHnp2SNwmrR8LSukTh7fgiVsisSTAW8zorsh38\nand/or an external block explorer to make sure that it has been included.\nThis sequence of operations was run:\n  Manager signed operations:\n    From: tz1RwoEdg4efDQHarsw6aKtMUYvg278Gv1ir\n    Fee to the baker: ꜩ0.00092\n    Expected counter: 1242111\n    Gas limit: 5515\n    Storage limit: 0 bytes\n    Balance updates:\n      tz1RwoEdg4efDQHarsw6aKtMUYvg278Gv1ir ............. -ꜩ0.00092\n      fees(tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU,204) ... +ꜩ0.00092\n    Transaction:\n      Amount: ꜩ0\n      From: tz1RwoEdg4efDQHarsw6aKtMUYvg278Gv1ir\n      To: KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm\n      Entrypoint: admin\n      Parameter: { NIL operation ;\n                   PUSH address \"tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\" ;\n                   CONTRACT unit ;\n                   IF_NONE\n                     { PUSH string \"not receiver\" ; FAILWITH }\n                     { PUSH mutez 3 ; UNIT ; TRANSFER_TOKENS ; CONS ; PAIR } }\n      This transaction was successfully applied\n      Updated storage:\n        (Pair 0x0000452d024b72d5897f14a02dc1a3b8e012c802cc3d 2)\n      Storage size: 251 bytes\n      Consumed gas: 3987.383\n    Internal operations:\n      Transaction:\n        Amount: ꜩ0.000003\n        From: KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm\n        To: tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm\n        This transaction was successfully applied\n        Consumed gas: 1427\n        Balance updates:\n          KT18rqmG2eV33cZYQR9JMDAtzf8yEp59Nnqm ... -ꜩ0.000003\n          tz1bDCu64RmcpWahdn9bWrDMi6cu7mXZynHm ... +ꜩ0.000003\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftqtezos%2Fpriced-event-oracle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftqtezos%2Fpriced-event-oracle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftqtezos%2Fpriced-event-oracle/lists"}