Where is safeFromTransfer function in contract instance?

I create a contract instance in hardhat console like so:

const contract_fac = await ethers.getContractFactory("ContractName");
const contract = await contract_fac.attach("CONTRACTADDR...");

But contract object has all public/external functions except safeTransferFrom. Why?
When i call it with contract.safeTransferFrom(…) comes “safeTransferFrom is not a function” JS error.
Is this a bug or do I not understand something? safeTransferFrom function is listed in the abi.

I use OpenZeppelin (version 4.2) 721 token template without changes, Ethers 5.4.1 and hardhat 2.4.1.

Problem solved. safeTransferFrom is a overloaded function. In ethers, the syntax to call an overloaded contract function is different from the non-overloaded function.

https://docs.ethers.io/v5/single-page/#/v5/migration/web3/-%23-migration-from-web3-js–contracts–overloaded-functions

Wrong:
contract.safeTransferFrom(addr1, addr2, 1);

Correct:
contract["safeTransferFrom(address,address,uint256)"](addr1, addr2, 1);

1 Like