0

When I try to send signed transactions, the transactions are successful but from my personal Account and not Biconomy!!

I'm using Web3 + Personal Sign custom implementation on a basic ERC20 token contract from Biconomy's SDK here.

The from address in the transaction is my own and not from Biconomy's list of relayer addresses.

This leads to issues like not being able to send many transactions at the same time and defeats the purpose of relayer.

HERE IS MY CODE for the transfer function :

 transfer = async function (userAddress, mintAmount) {
const contract = new web3.eth.Contract(tokenABI, bnzContractAddr);
// let nonce = 0;
let nonce = await contract.methods.getNonce(ownerAddress).call();

console.log("nonce----- ", nonce);
let functionSignature = contract.methods
  .transfer(userAddress, mintAmount)
  .encodeABI();

let messageToSign = this.constructMetaTransactionMessage(
  nonce,
  chainId,
  functionSignature,
  bnzContractAddr
);

let { signature } = web3.eth.accounts.sign(
  "0x" + messageToSign.toString("hex"),
  privateKey
);
let { r, s, v } = this.getSignatureParameters(signature);
let executeMetaTransactionData = await contract.methods
  .executeMetaTransaction(ownerAddress, functionSignature, r, s, v)
  .encodeABI();

let txParams = {
  from: ownerAddress,
  to: bnzContractAddr,
  value: "0x0",
  gas: 100000,
  data: executeMetaTransactionData,
};

const signedTx = await web3.eth.accounts.signTransaction(
  txParams,
  `0x${privateKey}`
);

let receipt = await web3.eth.sendSignedTransaction(
  signedTx.rawTransaction,
  (error, txHash) => {
    if (error) {
      return console.error(error);
    }
    console.log("Transaction hash is ", txHash);
    // do something with transaction hash
  }
);

console.log("Tokens Transferred------");


 };

I have done the prerequisites like:

  1. Registering Contract of Biconomy's Dashboard
  2. Adding Custom API

What can be the error or What am I missing?

Please let me know if you need more details.

0

Your Answer

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