Skip to content
LogoLogo

setAssetLifecycleState

Change an asset's lifecycle state on its NFT.

Usage

const  = await .('did:ope:2a6ebce0af...')
 
const  = await .( 
  , 
  .
) 

Resolves with the receipt once the transaction is mined, and throws if it was not submitted or reverted. Returns undefined without sending a transaction when the asset is already in the requested state. Within one instance, it waits for any publish(), completePublish() or edit() of the same NFT still running before it sends its transaction.

The states can also be set while editing, via AssetBuilder.setLifecycleState — use that when you are changing metadata anyway, and this when the state is all you want to change.

States

  • Type: LifecycleStates
ValueNameMeaning
0ACTIVENormal.
1END_OF_LIFERetired; no longer maintained. Reversible.
2DEPRECATEDSuperseded by another asset. One-way on ocean-node.
3REVOKED_BY_PUBLISHERWithdrawn. One-way on ocean-node.
4ORDERING_DISABLED_TEMPORARILYVisible, but cannot be ordered. Reversible.
5ASSET_UNLISTEDFor markets to hide. The node still resolves it by DID and returns it in searches, flagged with the state. Reversible.

ASSET_UNLISTED hides nothing by itself. The asset stays resolvable by DID and searchable on the node, with indexedMetadata.nft.state set to 5: a market must filter on that state to leave it out.

Reading the state

Read the state from the chain, not from the node. After a DEPRECATED or REVOKED_BY_PUBLISHER change, a 4.2.x node with Elasticsearch has no document to read it from. The NFT's getMetaData() holds it as its third value. Start from the NFT address you stored from the publish result, not from getAsset(): the node may no longer have the document to look it up in:

// at publish time: store the NFT address with your own records
const {  } = await .()
 
// later, after the state change
const  = .()
const  = new (, await ())
 
const  = (await .()) as unknown[] 
const  = ([2]) 

A state change does not update the indexed transaction id either, so waitForIndexer with the receipt's hash cannot wait for it. For the reversible states, polling getAsset and reading getLifecycleState shows when the node has caught up.

DDO v5's State enum carries the same values and is accepted too. nautilus re-exports it as a type only, so pass LifecycleStates members when you need a value.

Returns

  • Type: TransactionReceipt | undefined

The mined receipt. The standalone setMetadataState({ nftAddress, state, chainConfig, signer }) export behaves the same way and also waits for the receipt. A read straight after can still show the old state on an RPC behind a load balancer whose nodes lag each other by a block.

Parameters

asset

  • Type: AssetV5

state

  • Type: LifecycleStates | State