Core Functionality | NEAR Protocol Specification
NFT에 대한 표준 인터페이스.
기존 ERC-721에 비해 여러 향상된 기능이 추가됨 ⇒ 이전에는 2~3차례 contract call해야 했던 것을 한번에 해결 가능. 아래가 대표적인 예.
nft_transfer_call: user가 타 contract를 호출할 때, 토큰을 attach할 수 있다.
(attach한 토큰은 설정에 따라서, chain of promise가 끝난 후에 돌려받을 수도, 혹은 receiver contract에 줄 수도 있다.)
nft_on_transferReceiver contract가 NFT를 받은 후, 몇 가지 action들을 수행한다.
만약 sender_id로 NFT를 돌려줘야 한다면, true를 return한다.
// Take some action after receiving a non-fungible token
//
// Requirements:
// * Contract MUST restrict calls to this function to a set of whitelisted NFT
// contracts
//
// Arguments:
// * `sender_id`: the sender of `nft_transfer_call`
// * `previous_owner_id`: the account that owned the NFT prior to it being
// transferred to this contract, which can differ from `sender_id` if using
// Approval Management extension
// * `token_id`: the `token_id` argument given to `nft_transfer_call`
// * `msg`: information necessary for this contract to know how to process the
// request. This may include method names and/or arguments.
//
// Returns true if token should be returned to `sender_id`
function nft_on_transfer(
sender_id: string,
previous_owner_id: string,
token_id: string,
msg: string,
): Promise<boolean>;
필수조건:
Arguments:
sender_id: nft_transfer_call의 sender