Types
Media
export class Media {
id: string
owner_id: string
creator: string
prev_owner: string
metadata: TokenMetadata
royalty: Royalty
constructor(media: string) { }
}
Metadata
export class TokenMetadata {
constructor(
public title: string = '',
public issued_at: string = '',
public copies: u8 = 1,
public media: string = '',
public extra: Uint8Array = new Uint8Array(0),
public description: string = '',
public media_hash: string = '',
public expires_at: string = '',
public starts_at: string = '',
public updated_at: string = '',
public reference: string = '',
public reference_hash: string = ''
) {}
}
export class NFTContractMetadata {
constructor(
public spec: string = NFT_SPEC,
public name: string = NFT_NAME,
public symbol: string = NFT_SYMBOL,
public icon: string = '',
public base_uri: string = '',
public reference: string = '',
public reference_hash: string = ''
) {}
}
Royalty
export class Royalty {
split_between: Map<AccountId, u32> = new Map()
percentage: u32 = 0
constructor() {
/** 25% of future sales goes to FT */
this.split_between.set(FT_CONTRACT, ROYALTY_PERCENTAGE)
this.percentage = ROYALTY_PERCENTAGE
}
}
Methods
Claim Media
POST
[nft-contract].claim_media(media)
Mint Media for user.
Request Body
Name | Type | Description |
---|
| | Identifier of media on decentralized storage. |
{
"id": "mmmmm",
"owner_id": "berrytest.testnet",
"creator": "ysn-1_0_0.ysn.testnet",
"prev_owner": "ysn.testnet",
"metadata": {
"title": "berrytest",
"issued_at": "1627037962034007695",
"copies": 1,
"media": "b-ATrsmcvLYREXzQKpW8Yq9u9WZMR4KU-jnjOMNGt64",
"extra": "",
"description": "",
"media_hash": "",
"expires_at": "",
"starts_at": "",
"updated_at": "",
"reference": "",
"reference_hash": ""
},
"royalty": {
"split_between": {
"ysn-1_0_0.ysn.testnet": 2500
},
"percentage": 2500
}
}
Burn Design
DELETE
[nft-contract].burn_design(token_id)
Removes Media.
Request Body
NFT Token
GET
[nft-contract].nft_token(token_id)
Retrieve a specific token.
Request Body
{
"id": "ysn57031827",
"owner_id": "ysn.testnet",
"creator": "ysn-1_0_0.ysn.testnet",
"prev_owner": "ysn.testnet",
"metadata": {
"title": "ysn",
"issued_at": "1627565749029316411",
"copies": 1,
"media": "-H5vVA2HosWrOecpXebEKLt4cq4_BmAZzm1QjcCzB8o",
"extra": "",
"description": "",
"media_hash": "",
"expires_at": "",
"starts_at": "",
"updated_at": "",
"reference": "",
"reference_hash": ""
},
"royalty": {
"split_between": {
"ysn-1_0_0.ysn.testnet": 2500
},
"percentage": 2500
}
}
NFT Total Supply
GET
[nft-contract].nft_total_supply()
Returns number of tokens.
NFT Tokens
GET
[nft-contract].nft_tokens(from_index, limit)
An array of tokens from index to limit.
Request Body
[
{
id: 'mmmmm',
owner_id: 'berrytest.testnet',
creator: 'ysn-1_0_0.ysn.testnet',
prev_owner: 'ysn.testnet',
metadata: {
title: 'berrytest',
issued_at: '1627037962034007695',
copies: 1,
media: 'b-ATrsmcvLYREXzQKpW8Yq9u9WZMR4KU-jnjOMNGt64',
extra: '',
description: '',
media_hash: '',
expires_at: '',
starts_at: '',
updated_at: '',
reference: '',
reference_hash: ''
},
royalty: {
split_between: { 'ysn-1_0_0.ysn.testnet': 2500 },
percentage: 2500
}
},
{
id: 'yyyyy',
owner_id: 'berrytest.testnet',
creator: 'ysn-1_0_0.ysn.testnet',
prev_owner: 'berrytest.testnet',
metadata: {
title: 'berrytest',
issued_at: '1627550039482793937',
copies: 1,
media: 'iNannrXFNmLKZOoSrbl9KGuqptHKkNh1BsAomyXSu7Q',
extra: '',
description: '',
media_hash: '',
expires_at: '',
starts_at: '',
updated_at: '',
reference: '',
reference_hash: ''
},
royalty: {
split_between: { 'ysn-1_0_0.ysn.testnet': 2500 },
percentage: 2500
}
}
]
NFT Supply For Owner
GET
[nft-contract].nft_supply_for_owner(account_id)
A number of tokens are owned by the account.
Path Parameters
NFT Tokens For Owner
GET
[nft-contract].nft_tokens_for_owner(account_id, from_index, limit)
An array of tokens owned by account.
Request Body
[
{
id: 'yyyyy',
owner_id: 'berrytest.testnet',
creator: 'ysn-1_0_0.ysn.testnet',
prev_owner: 'berrytest.testnet',
metadata: {
title: 'berrytest',
issued_at: '1627550039482793937',
copies: 1,
media: 'iNannrXFNmLKZOoSrbl9KGuqptHKkNh1BsAomyXSu7Q',
extra: '',
description: '',
media_hash: '',
expires_at: '',
starts_at: '',
updated_at: '',
reference: '',
reference_hash: ''
},
royalty: {
split_between: { 'ysn-1_0_0.ysn.testnet': 2500 },
percentage: 2500
}
}
]
NFT Transfer
PATCH
[nft-contract].nft_transfer(token_id, bidder)
Transfer token to the new owner.
Request Body
Name | Type | Description |
---|
| | |
| | The receiver of the token. |
NFT Metadata
GET
[nft-contract].nft_metadata()
Return contract metadata.
{
"spec": "nft-1.0.0",
"name": "ml1w",
"symbol": "ML1W",
"icon": null,
"base_uri": null,
"reference": null,
"reference_hash": null
}
init
POST
[nft-contract].init(contract_metadata, market_contract)
Initialize new contract.
Request Body
Name | Type | Description |
---|
| | |
| | Address of the Market contract. |