Smart Contract

InscriptionMetadata

A.88dd257fcf26d3cc.InscriptionMetadata

Deployed

2h ago
Feb 28, 2026, 06:38:56 PM UTC

Dependents

0 imports
1import FungibleToken from 0xf233dcee88fe0abe
2import NonFungibleToken from 0x1d7e57aa55817448
3
4pub contract InscriptionMetadata {
5
6    /// Provides access to a set of metadata views. A struct or 
7    /// resource (e.g. an NFT) can implement this interface to provide access to 
8    /// the views that it supports.
9    ///
10    pub resource interface Resolver {
11        pub fun getViews(): [Type]
12        pub fun resolveView(_ view: Type): AnyStruct?
13    }
14
15    /// A group of view resolvers indexed by ID.
16    ///
17    pub resource interface ResolverCollection {
18        pub fun getIDs(): [UInt64]
19    }
20
21    /// Basic view that includes the name, description and thumbnail for an 
22    /// object. Most objects should implement this view.
23    /// InscriptionView is a group of views used to give a complete picture of an inscription
24    ///
25    pub struct InscriptionView {
26        pub let id: UInt64
27        pub let uuid: UInt64
28        pub let inscription: String
29
30        init(
31            id : UInt64,
32            uuid : UInt64,
33            inscription : String,
34        ) {
35            self.id = id
36            self.uuid = uuid
37            self.inscription = inscription
38        }
39    }
40
41    /// Helper to get an Inscription view 
42    ///
43    /// @param id: The inscription id
44    /// @param viewResolver: A reference to the resolver resource
45    /// @return A InscriptionView struct
46    ///
47    pub fun getInscriptionView(id: UInt64, viewResolver: &{Resolver}) : InscriptionView {
48        let inscriptionView = viewResolver.resolveView(Type<InscriptionView>())
49        if inscriptionView != nil {
50            return inscriptionView! as! InscriptionView
51        }
52
53        return InscriptionView(
54            id : id,
55            uuid: viewResolver.uuid,
56            inscription: "",
57        )
58    }
59
60}
61