A simple heads or tails (cross and pile) on Solana

Overview

cross-pile (Coin flip)

A heads or tails (cross and pile) on Solana. It's meant to serve as an example of how to use solrand, a randomness Oracle: https://github.com/evanmarshall/solrand

Installation & Usage

  1. Clone this repository
  2. Ensure that Anchor and all of its dependencies are installed: https://project-serum.github.io/anchor/getting-started/introduction.html
  3. yarn install
  4. Rename the Anchor.example.toml to Anchor.toml and update the wallet = to your solana key.
  5. Start the solana-test-validator in a different tab
  6. In a separate folder (In order to run a mock Oracle):
    1. Install: https://github.com/evanmarshall/solrand
    2. Run anchor build && anchor deploy
  7. Run anchor build && anchor deploy
  8. Use the Program Id found from the deploy. Replace 6urrPCjcrQ1xaxbAJGMTtvZfA9wbMqQbEArKnVUHhYTs with your new Program Id.
  9. Run the tests: anchor test --skip-local-validator

Troubleshooting

Problems with Anchor

  • The most common problem with anchor is using the right version of node. I recommend install Node through NVM and using Node v16.11.1.

License

We use the GNU Affero General Public License v3.0 or later license to ensure the community will always have access to all original and derivations of this program. Full text here: https://spdx.org/licenses/AGPL-3.0-or-later.html

