1

I'm trying to send eth from one wallet to another using wagmi + ether js, everything works in the browser through the metamask, but the transaction confirmation does not appear through wallet connect, and in the trust wallet application it says "method is not supported" has anyone come across this problem and how to solve it? I've been trying to solve this for 4 days now.

trust wallet error

log error

const SendTransaction = () => {

  const { config } = usePrepareSendTransaction({
    request: { to: "moxey.eth", value: utils.parseEther("0.0001") },
  });
  const { data, isLoading, isSuccess, sendTransaction, error } =
    useSendTransaction(config);

  console.log("err", error);

  return (
    <div>
      <button disabled={!sendTransaction} onClick={() => sendTransaction?.()}>
        Send Transaction
      </button>
      {isLoading && <div>Check Wallet</div>}
      {isSuccess && <div>Transaction: {JSON.stringify(data)}</div>}
    </div>
  );
};
1

2 Answers 2

0
import {formatUnits} from 'viems';

const SendTransaction = () => {
// try to replace config with request
  const { request} = usePrepareSendTransaction({
    to: "moxey.eth", 
    value: formatUnits("0.0001",18), //use formatUnits from viems, ethers is not supported anymore
  });
  const { data, isLoading, isSuccess, sendTransaction, error } =
    useSendTransaction(request);

  console.log("err", error);

  return (
    <div>
      <button disabled={!sendTransaction} onClick={() => sendTransaction()}>
        Send Transaction
      </button>
      {isLoading && <div>Check Wallet</div>}
      {isSuccess && <div>Transaction: {JSON.stringify(data)}</div>}
    </div>
  );
};

try this one...

0

add data:"0x" to your request.

const { config } = usePrepareSendTransaction(
  {
    request: { 
    to: "moxey.eth", 
    value: utils.parseEther("0.0001") 
  },
  data:"0x"
});

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.