Moralis.transfer() works for transfering NFT in ETH and MATIC?

Dear support,

I have implemented the Moralis.transfer() but when I try to send NFT from the MATIC mainnet which I own from my wallet, it shows an error, which makes me suspect I can only send NFT from ETH mainnet, but not MATIC.

Please clarify if this function Moralis.transfer(), works only for NFTs in ETH.

This is the error:

  1. [‘contract_address is required’, ‘token_id is required’]

  2. 0: “contract_address is required”

  3. 1: “token_id is required”

I have specified the contract address and the token Id correctly.
Thank you.

edit:

this is the MATIC contract address:
0x72b6dc1003e154ac71c76d3795a3829cfd5e33b9
This is the token Id:
6351

I would expect it to work, you have to be connected to Matic network in metamask, and the rest should work the same as on eth

Thanks for the reply.
This is the code of the function:

transferNFTs = async () => {
    
    let _type = String(document.querySelector('#nft-transfer-type').value);
    let _receiver = String(document.querySelector('#nft-transfer-receiver').value);
    let _contractAddress = String(document.querySelector('#nft-transfer-contract-address').value);
    let _tokenId = document.querySelector('#nft-transfer-token-id').value;
    
    console.log("type = ",_type)
    console.log("Receiver = ",_receiver)
    console.log("Contract Address = ",_contractAddress)
    console.log("Token Id = ",_tokenId)
    
    const options = {type: _type,  
                    receiver: _receiver,
                    contractAddress: _contractAddress,
                    tokenId: _tokenId}
                    
    let result = await Moralis.transfer(options)
   
}

This is the error that I get:

I have the Matic mainnet currently on Metamask;

What could be the issue?

Hey @dawveed

Could you try to hardcode those params directly to the options?

Hello @Yomoo
I hard-coded the parameters:

const options = {type: "erc721",  
                    receiver: "0xaf15EfBCaBd4FbcB934890Bc4a6D3ec9B5908fB8",
                    contractAddress: "0x72b6dc1003e154ac71c76d3795a3829cfd5e33b9",
                    tokenId: 6351}
                    
    let result = await Moralis.transfer(options)

and I got the same issue:

btw what’s the version of the SDK you’re using now? the error seems to be prompting for snake case params, but now we already use camel case for our params

hello @YosephKS
Thanks for you input.
I have two html files:
index.html
dashboard.html

The index.html has this code:

<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://unpkg.com/moralis/dist/moralis.js"></script>

The dashboard.html had this:

<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://npmcdn.com/[email protected]/dist/moralis.js">

Then I changed the code of dashboard.html to coincide with index.html and I got a different error:

this is a very old version of Moralis SDK

Yes as @cryptokid said, the version in your dashboard.html is extremely old ones, if you want the latest one change it to the one in SDK index.html with @latest tag. However keep in mind in our latest version, we have big breaking changes which requires you to do some migrations. If you wanna use the SDK without doing the migration use the @0.0.184 version of the SDK :raised_hands:

Thank you.
I did the proper migrations and the code worked fine.
Cheers

1 Like

I have added the Abi, the contract address, done everything but when I compile I get this error message


How can I fix it

Please screenshot :raised_hands: it hurts the eyes

@YosephKS please help

screenshot please :raised_hands: don’t take photo on your screen

Pls hw can I screenshot pls