Skip to content

Commit

Permalink
fixup: merge conflict -- basics::random
Browse files Browse the repository at this point in the history
  • Loading branch information
amnn committed Jul 12, 2024
1 parent 1626e60 commit 6dff639
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/move/basics/sources/random.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

/// This example demonstrates emitting a random u128 (e.g., for an offchain lottery)
module basics::random {
use sui::event;
use sui::random::Random;

public struct RandomU128Event has copy, drop {
value: u128,
}

entry fun new(r: &Random, ctx: &mut TxContext) {
let mut gen = r.new_generator(ctx);
let value = gen.generate_u128();
event::emit(RandomU128Event { value });
}
}

0 comments on commit 6dff639

Please sign in to comment.