Go Methods for ERC-721 NFT Locking
Blockchain App Builder automatically generates methods that you can use to lock non-fungible tokens that use the extended ERC-721 standard.
A locked token cannot be burned or transferred to other users. All other properties, such as the token's state, owner, and history are preserved. You can use the NFT locking functionality when transferring a token to another blockchain network, such as Ethereum or Polygon.
Before you can lock NFTs, you must assign the vault manager role to a user. The vault
manager is a special type of role, a TokenSys
role.
TokenSys
roles are different from asset-based roles such as
burner, minter, and notary, and from administrative roles such as Token
Admin
and Org Admin
. Currently Blockchain App Builder
supports the vault
TokenSys
role. The single user who has the vault
role for a chaincode is the vault manager of the chaincode, and can manage locked
NFTs.
- Create a non-fungible token that has the lockable behavior.
- Use the
AddTokenSysRole
method to give thevault
role to a user, the vault manager. - Call the
LockNFT
method to lock a non-fungible token, specified by the token ID.
TokenSys Role Management Methods
-
AddTokenSysRole
- This method adds a
TokenSys
role to a specified user. This method can be called only by aToken Admin
of the chaincode. -
IsInTokenSysRole
- This method returns a Boolean value to indicate if a user has a
specified
TokenSys
role. This method can be called only by aToken Admin
of the chaincode. -
RemoveTokenSysRole
- This method removes a
TokenSys
role from a specified user. This method can be called only by aToken Admin
of the chaincode. -
TransferTokenSysRole
- This method transfers a
TokenSys
role from a user to another user. This method can be called only by aToken Admin
of the chaincode. -
GetAccountsByTokenSysRole
- This method returns a list of all account IDs for a specified
TokenSys
role. This method can be called only by aToken Admin
of the chaincode. -
GetUsersByTokenSysRole
- This method returns user information for all users with a
specified
TokenSys
role. This method can be called only by aToken Admin
of the chaincode.
NFT Locking Methods
-
LockNFT
- This method locks a specified non-fungible token. To lock a
token, there must be a user with the
TokenSys
vault
role, who acts as the vault manager. This method can be called only by the owner of the token. -
IsNFTLocked
- This method returns a Boolean value to indicate if a specified
token is locked. This method can be called only by the token owner, the
vault manager (the user with the
TokenSys
vault
role), or aToken Admin
of the chaincode. -
GetAllLockedNFTs
- This method returns a list of all locked non-fungible tokens.
This method can be called only by the vault manager (the user with the
TokenSys
vault
role) or aToken Admin
of the chaincode. -
GetAllLockedNFTsByOrg
- This method returns a list of all locked non-fungible tokens
for a specified organization and optionally a specified user. This method
can be called only by the vault manager (the user with the
TokenSys
vault
role) or aToken Admin
of the chaincode.