Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vvizardev/super-potato-raffle
super-potato-raffle : This is the raffle program by using $SOL to buy tickets
https://github.com/vvizardev/super-potato-raffle
frontend raffle smart-contract solana tickets
Last synced: 12 days ago
JSON representation
super-potato-raffle : This is the raffle program by using $SOL to buy tickets
- Host: GitHub
- URL: https://github.com/vvizardev/super-potato-raffle
- Owner: vvizardev
- Created: 2024-07-01T17:50:32.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-10-05T19:13:03.000Z (4 months ago)
- Last Synced: 2025-01-25T17:19:04.464Z (12 days ago)
- Topics: frontend, raffle, smart-contract, solana, tickets
- Language: TypeScript
- Homepage:
- Size: 597 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SuperPotato-Raffle-program
This is the raffle program by using $SOL to buy tickets๐ Cแดษดแดแดแดแด แดแด Oษด สแดสแด: ๐๐ป
## Install Dependencies
- Install `node` and `yarn`
- Install `ts-node` as global command
- Confirm the solana wallet preparation: `/home/---/.config/solana/id.json` in test case## Usage
- Main script source for all functionality is here: `/cli/script.ts`
- Program account types are declared here: `/cli/types.ts`
- Idl to make the JS binding easy is here: `/cli/raffle.json`Able to test the script functions working in this way.
- Change commands properly in the main functions of the `script.ts` file to call the other functions
- Confirm the `ANCHOR_WALLET` environment variable of the `ts-node` script in `package.json`
- Run `yarn ts-node`# Features
## How to deploy this program?
First of all, you have to git clone in your PC.
In the folder `raffle`, in the terminal
1. `yarn`
2. `anchor build`
In the last sentence you can see:
```
To deploy this program:
$ solana program deploy /home/.../raffle/target/deploy/raffle.so
The program address will default to this keypair (override with --program-id):
/home/.../raffle/target/deploy/raffle-keypair.json
```
3. `solana-keygen pubkey /home/.../raffle/target/deploy/raffle-keypair.json`
4. You can get the pubkey of the program ID : ex."7M...KWJ"
5. Please add this pubkey to the lib.rs
`line 20: declare_id!("7M...KWJ");`
6. Please add this pubkey to the Achor.toml
`line 4: raffle = "7M...KWJ"`
7. Please add this pubkey to the scripts.ts
`line 21: const PROGRAM_ID = "7M...KWJ";`
8. `anchor build` again
9. `solana program deploy /home/.../raffle/target/deploy/raffle.so`
10. In the script.ts code, `line 54 decomment`
```js
await initProject();
```
11. `yarn ts-node`
12. If this error comes - `Error: Provider local is not available on browser.`, `export BRWOSER=`
13. `yarn ts-node`
Then, you can enjoy this program ๐ญ## How to use?
### - As a Smart Contract Owner
For the first time use, the Smart Contract Owner should `initialize` the Smart Contract for global account allocation.
```js
initProject()
```To add collections who will use this raffle site, Admin should call `addCollection` function.(In this collectionId is the verified creator of this collection NFTs)
```js
addCollection(
userAddress: PublicKey,
collectionId: PublicKey
)
```### - As the Creator of Raffle
The NFTs will be stored in the globalAuthority address.
When the admin creates a raffle, call the `createRaffle` function, the NFT will be sent to the PDA and the data of this raffle is stored on blockchain.
```js
createRaffle(
userAddress: PublicKey,
nft_mint: PublicKey,
ticketPriceSol: number,
endTimestamp: number,
max: number
)
```The creator can withdraw NFT from the PDA if nobody buys tickets and the time exceeds the endTime of raffle.
```js
withdrawNft(
userAddress: PublicKey,
nft_mint: PublicKey
)
```### - As the User of Raffle
When users buy tickets, call the `buyTicket` function, users will send $SOL to the raffle creator.
```js
buyTicket(
userAddress: PublicKey,
nft_mint: PublicKey,
amount: number
)
```To see the winner of the raffle, someone should call `revealWinnner` function. If then, in the `RafflePool` account, `winner` field will be charged with winner's address.
```js
revealWinner(
userAddress: PublicKey,
nft_mint: PublicKey
)
```### - As the Winner of Raffle
Winners can claim rewards by calling `claimReward` function.
```js
claimReward(
userAddress: PublicKey,
nft_mint: PublicKey
)
```# ๐ฅ๐ฅ๐ฅ Super Potato NFT Raffle | Solana | Next.js + Typescript
![]()
## ๐ Requirements
### ๐ถ User side
- Collection register
- Raffle create
They will have to pay about 0.4 SOL per NFT when creating a raffle.
- Buy tickets
- Withdraw NFT (after end time & and not sold any tickets)
- Reveal winner
- Claim reward
### ๐จโ๐ป Admin side
- User-registered Accept/Deny of collection
### Like FFF Raffle (famous fox federation)
[rafffle.famousfoxes.com](https://rafffle.famousfoxes.com/)## Mindfolk Landing Page
[www.mindfolk.art](https://www.mindfolk.art/)## ๐ Deployed
[superpotato-raffle.herokuapp.com/](https://superpotato-raffle.herokuapp.com/)## ๐ โป SET PROJECT ENVIRONMENT
### Firebase set
Replace firebase configuration values
`src/api/firebase.ts`
```tsx
const firebaseConfig = {
apiKey: "AIzaSyAI_r1Rs11kIsWJFiCVA4aGt58ffsZrclY",
authDomain: "mindfolk-raffle-afb92.firebaseapp.com",
projectId: "mindfolk-raffle-afb92",
storageBucket: "mindfolk-raffle-afb92.appspot.com",
messagingSenderId: "106626330620",
appId: "1:106626330620:web:c3343f7736902e58774c79",
measurementId: "G-NHD9LYKTVJ"
};
```
### Project config data
`src/config.tsx`
```tsx
export const NETWORK = "mainnet-beta"; //mainnet-beta | devnet
export const ADMINS = [
"7TBRMXkRbVpRWgLkrrTaqFJvXSMkMwnNKEZ4dbRh8Lnf",
"FePFmE1CbbTkiKg4K9A41dQcXfhPqLSJrEBcdXwBj3aa",
"A8rgsJecHutEamvb7e8p1a14LQH3vGRPr796CDaESMeu" // developer wallet address
]// deployed url
export const LIVE_URL = "https://superpotato-raffle.herokuapp.com/"
// treasury wallet address
export const TREASURY_WALLET = new PublicKey('BEQZXkjg1BzY5349FXGPgvsbySWw5R7zjEC4xQhzmQR5');
//smart contract program id
export const PROGRAM_ID = "Geb2fkVJMgNbjPwMkcjfR3n4AiN7DKqKwctFwfErkbn7";
// solana RPC url
export const RPC_URL = "https://a2-mind-prd-api.azurewebsites.net/rpc";```
## Install
```bash
npm run install
# or
yarn install
```
## Development```bash
npm run dev
# or
yarn dev
```## ๐ฅ Database
Google **Firebase**
- **collections**
When users send a request to register a Collection, it is stored in the database Collection calls **collections**.
Admin can **Accept** or **Deny** those collections.
All collections are also stored on the blockchain.
- **raffles**
When user create a raffle, it saved also database `raffles` document.
Raffle on db is updated, when those actions
`buy tickets`, `reveal winner`, `withdraw nft`, `claim reward`