Aller au contenu


Contains a set of results from Blockchain.GetTokens() and related functions. Depending on how many tokens are available, results may be separated into multiple pages. The .hasMoreResults property may be checked to determine whether more tokens are available. Those results may be retrieved using the :GetMoreResults() function.


Property Name Return Type Description Tags
hasMoreResults boolean Returns true if there are more tokens available to be requested. Read-Only


Function Name Return Type Description Tags
GetResults() Array<BlockchainToken> Returns the list of tokens contained in this set of results. This may return an empty table. None
GetMoreResults() <BlockchainTokenCollection, BlockchainTokenResultCode, string error Requests the next set of results for this list of tokens and returns a new collection containing those results. This function may yield until a result is available. Returns nil if the hasMoreResults property is false, or if an error occurs while fetching data. The status code in the second return value indicates whether the request succeeded or failed, with an optional error message in the third return value. None


Example using:




In this example, we want to differentiate the gameplay experience dependant on the player owning NFTs from a specific collection. If a player owns an NFT they are assigned to team 2, whereas other players are assigned to team 1. This could be used, for example, in conjunction with a collider to create a VIP section on the map, accessible only to holders of the NFT. To demonstrate we use the BAYC contract address. Replace it with the address to any other NFT contract to specify the collection representative of VIP status in your game.

-- Address to the NFT contract for Bored Ape Yacht Club
local NFT_CONTRACT_ADDRESS = "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d"
local HOLDER_TEAM = 2

-- Given a player and an NFT collection, check if the player owns a token
function DoesPlayerOwnFromContract(player, contractAddress)
    local walletsResult, walletsStatus, walletsErr = Blockchain.GetWalletsForPlayer(player)

    if walletsStatus == BlockchainTokenResultCode.SUCCESS then
        local wallets = walletsResult:GetResults()

        for walletIndex, wallet in ipairs(wallets) do
            local tokensResult, tokensStatus, tokensErr = Blockchain.GetTokensForOwner(wallet.address, { contractAddress = contractAddress })

            if tokensStatus == BlockchainTokenResultCode.SUCCESS then
                local tokens = tokensResult:GetResults()

                if #tokens > 0 then
                    return true

    return false

-- Is the given player considered VIP in our game?
function IsVIP(player)
    return DoesPlayerOwnFromContract(player, NFT_CONTRACT_ADDRESS)

-- A player joined. Set their team based on their VIP status
function OnPlayerJoined(player)
    if IsVIP(player) then = HOLDER_TEAM
        print( .. " is a holder and VIP member.")
    else = NON_HOLDER_TEAM
        print( .. " is not a holder.")


See also: Blockchain.GetWalletsForPlayer | BlockchainToken.contractAddress | Game.playerJoinedEvent |

Learn More


Dernière mise à jour: 10 septembre 2022