|
| 1 | +# Inspecting Solana Programs |
| 2 | + |
| 3 | +Programs for Solana can be found in the [programs](/contracts/programs/) directory. Here, you can find source code for each of the Chainlink programs deployed on Solana. |
| 4 | + |
| 5 | +- [Access Controller](/contracts/programs/access-controller/) |
| 6 | +- [OCR2](/contracts/programs/ocr2/) |
| 7 | +- [Store](/contracts/programs/store/) |
| 8 | + |
| 9 | +## Via Gauntlet Inspect |
| 10 | + |
| 11 | +Using Gaunlet, you can inspect the state of Chainlink programs on Solana. |
| 12 | + |
| 13 | +### Inspect Ownership |
| 14 | + |
| 15 | +Gauntlet offers an *inspect_ownership* command for each program. The following is a template for these commands, where PROGRAM_NAME is either ocr2 or access_controller and NETWORK_NAME corresponds to one of the networks defined in the [networks](/gauntlet/packages/gauntlet-solana-contracts/networks/) folder. |
| 16 | + |
| 17 | +```bash |
| 18 | +yarn gauntlet [PROGRAM_NAME]:inspect_ownership --network=[NETWORK_NAME] [PROGRAM_ACCOUNT_ADDRESS] |
| 19 | + |
| 20 | +e.g. |
| 21 | +yarn gauntlet ocr2:inspect_ownership --network=mainnet 2oyA8ZLwuWeAR5ANyDsiEGueUyDC8jFGFLSixSzT9KtV |
| 22 | +``` |
| 23 | + |
| 24 | +This command logs the owner and proposed owner (if defined) of the program account. |
| 25 | + |
| 26 | +```bash |
| 27 | +🧤 gauntlet 0.1.2 |
| 28 | +ℹ️ Loading Local wallet |
| 29 | +Operator address is H2ScWiFt1ZMRR1beYWB6Yr9cuADJ8sQhkGvYJxjJNAh8 |
| 30 | +ℹ️ Checking owner of 2TQmhSnGK5NwdXBKEmJ8wfwH17rNSQgH11SVdHkYC1ZD |
| 31 | +ℹ️ Owner: 2CbCTf2V95kMfNA31yYaqJ9oVX7MN71RU6zvvg27PgSz |
| 32 | +ℹ️ Proposed Owner: 11111111111111111111111111111111 |
| 33 | +✨ Done in 12.38s. |
| 34 | +``` |
| 35 | + |
| 36 | +### OCR2 Inspect |
| 37 | + |
| 38 | +Using Gauntlet, you can query an OCR2 program to obtain information about its oracles and configuration. The following template is used for this command. |
| 39 | + |
| 40 | +```bash |
| 41 | +yarn gauntlet ocr2:inspect --network=[NETWORK_NAME] [PROGRAM_ACCOUNT_ADDRESS] |
| 42 | + |
| 43 | +e.g. |
| 44 | +yarn gauntlet ocr2:inspect --network=devnet 2TQmhSnGK5NwdXBKEmJ8wfwH17rNSQgH11SVdHkYC1ZD |
| 45 | +``` |
| 46 | + |
| 47 | +You can find an example response below. |
| 48 | + |
| 49 | +```bash |
| 50 | +🧤 gauntlet 0.1.2 |
| 51 | +ℹ️ Loading Local wallet |
| 52 | +Operator address is H2ScWiFt1ZMRR1beYWB6Yr9cuADJ8sQhkGvYJxjJNAh8 |
| 53 | +ℹ️ Oracle Info: |
| 54 | + - Transmitter: 6s1wr4fv2GdTkcKxnXRdR429FYadX4mUVn9TMMhh3eMz |
| 55 | + - Proposed Payee: 11111111111111111111111111111111 |
| 56 | + - From Round ID: 0 |
| 57 | + - Payment Gjuels: 223296045 |
| 58 | + |
| 59 | +. |
| 60 | +. |
| 61 | +. |
| 62 | + |
| 63 | +ℹ️ Oracle Info: |
| 64 | + - Transmitter: 7o1AzTiXbvhZH1UV6ZHA664h4hBFbPbFYdLfSnVprRKa |
| 65 | + - Proposed Payee: 11111111111111111111111111111111 |
| 66 | + - From Round ID: 0 |
| 67 | + - Payment Gjuels: 222637143 |
| 68 | + |
| 69 | +ℹ️ Min Answer: 1 |
| 70 | +ℹ️ Max Answer: 100000000000000 |
| 71 | +ℹ️ Transmission Payment: 1 |
| 72 | +ℹ️ Observation Payment: 1 |
| 73 | +ℹ️ Requester Access Controller: 5vkHdxPiTyfY5VdRpPu8tNTpeik6Cy93M6GzztMPWfAk |
| 74 | +ℹ️ Billing Access Controller: CBWXiwPGX6ykWtPGXp4cuFJP53SW81pe9q1YfUASWC46 |
| 75 | +✨ Done in 12.61s. |
| 76 | +``` |
| 77 | + |
| 78 | +## Via Block Explorers |
| 79 | + |
| 80 | +[Solana Explorer](https://explorer.solana.com/) allows users to search for deployed programs and read their state. On the home page, search the address of the program account that you want to inspect. For example, if you want to inspect the OCR2 program for the BTC/USD feed on mainnet, search *2oyA8ZLwuWeAR5ANyDsiEGueUyDC8jFGFLSixSzT9KtV*. |
| 81 | + |
| 82 | +On the program account page, select the *Anchor Account* tab. In this tab, you will be able to inspect all of the data stored on the program in JSON format. In the case of an OCR2 program, this includes on-chain configuration and oracle information. |
| 83 | + |
| 84 | +Other block explorers include: |
| 85 | + |
| 86 | +- [Solscan](https://solscan.io/) |
| 87 | +- [Solana Beach](https://solanabeach.io/) |
| 88 | + |
| 89 | +## Via cURL |
| 90 | + |
| 91 | +You can also interact with deployed programs via cURL. Querying account info using cURL requires the following format. |
| 92 | + |
| 93 | +```bash |
| 94 | +curl [RPC_URL] -X POST -H "Content-Type: application/json" -d ' |
| 95 | + { |
| 96 | + "jsonrpc": "2.0", |
| 97 | + "id": 1, |
| 98 | + "method": "getAccountInfo", |
| 99 | + "params": [ |
| 100 | + "ACCOUNT_ADDRESS", |
| 101 | + { |
| 102 | + "encoding": "base58" |
| 103 | + } |
| 104 | + ] |
| 105 | + } |
| 106 | +' |
| 107 | +``` |
| 108 | + |
| 109 | +You may need to change the encoding if the data stored by your program is larger than 128 bytes. Here is the result of the above query. |
| 110 | + |
| 111 | +```bash |
| 112 | +{ |
| 113 | + "jsonrpc":"2.0", |
| 114 | + "result": { |
| 115 | + "context": { |
| 116 | + "slot":128841900 |
| 117 | + }, |
| 118 | + "value": { |
| 119 | + "data": ["BASE_58_STRING...","base58"], |
| 120 | + "executable":false, |
| 121 | + "lamports":49054080, |
| 122 | + "owner":"cjg3oHmg9uuPsP8D6g29NWvhySJkdYdAo9D25PRbKXJ", |
| 123 | + "rentEpoch":298 |
| 124 | + } |
| 125 | + }, |
| 126 | + "id":1 |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +## Via Solana-CLI |
| 131 | + |
| 132 | +Using [solana-cli](https://docs.solana.com/cli/install-solana-cli-tools) produces similar results to cURL. Run the following command to get information about a program account. |
| 133 | + |
| 134 | +```bash |
| 135 | +solana account [ACCOUNT_ADDRESS] |
| 136 | +``` |
| 137 | + |
| 138 | +This command will dump information about the given account. |
| 139 | + |
| 140 | +```bash |
| 141 | +Public Key: 2oyA8ZLwuWeAR5ANyDsiEGueUyDC8jFGFLSixSzT9KtV |
| 142 | +Balance: 0.04905408 SOL |
| 143 | +Owner: cjg3oHmg9uuPsP8D6g29NWvhySJkdYdAo9D25PRbKXJ |
| 144 | +Executable: false |
| 145 | +Rent Epoch: 298 |
| 146 | +Length: 6920 (0x1b08) bytes |
| 147 | +0000: d8 92 6b 5e 68 4b b6 b1 01 f9 00 00 00 00 00 00 ..k^hK.......... |
| 148 | +0010: a7 7a 9a 54 2d bb 05 64 37 03 f0 e4 90 be e4 d1 .z.T-..d7....... |
| 149 | +0020: bf 25 69 0f f1 2a 5d 82 52 57 16 71 f7 8a e3 40 .%i..*].RW.q...@ |
| 150 | +. |
| 151 | +. |
| 152 | +. |
| 153 | +``` |
0 commit comments