https://github.com/smartcontractkit/cairo-starter-kit
The boilerplate code for getting started with the usage of Chainlink services on Starknet
https://github.com/smartcontractkit/cairo-starter-kit
Last synced: about 2 months ago
JSON representation
The boilerplate code for getting started with the usage of Chainlink services on Starknet
- Host: GitHub
- URL: https://github.com/smartcontractkit/cairo-starter-kit
- Owner: smartcontractkit
- License: mit
- Created: 2023-03-21T12:58:01.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-29T23:54:17.000Z (about 2 years ago)
- Last Synced: 2025-04-30T18:48:58.337Z (about 2 months ago)
- Language: TypeScript
- Homepage: https://docs.chain.link/data-feeds/starknet
- Size: 229 KB
- Stars: 9
- Watchers: 6
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Chainlink Cairo Starter Kit
[](https://gitpod.io/#https://github.com/smartcontractkit/cairo-starter-kit)
The boilerplate code for getting started with the usage of Chainlink services on Starknet. [Here](https://docs.chain.link/data-feeds/starknet) you can visit the official Chainlink documentation for using Data Feeds on Starknet.
_This repository represents an example of using a Chainlink product or service. It is provided to to help you understand how to interact with Chainlink’s systems so that you can integrate them into your own. This template is provided "AS IS" without warranties of any kind, has not been audited, and may be missing key checks or error handling to make the usage of the product more clear. Take everything in this repository as an example and not something to be copy pasted into a production ready service._
## Getting started
### Prerequisites
Be sure to have installed the following
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [Node.js](https://nodejs.org/en/download/) in the `>=14 <=18` version range
- [Yarn](https://yarnpkg.com/getting-started/install)
- [Python](https://www.python.org/downloads/) in the `>=3.6 <=3.9` version range### Clone the repository
To clone the repository, run the following commands:
```
git clone https://github.com/smartcontractkit/cairo-starter-kit.git
cd cairo-starter-kit
```### Setting Up Starknet
To set up your Starknet development environment, follow the [official quickstart guide](https://docs.starknet.io/documentation/getting_started/setting_up_the_environment/).
Here you can see listed all of the commands from the mentioned quickstart guide.
- `python3.9 -m venv ~/cairo_venv`
- `source ~/cairo_venv/bin/activate`
- `pip3 install ecdsa fastecdsa sympy`
- `brew install gmp`
- `pip3 install cairo-lang`Verify that all of the required tools are configured correctly:
- Starknet CLI
- Run: `starknet -v`
- Expected output: `starknet 0.10.3`
- Cairo CLI
- Run: `cairo-compile -v`
- Expected output: `cairo-compile 0.10.3`
- NodeJS
- Run: `node -v`
- Expected output: `v18.12.1`
- Yarn
- Run: `yarn --version`
- Expected output: `1.22.19`### Compiling and running your first Cairo program
Not all Cairo programs are valid Starknet smart contracts. To compile your first Cairo program run the following command:
```
cairo-compile contracts/MyFirstCairoProgram.cairo --output MyFirstCairoProgram_compiled.json
```To debug the execution of your first Cairo program, execute the next command, and then open the http://localhost:8100/
```
cairo-run --program=MyFirstCairoProgram_compiled.json --print_output --print_info --relocate_prints --tracer
```### Usage
This repo comes with the Hardhat project which was set up for working with Starknet using the `@shardlabs/starknet-hardhat-plugin` plugin.
To get started run:
```
npm install# or
yarn install
```To compile contracts run the next command:
```
yarn build
```To deploy the Starknet Data Feeds Consumer contract on the Starknet Goerli Alpha Testnet, run:
```
yarn deploy
```Now you can get the latest price of LINK/USD on Starknet Goerli Alpha Testnet by running:
```
yarn readLatestRound
```Optionally, you can query LINK/USD data feed without deploying the Proxy Consumer contract, completely off-chain. To do that, run the following command:
```
yarn readLatestRoundOffChain
```Or directly from the CLI, without the usage of Hardhat tasks:
```
starknet call --address 0x2579940ca3c41e7119283ceb82cd851c906cbb1510908a913d434861fdcb245 --function latest_round_data --abi ./contracts/abis/aggregator_proxy_abi.json
```To see addresses of other available data feeds on Starknet, besides LINK/USD, visit the [official Chainlink documentation](https://docs.chain.link/data-feeds/price-feeds/addresses?network=starknet).
### Creating Starknet Account
All accounts on Starknet are represented as smart contracts. To set up your Starknet account, follow the [official guide](https://docs.starknet.io/documentation/getting_started/account_setup/).
To see the details of your default Starknet account on the Starknet Goerli Alpha Testnet, run the following command:
```
open ~/.starknet_accounts/starknet_open_zeppelin_accounts.json
```### Block Explorer
The Starknet Goerli Alpha Testnet block explorer is available at https://testnet.starkscan.co/.
## Contributing
Contributions are always welcome! Open a PR or an issue! Thank you!