Comments
  • Dependency missing

    Dependency missing

    Hi, in your dependencies you have listed "@demox_labs/solrand": "^0.0.3" twice, but when installing with npm/yarn in the root I get

    npm ERR! 404  '@demox_labs/solrand@https://registry.npmjs.org/@demox_labs/solrand/-/solrand-0.0.3.tgz' is not in this registry.
    
    opened by robbestad 2
  • Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: instruction expected an executable account

    Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: instruction expected an executable account

    Hi,

    i am trying to run cross-pile locally on localnet and keep receiving the following message when i go to run anchor test

    Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: instruction expected an executable account

    Any help would be appreciated! thanks

    opened by ebox86 1
  • Failed to

    Failed to "anchor build" for new anchor versions

    It seems that the repo is not up to date to latest anchor versions (0.24.2 or 0.25.0) but was written with anchor 0.18.2. Is it planned to be updated and is Solrand Oracle working with the new versions? Thanks.

    opened by kaouki99 0
  •   3) cross-pile Approve a flip: Error: Invalid arguments: requester not provided.  while ruinning test cases

    3) cross-pile Approve a flip: Error: Invalid arguments: requester not provided. while ruinning test cases

    User Pubkey: AfyttQHyJuLNBNDYWkvjNpXSQ19tvq5HQLZn8rWHa3h3 User 2 Pubkey: aomQraMKcXHSZW863r9edQ5NYUboGq1LpHLX2xQ8DLL Server responded with 429 Too Many Requests. Retrying after 500ms delay... Server responded with 429 Too Many Requests. Retrying after 1000ms delay... Server responded with 429 Too Many Requests. Retrying after 2000ms delay... Server responded with 429 Too Many Requests. Retrying after 4000ms delay... 1) Set up tests Coin account: AgQhY4gFzSTsL8DrWEBgh1QyUsch7s1STYv5tVSfoV6W 2) Create a coin! 3) Approve a flip Translating error TypeError: Cannot read properties of undefined (reading 'toString') at forEach (/home/aravind/Jhusten-cross-pile/node_modules/@solana/web3.js/src/transaction.ts:402:47) at Array.forEach () at Transaction.compileMessage (/home/aravind/Jhusten-cross-pile/node_modules/@solana/web3.js/src/transaction.ts:401:18) at Transaction._compile (/home/aravind/Jhusten-cross-pile/node_modules/@solana/web3.js/src/transaction.ts:523:26) at Transaction.partialSign (/home/aravind/Jhusten-cross-pile/node_modules/@solana/web3.js/src/transaction.ts:654:26) at NodeWallet.signTransaction (/home/aravind/Jhusten-cross-pile/node_modules/@project-serum/anchor/src/provider.ts:246:8) at Provider.send (/home/aravind/Jhusten-cross-pile/node_modules/@project-serum/anchor/src/provider.ts:105:23) at processTicksAndRejections (node:internal/process/task_queues:95:5) at Object.rpc [as publishRandom] (/home/aravind/Jhusten-cross-pile/node_modules/@project-serum/anchor/src/program/namespace/rpc.ts:24:23) at MockOracleSession.publishRandom (/home/aravind/Jhusten-cross-pile/node_modules/@demox-labs/solrand/app/sessions.js:123:9) 4) Oracle responds to request 5) Reveal the result

    0 passing (18s) 5 failing

    1. cross-pile Set up tests: Error: 429 Too Many Requests: {"jsonrpc":"2.0","error":{"code": 429, "message":"Too many requests for a specific RPC call, contact your app developer or [email protected]."}, "id": "c1d71c29-d02c-49a4-87a2-e0260f18b979" }

      at ClientBrowser.callServer (node_modules/@solana/web3.js/src/connection.ts:1155:18) at processTicksAndRejections (node:internal/process/task_queues:95:5)

    2. cross-pile Create a coin!: TypeError: Cannot read properties of undefined (reading 'toString') at /home/aravind/Jhusten-cross-pile/tests/cross-pile.ts:106:49 at Generator.next () at fulfilled (tests/cross-pile.ts:28:58)

    3. cross-pile Approve a flip: Error: Invalid arguments: requester not provided. at /home/aravind/Jhusten-cross-pile/node_modules/@project-serum/anchor/src/program/common.ts:50:15 at Array.forEach () at validateAccounts (node_modules/@project-serum/anchor/src/program/common.ts:45:14) at ix (node_modules/@project-serum/anchor/src/program/namespace/instruction.ts:43:23) at txFn (node_modules/@project-serum/anchor/src/program/namespace/transaction.ts:20:14) at Object.rpc [as approveFlip] (node_modules/@project-serum/anchor/src/program/namespace/rpc.ts:21:18) at /home/aravind/Jhusten-cross-pile/tests/cross-pile.ts:144:32 at Generator.next () at /home/aravind/Jhusten-cross-pile/tests/cross-pile.ts:31:71 at new Promise () at __awaiter (tests/cross-pile.ts:27:12) at Context. (tests/cross-pile.ts:142:37) at processImmediate (node:internal/timers:471:21)

    4. cross-pile Oracle responds to request: TypeError: Cannot read properties of undefined (reading 'toString') at forEach (node_modules/@solana/web3.js/src/transaction.ts:402:47) at Array.forEach () at Transaction.compileMessage (node_modules/@solana/web3.js/src/transaction.ts:401:18) at Transaction._compile (node_modules/@solana/web3.js/src/transaction.ts:523:26) at Transaction.partialSign (node_modules/@solana/web3.js/src/transaction.ts:654:26) at NodeWallet.signTransaction (node_modules/@project-serum/anchor/src/provider.ts:246:8) at Provider.send (node_modules/@project-serum/anchor/src/provider.ts:105:23) at processTicksAndRejections (node:internal/process/task_queues:95:5) at Object.rpc [as publishRandom] (node_modules/@project-serum/anchor/src/program/namespace/rpc.ts:24:23) at MockOracleSession.publishRandom (node_modules/@demox-labs/solrand/app/sessions.js:123:9)

    5. cross-pile Reveal the result: Error: Invalid arguments: requester not provided. at /home/aravind/Jhusten-cross-pile/node_modules/@project-serum/anchor/src/program/common.ts:50:15 at Array.forEach () at validateAccounts (node_modules/@project-serum/anchor/src/program/common.ts:45:14) at ix (node_modules/@project-serum/anchor/src/program/namespace/instruction.ts:43:23) at txFn (node_modules/@project-serum/anchor/src/program/namespace/transaction.ts:20:14) at Object.rpc [as revealCoin] (node_modules/@project-serum/anchor/src/program/namespace/rpc.ts:21:18) at /home/aravind/Jhusten-cross-pile/tests/cross-pile.ts:184:32 at Generator.next () at /home/aravind/Jhusten-cross-pile/tests/cross-pile.ts:31:71 at new Promise () at __awaiter (tests/cross-pile.ts:27:12) at Context. (tests/cross-pile.ts:182:40) at processImmediate (node:internal/timers:471:21)

    error Command failed with exit code 5.

    PLEASE HELP!!!

    opened by anilaravindv 0
  • Instruction references an unknown account GxJJd3q28eUd7kpPCbNXGeixqHmBYJ2owqUYqse3ZrGS

    Instruction references an unknown account GxJJd3q28eUd7kpPCbNXGeixqHmBYJ2owqUYqse3ZrGS

    Hi Evan, I'm new to Solana. I'm having trouble running cross-pile locally. I suspect it's because there's something wrong with the dependency setup I have because I made to to replace every instance of "GxJJd3q28eUd7kpPCbNXGeixqHmBYJ2owqUYqse3ZrGS" with the account obtained from anchor deploy of my own solrand installation in both repos.

    opened by acetonitrile 0
