Comments (5)
It's unclear how you mint two different singular NFTs on the same contract with different metadata ...
Everything is catered toward a range of NFT IDs with the same metadata.
Yes, this is a special NFT contract which represents "semi-fungible" NFTs.
You might want to look at NFT collectibles example: https://github.com/oxheadalpha/smart-contracts/tree/master/collectibles
https://github.com/oxheadalpha/smart-contracts/blob/master/collectibles/ligo/src/fa2_single_asset.mligo contract can be originated with a fixed NFT collection where each NFT has different metadata.
You may also have a look at https://github.com/tqtezos/minter-sdk which has a variety of fungible and non-fungible token contracts implementation or take the NFT contract from https://github.com/oxheadalpha/nft-tutorial
from smart-contracts.
Although I can't manage to write a working lambda, I've managed to assert from this:
(** Finds a definition of the token type (token_id range) associated with the provided token id *)
let find_token_def (tid, token_defs : token_id * (token_def set)) : token_def =
let tdef = Set.fold (fun (res, d : (token_def option) * token_def) ->
match res with
| Some r -> res
| None ->
if tid >= d.from_ && tid < d.to_
then Some d
else (None : token_def option)
) token_defs (None : token_def option)
in
match tdef with
| None -> (failwith fa2_token_undefined : token_def)
| Some d -> d
That it seems to match on tid
being greater than or equal to the from
, but less than the to
(exclusive).
So if I want data for token 3 and there are four pairs in storage
Pair(1, 2) -> url1
Pair(2, 3) -> url2
Pair(3, 4) -> url3
Pair(4, 5) -> url4
It will always pick Pair(3,4)
with url3
as
3 >= 3 is true
3 < 4 is true
And
3 >= 2 is true
3 < 3 is false
And
3 >= 4 is false
3 < 5 is true
And
3 >= 1 is true
3 < 2 is false
from smart-contracts.
I think we should put this more clearly somewhere as an example for future devs as it's a pretty odd pattern for something where each token inherently is supposed to have unique data.
I still have no idea how to pass in the lambda for getting token data.
from smart-contracts.
The token_metadata endpoint is also a little arcane, as it asks for a lambda as the first parameter and I'm not sure what sort of function it expects.
I still have no idea how to pass in the lambda for getting token data.
This is a special way to implement contract view entry points. Tezos will have Solidity-like view entry points with the next protocol update. At the moment, view entry points use continuation passing style pattern when the parameter contains a callback lambda.
If the contract A wants to get some value from the contract B, it should call contract's A view entry point passing parameters (like token_id) and a callback. Contract B then will call a provided callback entry point of the contract A, passing the requested value.
In general, view entry points cannot be called off-chain (only by other contracts). But Taquito library has special API which lets to inspect view entry points off-chain: https://tezostaquito.io/docs/lambda_view/
from smart-contracts.
@emishur thank you so much for all of this information. really appreciated
from smart-contracts.
Related Issues (20)
- Passing lambda into Balance_of entry point can be exploited to spoof a receiver
- Multi_asset safety check in spec, LIGO HOT 17
- Implement a new multisig contract
- MAC specifications - Milestones
- add_operator should handle implicit accounts
- Make implicit account whitelisting part of the explicit specification HOT 1
- Forwarder with whitelist and transfer check HOT 1
- FA1.4 HOT 2
- FA2 Documentation Review HOT 1
- Write up wrapper
- Write up wrapper examples and other FA2 details
- Make `pause` more fine grained on multi assets implementation
- Integrate TZIP-20 off-chain events for Mint / Burn / Origination
- publish as a node package? HOT 1
- Path issue when running tests HOT 2
- Can't Seem To Find Entrypoint for fa2_nft_asset
- Support for JsLIGO, PascaLIGO, and/or ReasonLIGO HOT 1
- FA2 update
- Calling `Balance_of` (or `get_balance`) from CameLIGO test HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smart-contracts.