Understanding Escrow in ERC-721 NFT Smart Contracts

Kristaps Grinbergs
3 min readMar 28, 2024

The ERC-721 standard helps make buying and selling unique digital items (NFTs) safe and reliable. It is crucial to secure transactions between two parties. That is where escrow services come in. They act like a safety net, holding an NFT until everyone agrees and all rules have been met. Let's explore how we can develop an escrow using the ERC-721 standard using OpenZeppelin implementation.

Photo by Mathew Schwartz on Unsplash

Sending an NFT to an Escrow

At first, the NFT asset holder needs to approve that a specific token can be used by someone else to transfer it. Only the owner of that token can execute this command.

With the implementation of OpenZeppelin ERC-721, we can call the approve(address to, uint256 tokenId) function to delegate it.

// Send to ESCROW address
function sendToESCROW(address escrow, uint256 tokenId) public {
approve(escrow, tokenId);
}

In the code above, when the owner of the tokenId calls this function, they delegate transfer functionality to the escrow address. Now the escrow account holder can transfer this NFT to another address.

We can get an approved address to check if the token has been delegated to another account. If it is a zero (0x) address, that means it has not been delegated.

--

--

Kristaps Grinbergs
Kristaps Grinbergs

Written by Kristaps Grinbergs

Blockchain, mobile and fullstack developer. Startup founder. Conference speaker. Mentor. Passionate about building products, sustainability and Web 3.0.

No responses yet