|
| 1 | +# Send-USD example for Starknet |
| 2 | + |
| 3 | +This contract demonstrates usage of Pyth Price Feeds on Starknet. See [this page](https://docs.pyth.network/price-feeds/use-real-time-data/starknet) for more information. |
| 4 | + |
| 5 | +## Setting up your environment |
| 6 | + |
| 7 | +1. Install Scarb (the Cairo and Starknet development toolchain) by following [the installation instructions](https://docs.swmansion.com/scarb/download). |
| 8 | +2. Install Starknet Foundry by following [the installation instructions](https://foundry-rs.github.io/starknet-foundry/getting-started/installation.html). |
| 9 | +3. Install Starkli (a cli tool for Starknet) by following [the installation instructions](https://github.com/xJonathanLEI/starkli). |
| 10 | +4. Install Katana (a local Starknet node) by following [the installation instructions](https://book.starknet.io/ch02-04-katana.html). |
| 11 | + |
| 12 | +The `.tool-versions` file in the `contract` directory specifies the tool versions used by the contract. |
| 13 | + |
| 14 | +## Local deployment |
| 15 | + |
| 16 | +1. Start `katana` and keep it running in a separate shell. |
| 17 | +2. Deploy pyth contract to katana by running the following commands: |
| 18 | + |
| 19 | +```bash |
| 20 | +git clone https://github.com/pyth-network/pyth-crosschain.git |
| 21 | +cd pyth-crosschain/target_chains/starknet/contracts |
| 22 | +deploy/deploy.sh > ~/pyth.env |
| 23 | +``` |
| 24 | + |
| 25 | +This generates `~/pyth.env` file that should contain the address of the deployed contract, for example: |
| 26 | + |
| 27 | +```bash |
| 28 | +$ cat ~/pyth.env |
| 29 | +PYTH_WORMHOLE_ADDRESS=0x07fa5a689a768982ecb60ed05f39ca8f6efe623dd32ee6f3608662e3452a104c |
| 30 | +PYTH_CONTRACT_ADDRESS=0x00f61bf0314a478bfc865c71d33cc53c77d0f994ea4a228ccf888d14435a8821 |
| 31 | +``` |
| 32 | + |
| 33 | +3. Apply these variables to your current shell: |
| 34 | + |
| 35 | +```bash |
| 36 | +export $(xargs < ~/pyth.env) |
| 37 | +``` |
| 38 | + |
| 39 | +4. Run Send-USD deploy script: |
| 40 | + |
| 41 | +```bash |
| 42 | +cd pyth-examples/price_feeds/starknet/send_usd/contract |
| 43 | +deploy/deploy.sh > ~/send_usd.env |
| 44 | +``` |
| 45 | + |
| 46 | +To verify your deployment, do the following steps: |
| 47 | + |
| 48 | +1. Apply `SEND_USD_CONTRACT_ADDRESS` variable to your current shell: |
| 49 | + |
| 50 | +```bash |
| 51 | +export $(xargs < ~/send_usd.env) |
| 52 | +``` |
| 53 | + |
| 54 | +2. Set the following variables: |
| 55 | + |
| 56 | +```bash |
| 57 | +export ACCOUNT_PRIVATE_KEY=0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a |
| 58 | +export ACCOUNT_ADDRESS=0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca |
| 59 | +``` |
| 60 | +This account should be pre-deployed and pre-funded in katana, so you will be able to send transactions from it. |
| 61 | + |
| 62 | +3. Run the client: |
| 63 | + |
| 64 | +```bash |
| 65 | +cd ../client |
| 66 | +npm install |
| 67 | +npm run start |
| 68 | +``` |
0 commit comments