Skip to Content
Mastering Blockchain Programming with Solidity
book

Mastering Blockchain Programming with Solidity

by Jitendra Chittoda
August 2019
Intermediate to advanced
486 pages
13h 52m
English
Packt Publishing
Content preview from Mastering Blockchain Programming with Solidity

The _isApprovedOrOwner internal function

_isApprovedOrOwner() is an internal function, which is used to check whether the given address of spender is approved or an owner of the given tokenId.

This function takes two arguments:

  • spender: The address of the spender who is going to spend the given tokenId
  • tokenId: The tokenId of the NFT that the spender wants to transfer

This function returns the Boolean result. If the result is as follows:

  • true: The given spender is the owner or an approved address
  • false: The given spender is neither the owner, nor the approved address

Let's look at the _isApprovedOrOwner() function code:

function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) {    address owner = ownerOf(tokenId) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Ethereum

Mastering Ethereum

Andreas M. Antonopoulos, Gavin Wood
Complete Cryptocurrency and Blockchain Course | Learn Solidity

Complete Cryptocurrency and Blockchain Course | Learn Solidity

Ravinder Deol, Codestars By Rob Percival, Thomas Wiesner

Publisher Resources

ISBN: 9781839218262Supplemental Content