Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
cartridge-gg avatar

Cartridge Vrng

  • 2 installs
  • 4 repo stars
  • Updated August 1, 2026
  • cartridge-gg/docs

Integrates Cartridge verifiable RNG into onchain Starknet games via the Cairo interface, multicall ordering, and Controller policies for atomic verifiable randomness.

About

Integrates Cartridge's verifiable random number generator (vRNG) into onchain Starknet games, with atomic randomness generated and verified in a single transaction. A developer uses it to add cheap verifiable randomness to game contracts.

  • Integrates Cartridge's verifiable RNG generated and verified within a single transaction
  • Shows Cairo interface, multicall ordering, and Controller policy setup

Cartridge Vrng by the numbers

  • 2 all-time installs (skills.sh)
  • Ranked #409 of 480 Web3 & Blockchain skills by installs in the Skillselion catalog
  • Data as of Aug 1, 2026 (Skillselion catalog sync)
npx skills add https://github.com/cartridge-gg/docs --skill cartridge-vrng

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs2
repo stars4
Last updatedAugust 1, 2026
Repositorycartridge-gg/docs

What it does

Integrates Cartridge verifiable RNG into onchain Starknet games via the Cairo interface, multicall ordering, and Controller policies for atomic verifiable randomness.

Files

SKILL.mdMarkdownGitHub ↗

Cartridge vRNG

Cartridge's Verifiable Random Number Generator provides cheap, atomic, verifiable randomness for onchain games. Randomness is generated and verified within a single transaction.

Contract Addresses

NetworkAddress
Mainnet0x051fea4450da9d6aee758bdeba88b2f665bcbf549d2c61421aa724e9ac0ced8f
Sepolia0x051fea4450da9d6aee758bdeba88b2f665bcbf549d2c61421aa724e9ac0ced8f

Cairo Interface

#[starknet::interface]
trait IVrfProvider<TContractState> {
    fn request_random(self: @TContractState, caller: ContractAddress, source: Source);
    fn consume_random(ref self: TContractState, source: Source) -> felt252;
}

#[derive(Drop, Copy, Clone, Serde)]
pub enum Source {
    Nonce: ContractAddress,
    Salt: felt252,
}

Source Types

  • Source::Nonce(ContractAddress): Uses the address's internal nonce.

Each request generates a different seed.

  • Source::Salt(felt252): Uses a provided salt.

Same salt = same random value.

Usage in Contracts

const VRF_PROVIDER_ADDRESS: starknet::ContractAddress =
    starknet::contract_address_const::<0x051fea4450da9d6aee758bdeba88b2f665bcbf549d2c61421aa724e9ac0ced8f>();

fn roll_dice(ref self: ContractState) {
    let vrf_provider = IVrfProviderDispatcher { contract_address: VRF_PROVIDER_ADDRESS };
    let player_id = get_caller_address();
    let random_value = vrf_provider.consume_random(Source::Nonce(player_id));
    // Use random_value in game logic
}

Executing vRNG Transactions

request_random must be the first call in the multicall. The Cartridge Paymaster wraps the multicall with submit_random and assert_consumed.

const call = await account.execute([
  // First: request_random
  {
    contractAddress: VRF_PROVIDER_ADDRESS,
    entrypoint: 'request_random',
    calldata: CallData.compile({
      caller: GAME_CONTRACT,
      // Source::Nonce(address)
      source: { type: 0, address: account.address },
      // Or Source::Salt(felt252)
      // source: { type: 1, salt: 0x123 },
    }),
  },
  // Then: your game call
  {
    contractAddress: GAME_CONTRACT,
    entrypoint: 'roll_dice',
    // ...
  },
]);

The source in request_random must match the source in consume_random.

Controller Policy

Add the vRNG contract to your Controller policies:

const policies: Policy[] = [
  // ... your existing policies ...
  {
    target: VRF_PROVIDER_ADDRESS,
    method: "request_random",
    description: "Allows requesting random numbers from the VRF provider",
  },
];

Security

Phase 0 assumes the Provider has not revealed the private key and does not collude with players. Future plans include moving the Provider to a Trusted Execution Environment (TEE).

Related skills

Web3 & Blockchainintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.