# safeTransferFrom is not a function

**URL:** https://forum.openzeppelin.com/t/safetransferfrom-is-not-a-function/27137
**Category:** Smart Contracts
**Created:** [April 2, 2022, 5:00pm UTC](https://forum.openzeppelin.com/t/safetransferfrom-is-not-a-function/27137 "2022-04-02T17:00:49Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Cainuriel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/cainuriel/32/5410_2.png) [@Cainuriel](https://forum.openzeppelin.com/u/Cainuriel)
#### Post date: [April 2, 2022, 5:00pm UTC](https://forum.openzeppelin.com/t/safetransferfrom-is-not-a-function/27137/1 "2022-04-02T17:00:49Z")

</div>

I am doing transfers from a dApp built with hardhat, ethers and React. it works perfectly using:

```auto
    async function transfer() {

      const [accountUser] = await window.ethereum.request({ method: 'eth_requestAccounts' });
      const provider = new ethers.providers.Web3Provider(window.ethereum);
      const signer = provider.getSigner();
      const contract = new ethers.Contract(nftContract, NFT.abi, signer);
      let transaction; 
      try {
        transaction = await contract.transferFrom(accountUser, newOwner, idNFT);
...

```

But if I use the function safeTransferFrom I get the error ``` safeTransferFrom is not a function``.  
Why is that? Evidently the contract has in its ABI this standard function.

```auto

    async function transfer() {

      const [accountUser] = await window.ethereum.request({ method: 'eth_requestAccounts' });
      const provider = new ethers.providers.Web3Provider(window.ethereum);
      const signer = provider.getSigner();
      const contract = new ethers.Contract(nftContract, NFT.abi, signer);
      let transaction; 
      try {
        transaction = await contract.safeTransferFrom(accountUser, newOwner, idNFT);

```

 ![para_mandar](https://us1.discourse-cdn.com/flex022/uploads/zeppelin/original/2X/d/d9f25a55361f234aed5d67276f6a0621333b3310.png)

---

<div class="post-metadata">

### Author: ![Team\_X](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/team_x/32/10471_2.png) [@Team\_X](https://forum.openzeppelin.com/u/Team_X)
#### Post date: [April 2, 2022, 5:23pm UTC](https://forum.openzeppelin.com/t/safetransferfrom-is-not-a-function/27137/2 "2022-04-02T17:23:37Z")

</div>

Well look at your code. Is safeTransferFrom a public function or even there? Is it public and NOT from any imports/interfaces?

---

<div class="post-metadata">

### Author: ![Cainuriel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/cainuriel/32/5410_2.png) [@Cainuriel](https://forum.openzeppelin.com/u/Cainuriel)
#### Post date: [April 2, 2022, 5:40pm UTC](https://forum.openzeppelin.com/t/safetransferfrom-is-not-a-function/27137/3 "2022-04-02T17:40:33Z")

</div>

> [@Team\_X](#):
>
> Well look at your code. Is safeTransferFrom a public function or even there?  
> Yes.  
> Is it public and NOT from any imports/interfaces?  
> is inherited from contract ERC721A. But it is public and accessible from the abi of the main contract.

ABI of contract:

```auto
{
      "inputs": [
        {
          "internalType": "address",
          "name": "from",
          "type": "address"
        },
        {
          "internalType": "address",
          "name": "to",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "tokenId",
          "type": "uint256"
        }
      ],
      "name": "safeTransferFrom",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    }

```

---

<div class="post-metadata">

### Author: ![Cainuriel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/cainuriel/32/5410_2.png) [@Cainuriel](https://forum.openzeppelin.com/u/Cainuriel)
#### Post date: [April 2, 2022, 5:55pm UTC](https://forum.openzeppelin.com/t/safetransferfrom-is-not-a-function/27137/4 "2022-04-02T17:55:45Z")

</div>

@Team_X  
Both transferFrom and safeTransferFrom functions are inherited from the same contract. It makes no sense for one to fail and the other to work.

---

<div class="post-metadata">

### Author: ![swkim109](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/swkim109/32/5097_2.png) [@swkim109](https://forum.openzeppelin.com/u/swkim109)
#### Post date: [April 2, 2022, 10:42pm UTC](https://forum.openzeppelin.com/t/safetransferfrom-is-not-a-function/27137/5 "2022-04-02T22:42:23Z")

</div>

Try this:

```auto
await contract['safeTransferFrom(address,address,uint256)'](accountUser, newOwner, idNFT)

```

And FYI, [https://github.com/ethers-io/ethers.js/issues/1160](https://github.com/ethers-io/ethers.js/issues/1160)

---

<div class="post-metadata">

### Author: ![Cainuriel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/cainuriel/32/5410_2.png) [@Cainuriel](https://forum.openzeppelin.com/u/Cainuriel)
#### Post date: [April 3, 2022, 12:54pm UTC](https://forum.openzeppelin.com/t/safetransferfrom-is-not-a-function/27137/6 "2022-04-03T12:54:21Z")

</div>

> [@swkim109](#):
>
> Try this:

Wow, It seems that we put the interface of the function in square brackets. Is this what we do @swkim109 ? It works perfectly thank you very much. I will keep this in mind in future functions with duplicate name.
