[Question]: Why is contractAddress null when checking transaction of transfered NFT?

When getting the information of a received transaction with web3 + transactionHash( web3Js.eth.getTransactionReceipt) I get that the contractAddress is null and that the to address is the same as smart contract address.

{
contractAddress: null -- why null
from: "0x5b6fb1739af592db13681832d0811709755a1a64" -- this is from address
status: true
to: "0x9b1e7450e54887afebefc020c980e217fdfb4e7b" -- this is smart contract addess
}

Should it not be that that the to would be the receiver address and the contractAddress would be the same as smart contract address?

What is the transaction + code you’re using?

etherscan:
https://ropsten.etherscan.io/tx/0x29ac1c9622f996a96d88a77d9a35d71203cf05d450048884041e32d53b812abb

This is the transaction returned by web3JS getTransactionReceipt. You can find this transaction on **ropsten ** test network.

{
    "blockHash": "0x00ef6c7936bbfc98fee8bdb6a02881bdfd9927215c73e34b219992d121c86ef4",
    "blockNumber": 12196727,
    "contractAddress": null,
    "cumulativeGasUsed": 2013433,
    "effectiveGasPrice": 1504526282,
    "from": "0x5b6fb1739af592db13681832d0811709755a1a64",
    "gasUsed": 53529,
    "logs": [
        {
            "address": "0x9B1e7450E54887aFEBEfC020C980E217FDFb4e7b",
            "blockHash": "0x00ef6c7936bbfc98fee8bdb6a02881bdfd9927215c73e34b219992d121c86ef4",
            "blockNumber": 12196727,
            "data": "0x00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000001",
            "logIndex": 125,
            "removed": false,
            "topics": [
                "0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62",
                "0x0000000000000000000000005b6fb1739af592db13681832d0811709755a1a64",
                "0x0000000000000000000000005b6fb1739af592db13681832d0811709755a1a64",
                "0x000000000000000000000000174ddab197328389a6fc2c1868e66e570d813afb"
            ],
            "transactionHash": "0x29ac1c9622f996a96d88a77d9a35d71203cf05d450048884041e32d53b812abb",
            "transactionIndex": 30,
            "id": "log_dce2e45e"
        }
    ],
    "logsBloom": "0x00000000000000000000000008008000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000100000000008200000000000000000000000000000000000000000000000000000000000000000000000080000000002",
    "status": true,
    "to": "0x9b1e7450e54887afebefc020c980e217fdfb4e7b",
    "transactionHash": "0x29ac1c9622f996a96d88a77d9a35d71203cf05d450048884041e32d53b812abb",
    "transactionIndex": 30,
    "type": "0x2"
}

Code:

import { useMoralis, useNFTTransfers } from 'react-moralis';
import Web3 from 'web3';

...

const { Moralis} = useMoralis();
const { fetch } = useWeb3Transfer();
const { getNFTTransfers } = useNFTTransfers();
const web3Js = new Web3(Moralis.provider);

// transfering the NFT from 0x5b6fb1739af592db13681832d0811709755a1a64 to 0x174ddab197328389a6fc2c1868e66e570d813afb
const transfer = await fetch({
        params: {
          tokenId: '1',
          contractAddress: '0x174ddab197328389a6fc2c1868e66e570d813afb',
          receiver: '0x174ddab197328389a6fc2c1868e66e570d813afb',
          type: 'erc1155',
          amount: '1',
        },
      });
...
web3Js.eth.getTransactionReceipt('0x29ac1c9622f996a96d88a77d9a35d71203cf05d450048884041e32d53b812abb', function (error, reciept) {
     console.log('Sent by ' + reciept.from + ' to contract ' + reciept.to);
 });

From the web3js docs:

contractAddress - String: The contract address created, if the transaction was a contract creation, otherwise null.

I think it’s all fine.

1 Like

Thank you very much.