Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        

# SuperPotato-Raffle-program
This is the raffle program by using $SOL to buy tickets

๐Ÿ“ž Cแดษดแด›แด€แด„แด› แดแด‡ Oษด สœแด‡ส€แด‡: ๐Ÿ‘†๐Ÿป



Email

Twitter
Discord
Telegram

## 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


Super potato

## ๐Ÿ“– 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`