The Resource Manager

When a resource is created on the Radix network, a “Resource Manager” with a unique address will be associated with it. This manager contains the data of this resource such as its type (fungible or non-fungible), its metadata and its supply among other things. It also allows people with the right authority to do actions on the resource like minting more tokens and updating its metadata. On this page, we will show you how to use the ResourceManager type that Scrypto offers and the various methods you can call on it.

Methods available on ResourceManager

The ResourceManager offers many methods that we listed in the following tables.

Fetching resource information

Method

Description

get_metadata(key)

Returns the metadata associated with the specified key.

resource_type()

Returns a ResourceType that is either non-fungible or fungible.

total_supply()

Returns the total supply of the resource.

non_fungible_exists(NonFungibleLocalId)

Returns whether a token with the specified non-fungible id was minted.

get_non_fungible_data(NonFungibleLocalId)

Returns the data associated with a particular non-fungible token of this resource.

Applying actions

Provided that the correct authority is presented (more information about this here), you can apply the following actions to a resource.

Method

Description

set_metadata(key, value)

Updates a metadata key associated with this resource.

mint(amount)

Mints an amount of fungible tokens.

Note: The resource must be of the fungible type.

mint_non_fungible(&id, data)

Mints a non-fungible token with the specified id and data.

Note: The resource must be of the non-fungible type

update_non_fungible_data(&id, field_name, new_data)

Updates a single field of the non-fungible data associated with a minted non-fungible token of the specified ID.

Updating resource flags

More information on access rules and resource flags here.

Method

Description

set_mintable(access_rule)

Sets the access rule for being able to update the mintable flag.

lock_mintable()

Locks the mintable flag.

set_burnable(access_rule)

Sets the access rule for being able to update the burnable flag.

lock_burnable()

Locks the burnable flag.

set_withdrawable(access_rule)

Sets the access rule for being able to update the withdrawable flag.

lock_withdrawable()

Locks the withdrawable flag.

set_depositable(access_rule)

Sets the access rule for being able to update the depositable flag.

lock_depositable()

Locks the depositable flag.

set_recallable(access_rule)

Sets the access rule for being able to update the recallable flag.

lock_recallable()

Locks the recallable flag.

set_updatable_metadata(access_rule)

Sets the access rule for being able to update the updateable_metadata flag.

lock_updatable_metadata()

Locks the updateable_metadata flag.

set_updatable_non_fungible_data(access_rule)

Sets the access rule for being able to update the updateable_non_fungible_data flag.

lock_updatable_non_fungible_data()

Locks the updateable_non_fungible_data flag.