Owner
Evan Marshall
Evan Marshall
Write Anchor-compatible Solana programs in Python

seahorse: Write Solana programs in Python The ease of Python with the safety of Rust. Seahorse lets you write Solana programs in Python. It is a commu

✨ amelia chen ✨ 214 Dec 28, 2022
Solana SVM, modularized.

The Case for a Modular SVM An effort is underway at Anza to extract most of the transaction processing pipeline out of the validator and into what wil

Joe C 42 Jul 26, 2024
The example anchor implementation for solana-swap

anchor-liquidity-pool This is the example anchor implementation for solana-swap. The curve is always ConstantProduct in this implementation. The fee r

Something-Something 2 Aug 17, 2024
Cross-platform GUI for youtube-dl made with Iced

youtube-dl-gui Cross-platform GUI for youtube-dl made with Iced. Installation Before you install this crate, make sure you have youtube-dl and FFmpeg

Hristo Gochev 4 Feb 27, 2023
`memory_pages` is a small library provinig a cross-platform API to request pages from kernel with certain premisions

memory_pages: High level API for low level memory management While using low-level memory management in a project can provide substantial benefits, it

null 14 Mar 30, 2023
Fast and simple datetime, date, time and duration parsing for rust.

speedate Fast and simple datetime, date, time and duration parsing for rust. speedate is a lax† RFC 3339 date and time parser, in other words, it pars

Samuel Colvin 43 Nov 25, 2022
Simple and performant hot-reloading for Rust

reloady Simple, performant hot-reloading for Rust. Requires Rust nightly and only works on Linux for now. installing CLI To install the CLI helper car

Anirudh Balaji 24 Aug 5, 2022
Mote is a systems-programming language designed to be practical, performant, and simple.

Mote NOTE: this following lists the goals for what Mote is supposed to be. It does not promise that any of the features here will be accomplished or a

The Mote Programming Language 14 Jul 28, 2021
A simple and convenient way to bundle owned data with a borrowing type.

A simple and convenient way to bundle owned data with a borrowing type. The Problem One of the main selling points of Rust is its borrow checker, whic

Dmitry Zamkov 20 Dec 21, 2022
A Simple Audio Control and Notifications Daemon

SACAND This is sacand, a Simple Audio Control and Notifications Daemon As it name oaths to imply, this is intended to be a simple audio control daemon

null 2 Jan 24, 2022
A simple programming language for something between C and Rust.

inuc inuc is a systems programming language that is something between C and Rust. Features : [] Strong , static typing (type inference not a priority

Sagnik Chatterjee 1 Feb 7, 2022
Rust language from simple to deep, and then to strengthen learning in multiple module

Rust Library This project is used to learn rust language from simple to deep, and then to strengthen learning in multiple module. It is used to help n

Summer 1 Sep 19, 2022
Simple string matching with questionmark- and star-wildcard operator

wildmatch Match strings against a simple wildcard pattern. Tests a wildcard pattern p against an input string s. Returns true only when p matches the

Armin Becher 38 Dec 18, 2022
A simple thread schedule and priority library for rust

thread-priority A simple library to control thread schedule policies and thread priority. If your operating system isn't yet supported, please, create

Victor Polevoy 62 Dec 5, 2022
TypeRust - simple Rust playground where you can build or run your Rust code and share it with others

Rust playground Welcome to TypeRust! This is a simple Rust playground where you can build or run your Rust code and share it with others. There are a

Kirill Vasiltsov 28 Dec 12, 2022
A simple library to get all pairs from any Dex and sync reserves.

pair_sync A simple library to get all pairs from any supported Dex and sync reserves. Crates.io Documentation in progress Filename: examples/sync-pair

null 116 Dec 30, 2022
A query-building & utility crate for SurrealDB and its SQL querying language that aims to be simple

Surreal simple querybuilder A simple query-builder for the Surreal Query Language, for SurrealDB. Aims at being simple to use and not too verbose firs

Thibault H 11 Dec 30, 2022
Simple, safe way to store and distribute tensors

safetensors Safetensors This repository implements a new simple format for storing tensors safely (as opposed to pickle) and that is still fast (zero-

Hugging Face 402 Dec 29, 2022
Simple and fast proxy checker that include protocol validation;

Open Proxies ⭐️ Leave me a start please ⭐️ it will motivate me to continue maintaining and adding futures About | Technologies | Requirements | Starti

kmoz000 3 Nov 29, 2022