Skip to main content

ASBT

Overview​

License: MIT​

abstract contract ASBT is ISBT, ERC165Upgradeable

The SBT module

An abstract lightweight implementation of a Soul Bound Token. Does not comply with ERC721 standard. Approve and transfer functionality has been removed as it is not needed in SBTs.

The contract is compatible with Metamask and Opensea.

Structs info​

ASBTStorage​

struct ASBTStorage {
string name;
string symbol;
mapping(uint256 => address) tokenOwners;
mapping(address => EnumerableSet.UintSet) balances;
string baseURI;
mapping(uint256 => string) tokenURIs;
}

Errors info​

ReceiverIsZeroAddress​

error ReceiverIsZeroAddress()

TokenAlreadyExists​

error TokenAlreadyExists(uint256 tokenId)

TokenDoesNotExist​

error TokenDoesNotExist(uint256 tokenId)

Functions info​

name (0x06fdde03)​

function name() public view virtual override returns (string memory)

The function to return the name of the contract

Return values:

NameTypeDescription
[0]stringthe name of the contract

symbol (0x95d89b41)​

function symbol() public view virtual override returns (string memory)

The function to return the symbol of the contract

Return values:

NameTypeDescription
[0]stringthe symbol of the contract

tokenExists (0x00923f9e)​

function tokenExists(
uint256 tokenId_
) public view virtual override returns (bool)

The function to check the existence of the token

Parameters:

NameTypeDescription
tokenId_uint256the token to check

Return values:

NameTypeDescription
[0]booltrue if tokenId_ exists, false otherwise

balanceOf (0x70a08231)​

function balanceOf(
address owner_
) public view virtual override returns (uint256)

The function to get the balance of the user

Parameters:

NameTypeDescription
owner_addressthe user to get the balance of

Return values:

NameTypeDescription
[0]uint256the user's balance

tokenOf (0xa3dabb02)​

function tokenOf(
address owner_,
uint256 index_
) public view virtual override returns (uint256)

The function to get a user's token by its ordinal id

Parameters:

NameTypeDescription
owner_addressthe user to get the token of
index_uint256the id of the token in the user's array

Return values:

NameTypeDescription
[0]uint256the token the user owns

tokensOf (0x5a3f2672)​

function tokensOf(
address owner_
) public view virtual override returns (uint256[] memory)

The function to get ALL the tokens of a user. Be careful, O(n) complexity

Parameters:

NameTypeDescription
owner_addressthe user to get the tokens of

Return values:

NameTypeDescription
[0]uint256[]the array of tokens the user owns

ownerOf (0x6352211e)​

function ownerOf(
uint256 tokenId_
) public view virtual override returns (address)

The function to get the owner of a token

Parameters:

NameTypeDescription
tokenId_uint256the token to get the owner of

Return values:

NameTypeDescription
[0]addressaddress of an owner or address(0) if token does not exist

baseURI (0x6c0360eb)​

function baseURI() public view virtual override returns (string memory)

The function to get the base URI of all the tokens

Return values:

NameTypeDescription
[0]stringthe base URI

tokenURI (0xc87b56dd)​

function tokenURI(
uint256 tokenId_
) public view virtual override returns (string memory)

The function to get the token URI.

  • If individual token URI is set, it gets returned.
  • Otherwise if base URI is set, the concatenation of base URI and token URI gets returned.
  • Otherwise "" gets returned

Parameters:

NameTypeDescription
tokenId_uint256the token to get the URI of

Return values:

NameTypeDescription
[0]stringthe URI of the token

supportsInterface (0x01ffc9a7)​

function supportsInterface(
bytes4 interfaceId_
) public view virtual override returns (bool)

Returns true if this contract implements the interface defined by interfaceId

Parameters:

NameTypeDescription
interfaceId_bytes4the interface ID to check

Return values:

NameTypeDescription
[0]booltrue if the passed interface ID is supported, otherwise false