PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, September 25, 2022

[FIXED] how to I write timestamp in erc721-contract when someone transfer it

 September 25, 2022     blockchain, ethereum, solidity     No comments   

Issue

I want to know when the current owner has this token by storing a new timestamp every time an erc721 token is traded. I want to store a timestamp (ex. string timestamp = "20220430") in my contract whenever transferFrom and safeTransferFrom are executed, please give me an idea of the best way. My contract inherits from ERC721A(AZUKI standard).


Solution

My suggestion is to add an event:

event TransferTimestamp(uint256 tokenId, address from, address to, uint256 timestamp);

And emit it on either of the two methods, using block.timestamp to get the timestamp:

emit TransferTimestamp(tokenId, msg.sender, to, block.timestamp);

Note: block.timestamp is inaccurate. Miners are directly able to influence its value with no checks.

Alternatively, you could use the built-in Transfer event present in all EIP-721 NFTs. The event list has the block when it was emitted, which can then be converted to a timestamp in the DApp's frontend.



Answered By - Pandapip1
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing