Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ShareXMomentumBadge

Git Source

Inherits: ERC721Enumerable, AccessControl, IShareXMomentumBadge

Title: ShareX Momentum Badge

ERC721 badge contract to celebrate the 5th Anniversary of BNB Chain

This Badge is awarded to participants who joined ShareX activities during official #BNBDay celebrations

State Variables

MINTER_ROLE

Role for minting badges

bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE")

BURNER_ROLE

Role for burning badges

bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE")

_TOKEN_URI

Fixed metadata URI for all badges

string private constant _TOKEN_URI = "https://rwa.sharex.network/metadata/momentum-badge.json"

_currentTokenId

Current token ID counter

uint256 private _currentTokenId

Functions

constructor

Initialize the ShareX Momentum Badge contract

constructor(address admin) ERC721("ShareX Momentum Badge", "SMB");

Parameters

NameTypeDescription
adminaddressAddress to be granted admin role

mint

Mint a badge to a recipient

function mint(address to) external override onlyRole(MINTER_ROLE);

Parameters

NameTypeDescription
toaddressRecipient address

batchMint

Mint badges to multiple recipients

function batchMint(address[] calldata recipients) external override onlyRole(MINTER_ROLE);

Parameters

NameTypeDescription
recipientsaddress[]Array of recipient addresses

burn

Burn a badge

function burn(uint256 tokenId) external override;

Parameters

NameTypeDescription
tokenIduint256Token ID to burn

batchBurn

Burn multiple badges

function batchBurn(uint256[] calldata tokenIds) external override;

Parameters

NameTypeDescription
tokenIdsuint256[]Array of token IDs to burn

tokenURI

Get the metadata URI for a token

function tokenURI(uint256 tokenId)
    public
    view
    virtual
    override(ERC721, IShareXMomentumBadge)
    returns (string memory);

Parameters

NameTypeDescription
tokenIduint256Token ID

Returns

NameTypeDescription
<none>stringThe metadata URI

totalSupply

Get the total supply of badges

function totalSupply()
    public
    view
    override(ERC721Enumerable, IShareXMomentumBadge)
    returns (uint256);

Returns

NameTypeDescription
<none>uint256The total number of badges minted

supportsInterface

Check if the contract supports an interface

function supportsInterface(bytes4 interfaceId)
    public
    view
    override(ERC721Enumerable, AccessControl, IERC165)
    returns (bool);

Parameters

NameTypeDescription
interfaceIdbytes4Interface identifier

Returns

NameTypeDescription
<none>boolTrue if the interface is supported

_exists

Internal function to check if a token exists

function _exists(uint256 tokenId) internal view returns (bool);

Parameters

NameTypeDescription
tokenIduint256Token ID to check

Returns

NameTypeDescription
<none>boolTrue if the token exists