1

I am having an issue transferring ownership of an ERC721 token to a deployed Holding contract.

The error I’m getting when running truffle test is the following - Error: sender account not recognized When calling the transferFrom() function on the ERC721 contract using the deployed Holding contract.

I have successfully approved the Holding contract before calling transferFrom() so that is not the issue, but I’m unaware where the error is in trying to transfer the NFT to the Holding Contract.

The contracts and test file are located here: https://github.com/sharad-s/DAOjo

The specific line of code which is causing this error in my tests is line 120 of DAOjo/test/test.js

To recreate this error:

  • Clone repo
  • Install truffle globally
  • Run a ganache local blockchain instance (port 8545)
  • Run truffle test in the root of this repo

Following is the error stack trace:

Contract: Crowdsale
DAOToken
1e+23
      ✓ should have a total supply of: 1e+23
      ✓ should have transferred 1e+23 to Crowdsale
    Crowdsale
Wei Raised:  1000000000000000000
Buyer Balance:  1000000000000000000
      ✓ should accept ETH payments (144ms)

Contract: NFTTokenMetaDataEnumerableMock
  NFT Registry
      ✓ Should have a total of 0 tokens when created
NFT APPROVED FOR:  0x3a0a837952964bdf3e751ba838e04b9a1752d94a
HOUSE OWNER:  0x6e4679ddb735556a47dd548489dfab641752afd5
SPV:  0x3a0a837952964bdf3e751ba838e04b9a1752d94a
DAO TOKEN BALANCE OF BUYER 1:  BigNumber { s: 1, e: 3, c: [ 1000 ] }
      1) Should approve and transfer token to SPV contract

    Events emitted during test:
    ---------------------------

    Transfer(from: <indexed>, to: <indexed>, value: 1000)
    Transfer(from: <indexed>, to: <indexed>, value: 1000)
    Transfer(from: <indexed>, to: <indexed>, value: 1000)
    Transfer(from: <indexed>, to: <indexed>, value: 0)
    Approval(owner: <indexed>, spender: <indexed>, value: 0)

    ---------------------------


  4 passing (3s)
  1 failing

  1) Contract: NFTTokenMetaDataEnumerableMock
       NFT Registry
         Should approve and transfer token to SPV contract:
 Error: sender account not recognized
  at Object.InvalidResponse (/Users/sharad/.nvm/versions/node/v8.9.4/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1)
  at /Users/sharad/.nvm/versions/node/v8.9.4/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:86:1
  at /Users/sharad/.nvm/versions/node/v8.9.4/lib/node_modules/truffle/build/webpack:/packages/truffle-provider/wrapper.js:134:1
  at XMLHttpRequest.request.onreadystatechange (/Users/sharad/.nvm/versions/node/v8.9.4/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
  at XMLHttpRequestEventTarget.dispatchEvent (/Users/sharad/.nvm/versions/node/v8.9.4/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
  at XMLHttpRequest._setReadyState (/Users/sharad/.nvm/versions/node/v8.9.4/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
  at XMLHttpRequest._onHttpResponseEnd (/Users/sharad/.nvm/versions/node/v8.9.4/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
  at IncomingMessage.<anonymous> (/Users/sharad/.nvm/versions/node/v8.9.4/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:469:1)
  at endReadableNT (_stream_readable.js:1055:12)
  at _combinedTickCallback (internal/process/next_tick.js:138:11)
  at process._tickCallback (internal/process/next_tick.js:180:9)

Thank you!

2

You can only send transactions from an account your node (ganache, in this case) knows the private key for. In this code:

const transferFrom = await _HouseNFTRegistry.transferFrom(
    houseOwner,
    _spvHoldingCrowdsale.address,
    1,
    { from: _spvHoldingCrowdsale.address, to: _HouseNFTRegistry.address }
);

you're trying to send a transaction from the address of a contract, which you can't do. (No one knows the private key for that address.)

  • Got it, thank you! I solved this by calling the transferFrom() function {from : houseOwner} which i defined as address[0] given from ganache, who also owned the NFT meant for transfer. – Sharad S. Aug 17 '18 at 20:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.