# PitchTalk Solana Contract This is a PitchTalk contract for Solana blockchain. ## Program ### Dependencies To install everything you need to work with this project, you'll need to install dependencies as described in [Anchor](https://www.anchor-lang.com/docs/installation) documentation. ### Build contract The source code of pitchtalk program is in ./programs/pitchtalk-solana. To build the **pitchtalk-solana** program, you need to execute this command: ```sh anchor build ``` You'll get the following output: - program binaries at ./target/deploy/pitchtalk_solana.so - IDL file at ./target/idl/pitchtalk_solana.json - Typescript typings at ./target/types/pitchtalk_solana.ts ### Deploy To deploy the program, run this command: ```sh anchor deploy \ --provider.cluster $ANCHOR_PROVIDER_URL \ --program-keypair $KEYPAIR \ --program-name pitchtalk_solana \ --provider.wallet $ANCHOR_WALLET ``` ### Run scripts Before start setup env file with corresponding variables: - ANCHOR_PROVIDER_URL - url of solana rpc - ANCHOR_WALLET - path to wallet to sign transactions - PITCHTALK_PROGRAM_ID - public key of PitchTalk program - KEYPAIR - PitchTalk program account keypair Available scripts: 1. To initialize contract state run: ```sh npm run initialize-state ``` 2. To update contract state run: ```sh npm run update-state ``` 3. To create admin run: ```sh npm run create-admin ``` 4. To update admin run: ```sh npm run update-admin ``` 5. To remove admin run: ```sh npm run remove-admin ``` 6. To add whitelist token run: ```sh npm run add-whitelist-token ``` ### Run tests To test the **pitchtalk-solana** program, you need to execute this command: ```sh ./tests/test_script.sh ``` This command starts a local validator, sets up the program on chain and runs a suite of Jest tests against it. --- ## Typescript client The Javascript/Typescript client for this program. It's published by this command: ```sh npm publish ``` Please view the test suite (./tests/\*\*.spec.ts) to see how can this client be used in NodeJS context. ### Basic usage example ```typescript import { Connection, PublicKey } from "@solana/web3.js"; import { Provider } from "@coral-xyz/anchor"; import { PitchTalkProgram } from "@pitchtalk/pitchtalk-solana-cli"; // Setup web3 Connection const connection = new Connection("https://api.mainnet-beta.solana.com"); // Use Phantom wallet provider const wallet = window.solana; // Setup Anchor provider const provider = new Provider(connection, wallet as any); // pitchtalk program ID is a well-known public key const program = new PitchTalkProgram( new web3.PublicKey(PITCH_TALK_ID), provider ); ```