When NFT (ERC-721) is traded, I'd like its minter (creator) of the NFT to receive a royalty.

In order to achieve this, I've tried

  1. call ERC20.transferFrom inside of ERC721.transferFrom -> it compiled, but had runtime error.
  2. created a third contract importing both ERC721, ERC20 and then a new function to call ERC20.transferFrom and ERC721.transferFrom -> again, the same runtime error.

How should I go about implementing this? My full code is here -> https://github.com/NCGlobalTech/NFT_Voting_Dapp

Inside contract folder: ERC20Token.sol: my ERC20 contract inheriting openzeppelin erc20 interface NFTTrade.sol: my ERC721 contract inheriting openzeppelin erc721 interface NFTtoken.sol: The third contract to call TransferFrom both ERC20/ERC721 contracts by inheriting both.

Runtime Errors:

inpage.js:1 MetaMask - RPC Error: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32603,"data":{"message":"VM Exception while processing transaction: revert","code":-32000,"data":{"0x3ca874aa420b982f88249897a41c714b25d2cc10730ed1522c09feadd0a2a9fd":{"error":"revert","program_counter":368,"return":"0x"},"stack":"RuntimeError: VM Exception while processing transaction: revert\n    at Function.RuntimeError.fromResults (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\lib\\utils\\runtimeerror.js:94:13)\n    at BlockchainDouble.processBlock (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\lib\\blockchain_double.js:627:24)\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (internal/process/task_queues.js:93:5)","name":"RuntimeError"}}}}' {code: -32603, message: `[ethjs-query] while formatting outputs from RPC '{…/task_queues.js:93:5)","name":"RuntimeError"}}}}'`}
Uncaught (in promise) {code: -32603, message: `[ethjs-query] while formatting outputs from RPC '{…/task_queues.js:93:5)","name":"RuntimeError"}}}}'`, stack: '{\n  "code": -32603,\n  "message": "[ethjs-query] wh…gaeaoehlefnkodbefgpgknn/background-0.js:1:216902)'}

Thank you


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.