This is Send rc V1
- Player registration system
- Step counting mechanism
- Coin collection system
- Ephemeral rollups integration for faster transactions
- Delegated account management
- Rust and Cargo
- Solana Tool Suite
- Node.js and Yarn
- Anchor Framework
-
Clone the repository:
-
Install dependencies:
yarn install- Build the program:
anchor build-
Create a
keysdirectory and add the following key files:admin.json: Admin wallet keypairusermain.json: User wallet keypair (for testing)
-
Update the
Anchor.tomlfile with your desired cluster and wallet configuration.
- Player Account
owner: Player's wallet public keystep_count: Number of steps takencoins_count: Number of coins collected
-
Register Player
- Initializes a new player account
- Creates PDA for player data storage
-
Increment Step
- Increases player's step count
- Requires player authorization
- Can be executed on main chain or ephemeral rollup
-
Collect Coins
- Increases player's coin count
- Requires player authorization
- Can be executed on main chain or ephemeral rollup
-
Delegate
- Delegates player account to ephemeral rollup
- Enables faster and cheaper transactions
-
Undelegate
- Returns player account control from ephemeral rollup to main chain
- Commits state changes back to main chain
- Start a local Solana validator:
solana-test-validator- Run tests:
anchor test- Build the program:
anchor build- Deploy to desired cluster:
anchor deployExample of registering a player:
const tx = await program.methods
.registerPlayer()
.accounts({
user: userWallet.publicKey,
player: playerPda,
systemProgram: web3.SystemProgram.programId,
})
.signers([userWallet])
.rpc();Example of incrementing steps:
const tx = await program.methods
.incrementStep()
.accounts({
user: userWallet.publicKey,
admin: adminWallet.publicKey,
})
.signers([userWallet, adminWallet])
.rpc();The contract supports ephemeral rollups through the @magicblock-labs/ephemeral-rollups-sdk. This enables:
- Faster transaction processing
- Reduced transaction costs
- Improved scalability
To use ephemeral rollups:
- Delegate account:
await program.methods
.delegate()
.accounts({
user: userWallet.publicKey,
})
.signers([userWallet])
.rpc();- Perform actions on rollup:
await ephemeralProgram.methods
.incrementStep()
.accounts({
user: userWallet.publicKey,
admin: adminWallet.publicKey,
})
.signers([userWallet, adminWallet])
.rpc();- Undelegate to commit changes:
await ephemeralProgram.methods
.undelegate()
.accounts({
user: userWallet.publicKey,
})
.signers([userWallet, adminWallet])
.rpc();- Admin key is required for certain operations
- Player operations are protected by owner checks
- Delegation operations are protected by proper authorization
- State changes are atomic and protected against reentrancy
ISC