Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nonfungible Token Standard #4

Closed
wants to merge 27 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
418a5d5
NEP-1 incomplete draft with notes
behaviary Jun 28, 2019
1794e1e
minor typo
behaviary Jun 28, 2019
7649150
add details
behaviary Jun 28, 2019
64dfbad
update standard with transfer callback
behaviary Jul 9, 2019
cf1b305
changing ids to use u64 instead of strings
behaviary Jul 10, 2019
f9f8cd4
add descriptions to headings
behaviary Jul 23, 2019
135e78a
clarify on transfer
behaviary Jul 23, 2019
43af15d
'be'
behaviary Jul 23, 2019
37158dd
Merge branch 'master' of github.com:nearprotocol/NEPs into nep-4
behaviary Jul 31, 2019
eb91fd1
Merge branch 'master' of github.com:nearprotocol/NEPs into nep-4
behaviary Sep 26, 2019
e3e9183
nep-4: clean up comments and add examples
behaviary Sep 26, 2019
cc6284d
merge master
behaviary May 15, 2020
00e57ba
Merge branch 'master' of github.com:nearprotocol/NEPs into nep-4
behaviary May 15, 2020
8b15509
update NFT standard
behaviary May 15, 2020
df7772c
change syntax to match Rust-style contract calls and update example
behaviary May 17, 2020
c2f0c10
add to links
behaviary May 17, 2020
8878dc1
clarifications and typos
behaviary May 19, 2020
f1aef35
fix minor typos/grammar issues
chadoh May 19, 2020
7c7b5c9
add missing backtick
chadoh May 19, 2020
e17e086
outdent example AssemblyScript
chadoh May 19, 2020
c6dada6
rearrange block spacing in example AssemblyScript
chadoh May 19, 2020
7670ce9
Update non-fungible-token format: remove owner_id from transfer_from
janedegtiareva May 22, 2020
3c73461
cleanup and changing params for check_access
behaviary May 27, 2020
9167868
Update specs/Standards/Tokens/NonFungibleToken.md
behaviary May 28, 2020
f31e223
Minor changes to transfer (move back to transfer_from and transfer)
janedegtiareva May 28, 2020
39fbef5
Typo in specs/Standards/Tokens/NonFungibleToken.md
behaviary Jun 4, 2020
3c23a47
Grammar in specs/Standards/Tokens/NonFungibleToken.md
behaviary Jun 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 61 additions & 38 deletions 0004-market-integration-token-standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A standard interface for non-fungible tokens allowing for ownership and transfer
# Motivation
[motivation]: #motivation

Non-fungible tokens (NFTs) have been described in many ways: digital goods, collectible items, unique online assets etc. The current core use case for NFTs is speculating on value and trading unique items. The use case of trading NFTs should natively supported for this emerging market.
Non-fungible tokens (NFTs) have been described in many ways: digital goods, collectible items, unique online assets etc. The current core use case for NFTs is speculating on value and trading unique items. The use case of trading NFTs should natively supported for this emerging market.
behaviary marked this conversation as resolved.
Show resolved Hide resolved

The idea of a marketplace-integrated NFT is to make it as easy as possible to merge new services with existing tokens that use the standard. Existing NFT standards still require some customization on the part of third party integrators, which becomes a burden with each NFT integrated. This standard will allow anyone to build a marketplace on top of any number of tokens, not just allowing but promoting trading and extension. These marketplaces can be built into games and apps that use the specific metadata in whatever way they choose.

Expand All @@ -22,27 +22,42 @@ ERC-1155 standard: https://eips.ethereum.org/EIPS/eip-1155
# Guide-level explanation
[guide-level-explanation]: #guide-level-explanation

## Documenting functionality

- mint tokens with metadata
- transfer tokens to new users
- allow users to trade tokens
- allow users to sell tokens (in market)
- I want to craft tokens
- I want to see all tokens
- I want to look at all the types of tokens
- I want to have different kinds of tokens in one contract
- I want to see a user's tokens
- I want to see a token's owner
- I want to see how many tokens of a type exist (are minted)
- I want to see the rarity of a token (total supply)

## Example of minting a token

