InfiniRewards
Reference

InfiniRewardsCollectible

Reference documentation for the InfiniRewardsCollectible contract

InfiniRewardsCollectible

An ERC1155-based contract for managing collectible tokens within the InfiniRewards ecosystem.

Storage Variables

NameTypeDescription
nameByteArrayName of the collectible token collection
metadataByteArrayBase metadata URI for the collectible tokens
points_contractContractAddressAddress of the associated points contract
token_idsVec<u256>List of all token IDs in the collection
token_pricesMap<u256, u256>Maps token IDs to their prices in points
token_expiriesMap<u256, u64>Maps token IDs to their expiry timestamps
token_metadatasMap<u256, ByteArray>Maps token IDs to their specific metadata URIs
token_suppliesMap<u256, u256>Maps token IDs to their current total supply

Events

EventParametersDescription
ERC1155EventInheritedStandard ERC1155 events (Transfer, ApprovalForAll)
TokenCreatedtoken_id: u256, price: u256, supply: u256Emitted when a new token type is created
TokenPurchasedbuyer: ContractAddress, token_id: u256, amount: u256Emitted when a token is purchased with points

Key Methods

Constructor

fn constructor(
    ref self: ContractState,
    owner: ContractAddress,
    name: ByteArray,
    metadata: ByteArray
)

Initializes a new collectible token contract.

ParameterTypeDescription
ownerContractAddressThe owner of the contract, typically a merchant
nameByteArrayName of the collectible token collection
metadataByteArrayBase metadata URI for the collectible tokens

Create Token

fn create_token(
    ref self: ContractState,
    token_id: u256,
    supply: u256,
    price: u256,
    expiry: u64,
    metadata: ByteArray
) -> u256

Creates a new token type in the collection.

ParameterTypeDescription
token_idu256Unique identifier for the new token
supplyu256Maximum supply of this token
priceu256Price in points to purchase this token
expiryu64Timestamp when this token expires (0 for no expiry)
metadataByteArrayToken-specific metadata URI

Returns: The ID of the created token

Purchase Token

fn purchase_token(
    ref self: ContractState,
    token_id: u256,
    amount: u256
)

Allows a user to purchase a token with points.

ParameterTypeDescription
token_idu256ID of the token to purchase
amountu256Number of tokens to purchase

Mint

fn mint(
    ref self: ContractState,
    account: ContractAddress,
    token_id: u256,
    value: u256,
    data: Span<felt252>
)

Mints new tokens to a specified account (owner only).

ParameterTypeDescription
accountContractAddressRecipient of the tokens
token_idu256ID of the token to mint
valueu256Number of tokens to mint
dataSpan<felt252>Additional data to pass to the receiver

Burn

fn burn(
    ref self: ContractState,
    account: ContractAddress,
    token_id: u256,
    value: u256
)

Burns tokens from the specified account.

ParameterTypeDescription
accountContractAddressAccount to burn tokens from
token_idu256ID of the token to burn
valueu256Number of tokens to burn

Set Token Price

fn set_token_price(
    ref self: ContractState,
    token_id: u256,
    price: u256
)

Sets the price of a token (owner only).

ParameterTypeDescription
token_idu256ID of the token to update
priceu256New price in points

On this page