{"id":17725480,"url":"https://github.com/Entangle-Protocol/universal-data-feeds-solana","last_synced_at":"2025-04-01T16:30:32.090Z","repository":{"id":259229098,"uuid":"862306069","full_name":"Entangle-Protocol/universal-data-feeds-solana","owner":"Entangle-Protocol","description":"Provides facilities to store Entangle data feeds on Solana","archived":false,"fork":false,"pushed_at":"2024-11-18T07:12:49.000Z","size":225,"stargazers_count":2,"open_issues_count":5,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-20T21:43:48.755Z","etag":null,"topics":["solana","udf"],"latest_commit_sha":null,"homepage":"https://entangle.fi","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Entangle-Protocol.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-24T11:36:23.000Z","updated_at":"2024-11-22T11:42:33.000Z","dependencies_parsed_at":"2024-10-23T17:57:23.397Z","dependency_job_id":"254cb1ae-695e-4d45-8b3a-eb5a6d3c2a08","html_url":"https://github.com/Entangle-Protocol/universal-data-feeds-solana","commit_stats":null,"previous_names":["entangle-protocol/udf-price-oracle-solana","entangle-protocol/universal-data-feeds-solana"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Entangle-Protocol%2Funiversal-data-feeds-solana","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Entangle-Protocol%2Funiversal-data-feeds-solana/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Entangle-Protocol%2Funiversal-data-feeds-solana/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Entangle-Protocol%2Funiversal-data-feeds-solana/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Entangle-Protocol","download_url":"https://codeload.github.com/Entangle-Protocol/universal-data-feeds-solana/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246670363,"owners_count":20814972,"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":["solana","udf"],"created_at":"2024-10-25T16:04:38.390Z","updated_at":"2025-04-01T16:30:32.081Z","avatar_url":"https://github.com/Entangle-Protocol.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://docs.entangle.fi/~gitbook/image?url=https%3A%2F%2F4040807501-files.gitbook.io%2F~%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F5AajewgFWO9EkufRORqL%252Fuploads%252FDfRGGJJASR0PFitX6rbx%252FTwitter%2520%281%29.png%3Falt%3Dmedia%26token%3D09e49fe6-1b92-4bed-82e6-730ba785afaf\u0026width=1248\u0026dpr=2\u0026quality=100\u0026sign=5fbbb9f4\u0026sv=1\" alt=\"Entangle\" style=\"width:100%;\"/\u003e\n\n# The Universal Data Feeds price oracle - solana\n\nThis repository consists of both the program implementing the Entangle Universal Data Feeds (UDF) and a plugin used\nwithin\nthe [Pull Update Publisher](https://github.com/Entangle-Protocol/udf-update-publisher) facility to interact with Solana,\nas one out of the many blockchains are supposed to receive price feeds.\n\n- The [price oracle program](./programs/udf-solana) securely stores real-time data, validated by signatures from trusted\n  transmitters who gather it from multiple sources.\n- The [Pull Update Publisher plugin](./price-publisher) is loaded as a shared library at runtime and\n  communicates [with the main application](https://github.com/Entangle-Protocol/udf-update-publisher) through the\n  Foreign Function Interface (FFI). This plugin uses the received data feeds to construct, execute, and process the\n  results of Solana transactions, ensuring that the data is properly transmitted and validated on the blockchain.\n\n## Table of Contents\n\n- [Build and install](#build-and-install)\n    - [Build udf solana](#build-udf_solana)\n        - [mainnet](#mainnet)\n        - [devnet, localnet](#devnet-localnet)\n    - [Building publisher lib](#building-publisher-lib)\n- [Testing](#testing)\n    - [Testing udf locally](#testing-udf-locally)\n        - [Starting Solana test validator](#starting-solana-test-validator)\n        - [Deploying UDF price oracle contract](#deploying-udf-price-oracle-contract)\n        - [Running tests](#running-tests)\n        - [Publishing anchor IDL](#publishing-anchor-idl)\n    - [Checking accounts using anchor the CLI](#checking-accounts-using-anchor-cli)\n- [Changelog](CHANGELOG.md)\n- [Contributing](CONTRIBUTING.md)\n- [Code of Conduct](CODE_OF_CONDUCT.md)\n- [License](LICENSE)\n\n## Build and install\n\n### Build udf_solana\n\nThe following command not only builds the udf_solana but also compiles both the `photon_mock` and `price_consumer`,\nwhich are intended for testing purposes.\n\n#### mainnet\n\nThe `mainnet` build feature is distinct as it embeds the administrator public key directly within the code.\n\n```\nRUSTFLAGS=\"--cfg feature=\\\"mainnet\\\"\" anchor build\n```\n\n#### devnet, localnet\n\nThe default build is distinct in that it embeds the testing administrator public key, which is derived from\nkeys/owner.json,\ndirectly within the code.\n\n```\nanchor build\n```\n\n### Building publisher lib\n\nPublisher lib is used as a plugin for pull update publisher service that publishes prices to the multiple chains.\nIt's supposed that pull update publisher source directory exists at the given path\n\n```\ncargo build --release -Z unstable-options -p price-publisher --out-dir ../pull-update-publisher\n```\n\n## Testing\n\n### Testing udf locally\n\nTesting the udf_solana program allows us to ensure it works in the same way on the mainnet. It assumes starting\nthe solana validator locally, deploying programs in it and running tests.\n\nIt is also possible to run standalone sample scripts provided within\nthe [udf-samples on the github](https://github.com/Entangle-Protocol/udf-examples).\n\n#### Starting Solana test validator\n\nThe local Solana test validator is supposed to be started to make it able to deploy contracts and to initialize the\ntesting state on it.\n\n```shell\nsolana-test-validator  --reset --config solana_config.yml \n```\n\n#### Deploying UDF price oracle contract\n\nThe next step involves deploying the udf-solana, price_consumer, and photon_mock programs in sequence:\n\n- udf-solana: This is the price oracle program that defines the rules for how and where price feeds are validated and\n  stored on-chain. It serves as the backbone for ensuring the accuracy and security of price data within the network.\n- price_consumer: This is a sample contract designed to demonstrate how client contracts can be structured and\n  implemented. It shows how external developers can integrate price-consuming functionality into their own programs.\n- photon_mock: This is a mock version of the Photon CCM, used for testing purposes. It simulates the behavior of the\n  real Photon CCM by providing a set of fake transmitters responsible for validating price feed signatures, enabling a\n  controlled environment for testing price validation.\n\nBy deploying these programs in turn, you can set up a functional environment for testing and demonstrating how the price\nfeeds are managed and validated on the Solana blockchain.\n\n```shell\nanchor deploy --provider.cluster localnet --program-name udf-solana --program-keypair keys/udf_solana-keypair.json --provider.wallet keys/owner.json \u0026\u0026 \\\nanchor deploy --provider.cluster localnet --program-name price_consumer --program-keypair keys/price-consumer.json --provider.wallet keys/owner.json \u0026\u0026 \\\nanchor deploy --provider.cluster localnet --program-name price_consumer_pull --program-keypair keys/price_consumer_pull-keypair.json --provider.wallet keys/owner.json \u0026\u0026 \\\nanchor deploy --provider.cluster localnet --program-name photon_mock --program-keypair keys/photon-keypair.json --provider.wallet keys/owner.json\n```\n\n#### Running tests\n\nDuring the subsequent process, both the PULL and PUSH UDF models are tested. This step also sets up the initial local\nenvironment, which can be used for further interactions by sample client programs. By creating this environment,\ndevelopers can test and demonstrate how the UDF models operate in different scenarios, ensuring seamless integration\nand functionality for both models within the system.\n\n```shell\nanchor test --skip-deploy --skip-build --skip-local-validator --provider.wallet keys/owner.json\n```\n\n#### Publishing anchor IDL\n\nPublishing the Anchor IDL for the price consumer sample program stores the IDL on-chain at the program-derived address\n(PDA) based on the program's initial address. This allows clients to interact with the price consumer program without\nembedding the IDL in the client code.\n\n```shell\nanchor idl init --provider.cluster localnet --provider.wallet keys/owner.json --filepath target/idl/price_consumer.json 3r5ixGQu8DRmJWgFEjwnDUQ6yasfYFXDsUbqkA6gkRtv\nanchor idl init --provider.cluster localnet --provider.wallet keys/owner.json --filepath target/idl/price_consumer_pull.json GHzaqPXQUSQ4AD9c7w7dgA3LR4ztZYTDGKqs5E2JZTwJ\nanchor idl init --provider.cluster localnet --provider.wallet keys/owner.json --filepath target/idl/udf_solana.json 7HramSnctpbXqZ4SEzqvqteZdMdj3tEB2c9NT7egPQi7\n```\n\n### Checking accounts using anchor CLI\n\nIn some cases, it can be helpful to verify whether the accounts specified in the Solana programs are initialized\ncorrectly.\nFor testing purposes, the Anchor SDK provides CLI commands that allow us to check if an account is structured and\ninitialized as expected.\n\nFor example, to check the ProtocolInfo account defined within the photon_mock program, you can use the following\ncommand:\n\n```shell\nanchor account --provider.cluster localnet  --provider.wallet keys/owner.json photon.ProtocolInfo 3S41QhsrzERXpFuAiJD2uZbUqEyvS2FYHPHKak6MKMdr | jq -c\n```\n\nThis command fetches the account data and formats it using jq to provide a compact JSON view. Additionally, if it's\nnecessary\nto check the latest update without creating a client project, similar commands can be used to inspect the state of the\nrelevant on-chain accounts, ensuring the data is correctly stored and accessible. This approach allows for quick\nverification without the need for a full client-side implementation.\n\n```shell\nanchor account --provider.cluster localnet  --provider.wallet keys/owner.json udf_solana.LatestUpdate GdhgwM9UP19849bDkyAEiEre5prTNWbMMKWDonJEvkCU | jq -c\n{\n    \"data\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30,251,78,3,14,123],\n    \"dataKey\":[71,65,83,45,69,84,72,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\n    \"dataTimestamp\":1721300185\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEntangle-Protocol%2Funiversal-data-feeds-solana","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEntangle-Protocol%2Funiversal-data-feeds-solana","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEntangle-Protocol%2Funiversal-data-feeds-solana/lists"}