```TypeScript

let corgiToken = generateRandomCorgiToken(tokenDetails);
near.log(corgiToken.id)
let tokenTypeId = mintTokenType("Corgi Token", 1000);
near.log(tokenTypeId);
// 0

// This should be done with a constructor, but is done here with attributes illustratively
let corgiToken = {};
corgiToken.name = "Winnifred";
corgiToken.tokenTypeId = tokenTypeId;
corgiToken.data = "{\"url\":\"corgi name\"}";

// At this point, corgi doesn't have an id because it hasn't been minted yet
near.log(corgiToken.id);
// null

// id generation should be incremental and unique across all tokens
let mintedCorgiToken = mintToken(corgiToken);
near.log(corgiToken.id)
// "2134aa-adsf34-asd23a-1qwera" or simply "1"
// id generation can be randomized or incremental

near.log(mintedCorgiToken.tokenType.name);
// "CorgiToken"

const sender = context.sender;
const recipient = "new.owner";
const tokenId = ["1"];


// 0
```

# Reference-level explanation
Expand All @@ -65,38 +80,43 @@ At time of writing, this standard is established with several constraints found
unimplemented();
}

export function getToken(tokenId:string):Token {
// returns TokenTypeID, which is also an index
export function mintTokenType(name:string, totalSupply:u64):u32 {
unimplemented();
}

export function getTokenOwner(tokenId:string):string {
export function getToken(tokenId:u64):Token {
unimplemented();
}

export function getTokenTypes():TokenType[] {
export function getTokenType(tokenTypeId:u32) {
behaviary marked this conversation as resolved.
Show resolved Hide resolved
unimplemented();
}
export function getTokensByOwner(ownerId:string, startTokenId:string = null, limit:u32 = 10):Token[] {

export function getTokenOwner(tokenId:u64):string {
unimplemented();
}

export function getCountByOwner(tokenType: TokenType, ownerId: string) {
export function getAllTokenTypes():TokenType[] {
unimplemented();
}

export function getTokenData(tokenId:string):bytes {

export function getTokensByOwner(ownerId:string, startTokenId:u64 = 0, limit:u32 = 10):Token[] {
behaviary marked this conversation as resolved.
Show resolved Hide resolved
unimplemented();
}

export function getCountByOwner(ownerId: string):u64 {
unimplemented();
}

export function transfer(recipientId:string, tokenIds:string[], onTransfer:PayloadCallback = null):void {
export function transfer(recipientId:string, tokenIds:u64[], onTransfer:PayloadCallback = null):void {
unimplemented();
behaviary marked this conversation as resolved.
Show resolved Hide resolved
}

class OnTransferArgs {
ownerId: string;
recipientId: string;
tokenIds: string[];
tokenIds: u64[];
payload: string;
}

Expand All @@ -107,24 +127,24 @@ At time of writing, this standard is established with several constraints found
}

//*** Researching the following methods ***//
function lockToken(tokenId:string):void {
function lockToken(tokenId:u64):void {
unimplemented();
}
function unlockToken(tokenId:string):void {

function unlockToken(tokenId:u64):void {
unimplemented();
}

// The concept of escrow that the standard knows about is optimizing for multiple NFT exchanges
export function checkEscrow(escrowId:string, tokenIds:string[]) {
export function checkEscrow(escrowId:string, tokenIds:u64[]) {
unimplemented();
}

export function approveEscrow(escrowId:string, tokenIds:string[]):void {
export function approveEscrow(escrowId:string, tokenIds:u64[]):void {
unimplemented();
}

export function cancelEscrow(escrowId:string, tokenIds:string[]):void {
export function cancelEscrow(escrowId:string, tokenIds:u64[]):void {
behaviary marked this conversation as resolved.
Show resolved Hide resolved
unimplemented();
}
```
Expand All @@ -137,25 +157,28 @@ At time of writing, this standard is established with several constraints found

`mintToken` - It's up to the developer of a token to decide how tokens are generated. Minting should return the Token with a unique ID attached.

`transfer` - A straightforward transfer between two
`transfer` - A straightforward transfer between two

needs collections
## Collections
```TypeScript
tokens
tokensByOwner
```

## Models for AssemblyScript contract

```TypeScript
export class Token {
id: string;
tokenType: TokenType;
data: bytes;
id:u64;
tokenTypeId:u32;
// serialized json
data:string;
behaviary marked this conversation as resolved.
Show resolved Hide resolved
behaviary marked this conversation as resolved.
Show resolved Hide resolved
}

export class TokenType {
id: string;
name: string;
id: u32;
totalSupply: u64;
data:string;
}

```
Expand Down