0

I'm using the JS SDK and trying to create a transaction that transfers out a POAP of a Safe... the tx goes through and I can see it in the UI, but not sure why it doesn't transfer the asset out here's the safe's history with the txs that I've submitted to try and transfer the POAP out https://gnosis-safe.io/app/gno:0x166fe3B49E82c0514689Ff0527Cd7C76261A9D07/transactions/history

here's the code:

const transferPOAP = async (safeAddress: string, toAddress: string) => {
  // NOTE :: Get POAPs in wallet
  const poaps = await getWalletPOAPs(safeAddress);
  // NOTE :: Get array of POAP Token IDs
  const tokenIds = poaps.map((el) => el.tokenId);

  // NOTE :: Create Gnosis Safe Factory
  const safeSDK: Safe = await Safe.create({
    ethAdapter: new EthersAdapter({
      ethers,
      signer: owner_wallet, // NOTE :: Owner of safe
    }),
    safeAddress,
  });

  // NOTE :: ABI encoded transaction data
  const data = web3.eth.abi.encodeFunctionCall(
    {
      name: "safeTransferFrom",
      type: "function",
      inputs: [
        { type: "address", name: "from" },
        { type: "address", name: "to" },
        { type: "uint256", name: "tokenId" },
      ],
    },
    [safeAddress, toAddress, tokenIds[0]]
  );

  // NOTE :: Create transaction
  const safeTransaction = await safeSDK.createTransaction({
    safeTransactionData : {
      to: toAddress,
      value: "0",
      data,
    },
  });

  // NOTE :: Get transaction hash
  const txHash = await safeSDK.getTransactionHash(safeTransaction);

  // NOTE :: Sign + Execute transaction
  const executeTxResponse = await safeSDK.executeTransaction(
    safeTransaction
  );

  // NOTE :: Get final confirmation of successful transaction
  const res = await executeTxResponse.transactionResponse?.wait();
  console.log(res?.transactionHash);
}
1
  • Is this because I am trying to interact with a contract that I am not the owner of, or have permission to interact with?
    – Austin
    Commented Oct 29, 2022 at 0:58

1 Answer 1

0

Looking at the latest transaction entry on your Safe, it appears you're attempting to make a contract call on the address 0x9bE27356765EA765F1503c9c63e227fAD8c0B8A9, which is an EOA.

To make calls on smart contracts, you must, of course, execute them on a contract (that supports the method). Looking at the tokens assigned to the Safe address, it seems the POAP token contract in question is 0x22C1f6050E56d2876009903609a2cC3fEf83B415.

Therefore, submit your transaction again, but make sure the "to" field (that is, the contract you want to interact with) is this contract.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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