NFT libs mistakes on beta-3 building

Hi! I have a lot of mistakes in NFT library while im building my contract on beta-3:

error
   --> /Users/master/.forc/git/checkouts/nft-30641758e4be7209/14139407704840d45d7eba9b2fa040b1b430b3a9/libs/nft/src/lib.sw:152:15
    |
150 | 
151 | pub fn owner_of(token_id: u64) -> Option<Identity> {
152 |     let nft = read::<Option<NFTCore>>(sha256((TOKENS, token_id)), 0).unwrap_or(Option::None);
    |               ^^^^ Could not find symbol "read" in this scope.
153 | 
154 |     match nft {
    |
____

error
   --> /Users/master/.forc/git/checkouts/nft-30641758e4be7209/14139407704840d45d7eba9b2fa040b1b430b3a9/libs/nft/src/lib.sw:180:5
    |
178 | 
179 |     let sender = msg_sender().unwrap();
180 |     write(sha256((OPERATOR_APPROVAL, sender, operator)), 0, approve);
    |     ^^^^^ Could not find symbol "write" in this scope.
181 | 
182 |     log(OperatorEvent {
    |
____

error
   --> /Users/master/.forc/git/checkouts/nft-30641758e4be7209/14139407704840d45d7eba9b2fa040b1b430b3a9/libs/nft/src/lib.sw:196:5
    |
194 | 
195 | pub fn tokens_minted() -> u64 {
196 |     read::<u64>(TOKENS_MINTED, 0).unwrap_or(0)
    |     ^^^^ Could not find symbol "read" in this scope.
197 | }
    |
____

error
   --> /Users/master/.forc/git/checkouts/nft-30641758e4be7209/14139407704840d45d7eba9b2fa040b1b430b3a9/libs/nft/src/lib.sw:216:15
    |
214 | 
215 | pub fn transfer(to: Identity, token_id: u64) {
216 |     let nft = read::<Option<NFTCore>>(sha256((TOKENS, token_id)), 0).unwrap_or(Option::None);
    |               ^^^^ Could not find symbol "read" in this scope.
217 |     require(nft.is_some(), InputError::TokenDoesNotExist);
218 |     let _ = nft.unwrap().transfer(to);
    |
____

  Aborting due to 56 errors.
Error: Failed to compile nft

How i can fix it?(another sway libs version???). And what about the metadata on beta-3?

You need to import read from std::storage::storage_api::read

However, your code looks a bit outdated, most storage operations will be easier with the Fuel storage API.

Also, NFTs will be changing significantly on beta-4, which will introduce native NFTs.

2 Likes

this project for hackathon, i can’t wait beta-4…

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.