Skip to content

Commit

Permalink
sh/update-program-id.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
s-damian committed Aug 25, 2024
1 parent 0a9a28a commit 0133c78
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 4 deletions.
97 changes: 97 additions & 0 deletions README-tech.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,100 @@ npm run lint:fix

## Localnet to Devnet

### Switch to Devnet

Change your Solana CLI to use the Devnet:

```bash
solana config set --url https://api.devnet.solana.com
```

### Fund Your Wallet

Airdrop SOL to your Devnet wallet:

```bash
solana airdrop <amout>
```

### Update Anchor Configuration

Modify your `Anchor.toml` file:

Replace:
```bash
[provider]
cluster = "localnet"
```
By:
```bash
[provider]
cluster = "devnet"
```

Add :
```bash
[programs.devnet]
nft_ticketing = "<your-program-id>"
```

### Environment Variables

In `/app/front/.env` (Next.js App):
Replace:
```bash
NEXT_PUBLIC_REACT_APP_SOLANA_NETWORK="localnet"
```
By:
```bash
NEXT_PUBLIC_REACT_APP_SOLANA_NETWORK="devnet"
```

### Phantom Wallet

In your Phantom settings, switch **Solana Localnet** to **Solana Devnet**.

### Build and Deploy the Anchor Program

Build:

```bash
anchor build
```

Deploy on the Devnet:

```bash
anchor deploy --provider.cluster devnet
```
### Update Program ID

Automatically update the Program ID in the necessary files:

```bash
npm run update-program-id
```

// anchor build && anchor deploy ???

### IDL Setup

Copy the IDL (Interface Definition Language) file into the Next.js App:

```bash
npm run copy-idl
```

### Run Front-End (Next.js App)

Go to the Next.js App Directory:

```bash
cd /<your-path>/anchor-nft-ticketing/app/front
```

Start the development server:

```bash
npm run dev
```
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ Start the Solana local validator (solana-test-validator) with Metaplex:
npm run ledger
```

after starting the Solana local validator, you will probably need to do an airdrop(s):
### Fund Your Wallet

After starting the Solana local validator, you will probably need to airdrop SOL to your Localnet wallet:

```bash
solana airdrop <amout> <your-address>
solana airdrop <amout>
```

### Build and Deploy the Anchor Program
Expand All @@ -142,7 +144,7 @@ anchor deploy

> **PS**: `anchor deploy` will create your `target/idl/nft_ticketing.json` file.
### Change Program ID
### Update Program ID

Automatically update the Program ID in the necessary files:

Expand Down
2 changes: 1 addition & 1 deletion sh/update-program-id.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ for PROGRAM in "${PROGRAMS[@]}"; do
PROGRAM_PATH=${PROGRAM//_/-}

# Mise à jour de Anchor.toml pour chaque programme
sed -i "s/${PROGRAM} = \"[^\"]*\"/${PROGRAM} = \"$PROGRAM_ID\"/" Anchor.toml
sed -i "/^\[programs\./,/^\[/ s/^$PROGRAM = \"[^\"]*\"/$PROGRAM = \"$PROGRAM_ID\"/" Anchor.toml

# Mise à jour de lib.rs pour chaque programme
sed -i "s/declare_id!(\"[^\"]*\")/declare_id!(\"$PROGRAM_ID\")/" programs/${PROGRAM_PATH}/src/lib.rs
Expand Down

0 comments on commit 0133c78

Please sign in to comment.