-
Notifications
You must be signed in to change notification settings - Fork 316
/
erc1155.cairo
63 lines (57 loc) · 1.93 KB
/
erc1155.cairo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts for Cairo v0.11.0 (presets/erc1155.cairo)
/// # ERC1155 Preset
///
/// The ERC1155 contract offers a batch-mint mechanism that
/// can only be executed once upon contract construction.
///
/// For more complex or custom contracts, use Wizard for Cairo
/// https://wizard.openzeppelin.com/cairo
#[starknet::contract]
mod ERC1155 {
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin::token::erc1155::ERC1155Component;
use starknet::ContractAddress;
component!(path: ERC1155Component, storage: erc1155, event: ERC1155Event);
component!(path: SRC5Component, storage: src5, event: SRC5Event);
// ERC1155 Mixin
#[abi(embed_v0)]
impl ERC1155MixinImpl = ERC1155Component::ERC1155MixinImpl<ContractState>;
impl ERC1155InternalImpl = ERC1155Component::InternalImpl<ContractState>;
#[storage]
struct Storage {
#[substorage(v0)]
erc1155: ERC1155Component::Storage,
#[substorage(v0)]
src5: SRC5Component::Storage
}
#[event]
#[derive(Drop, starknet::Event)]
enum Event {
#[flat]
ERC1155Event: ERC1155Component::Event,
#[flat]
SRC5Event: SRC5Component::Event
}
/// Sets the `base_uri` for all tokens.
/// Mints the `values` for `token_ids` tokens to `recipient`.
///
/// Requirements:
///
/// - `to` is either an account contract (supporting ISRC6) or
/// supports the `IERC1155Receiver` interface.
/// - `token_ids` and `values` must have the same length.
#[constructor]
fn constructor(
ref self: ContractState,
base_uri: ByteArray,
recipient: ContractAddress,
token_ids: Span<u256>,
values: Span<u256>
) {
self.erc1155.initializer(base_uri);
self
.erc1155
.batch_mint_with_acceptance_check(recipient, token_ids, values, array![].span());
}
}