{"id":31924034,"url":"https://github.com/chainsafe/api3-rust","last_synced_at":"2025-10-14T00:00:06.167Z","repository":{"id":37728699,"uuid":"470237066","full_name":"ChainSafe/api3-rust","owner":"ChainSafe","description":"Rewrite API3 Solidity contracts in Rust (for Solana, Near, Oasis)","archived":false,"fork":false,"pushed_at":"2023-02-04T10:35:10.000Z","size":940,"stargazers_count":8,"open_issues_count":5,"forks_count":5,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-10-02T02:53:24.277Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChainSafe.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":"2022-03-15T16:10:52.000Z","updated_at":"2022-07-26T23:27:38.000Z","dependencies_parsed_at":"2023-02-12T07:02:02.346Z","dependency_job_id":null,"html_url":"https://github.com/ChainSafe/api3-rust","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ChainSafe/api3-rust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainSafe%2Fapi3-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainSafe%2Fapi3-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainSafe%2Fapi3-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainSafe%2Fapi3-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChainSafe","download_url":"https://codeload.github.com/ChainSafe/api3-rust/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChainSafe%2Fapi3-rust/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017175,"owners_count":26086019,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-10-13T23:59:15.652Z","updated_at":"2025-10-14T00:00:06.160Z","avatar_url":"https://github.com/ChainSafe.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# API3-Rust\nThis is the repo for RUST implementation of API3's Beacon Server\n\n## Common\nCommon package used for all the subsequent chain implementations.\nTo run all test\n```\ncd common\ncargo test\n```\n\n## Solana\nRead up on anchors https://book.anchor-lang.com/.\nTo build the solana code, do the following in docker container (.devcontainer/Solana-Dockerfile):\n```\ncd solana/beacon-server\nanchor build\nsolana-keygen new\nanchor test\n```\n\nInstead of docker, you can follow installation commands from docker image.\n\n## Near\n### Prerequisite\nRead up on Near from these links:\n- Get started: `https://docs.near.org/docs/develop/contracts/overview`\n- Create account: `https://docs.near.org/docs/develop/basics/create-account#creating-a-testnet-account`\n- Cross contract call: `https://docs.near.org/docs/tutorials/contracts/xcc-receipts`\n- End to end test: `https://docs.near.org/docs/develop/contracts/rust/testing-rust-contracts#end-to-end-tests`\nAfter reading the above, you should be able to know:\n- The basic syntax of writing a Near contract using rust\n- How to create test accounts\n- How and why we need cross contract call\n- How end to end test with javascript is written and tested\n\n### Dev\nTo setup the dev env, checkout the dockerfile in `.devcontainer/Near-Dockerfile`, build and launch the docker. Alternatively,\nwe recommend you use vscode remote docker plugin, you can open this folder in remote docker, then you can have the same dev \nenv.\nOnce in the docker, you can follow the subsection accordingly.\n\n#### Compile\n- go to the near contract folder: `cd near/contract`\n- compile: `cargo build --target wasm32-unknown-unknown --release`\nOnce done you should be able to see, relative to the repo root folder, `target/wasm32-unknown-unknown/release/dapi_server.wasm`.\n\n#### Create test accounts\nYou need to create 3 accounts for testing:\n```\nCONTRACT_ACCOUNT: the account for the dapiServer contract.\nADMIN_ACCOUNT: the default admin of the contract.\nUSER_ACCOUNT: test util account, mainly for reading data points with unlimited access for data verification.\n```\nNow go to near testnet and create the above accounts, you can choose your own names. Remember to define the above env variables with the account \nnames, i.e. for our dev env, it's:\n```\nexport CONTRACT_ACCOUNT=dapi-contract1.testnet\nexport ADMIN_ACCOUNT=mocha-test1.testnet\nexport USER_ACCOUNT=user-test1.testnet\n```\n\n#### Login on CLI\nOnce the acconts are created, you need to login from CLI:\n```\nnear login --account-id ${CONTRACT_ACCOUNT}\nnear login --account-id ${ADMIN_ACCOUNT}\nnear login --account-id ${USER_ACCOUNT}\n```\n\n#### Deploy the contracts\nIn the root folder, deploy the `api3-contract` using:\n```\nnear deploy --wasmFile ./target/wasm32-unknown-unknown/release/dapi_server.wasm --accountId=${CONTRACT_ACCOUNT}\n```\nIf you get error on not enough balance. Run `near dev-deploy ...` and delete generated dev-xxxx account in favour of your account: `near delete dev-xxxx ${CONTRACT_ACCOUNT}`\n\nOnce you have deployed the contract, perform some santiy checks to ensure proper deployment, such as:\n```bash\n# This should pass with no problem\nnear call \u003cCONTRACT_ACCOUNT\u003e grant_role '{\"role\":[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,0,0,0,0,0,0],\"who\":\"user-test1.testnet\"}' --accountId \u003cADMIN_ACCOUNT\u003e\n# This should return true\nnear view \u003cCONTRACT_ACCOUNT\u003e has_role '{\"role\":[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,0,0,0,0,0,0],\"who\":\"user-test1.testnet\"}'\n# This should pass with no problem\nnear call \u003cCONTRACT_ACCOUNT\u003e revoke_role '{\"role\":[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,0,0,0,0,0,0],\"who\":\"user-test1.testnet\"}' --accountId \u003cADMIN_ACCOUNT\u003e\n# This should return false\nnear view \u003cCONTRACT_ACCOUNT\u003e has_role '{\"role\":[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,0,0,0,0,0,0],\"who\":\"user-test1.testnet\"}'\n```\n\n#### Run tests\nThe tests are located in `near/client-test`, the `main` for tests is `near/client-test/tests/test.spec.js`. Use `npm install` if you have not setup before.\n\nTo run the test: `cd near/client-test \u0026\u0026 yarn jest`. Please note that the tests will take around 10 minutes to finish. At the same time, it is also running against a live network, sometimes there will be timeout errors, but near would retry automatically.\n\nWhen the contract reverts execution, the near client would log the contract execution error with `console.warn`. The tests would capture the exceptions thrown and check the expected error name appears in the error message. If you want to disable the warn logs, use `yarn jest --silent`.\n\n#### Clean up\nTo clean up, just delete the accounts using `near delete ... ...`. See `https://docs.near.org/docs/tools/near-cli#near-delete`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainsafe%2Fapi3-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchainsafe%2Fapi3-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainsafe%2Fapi3-rust/lists"}