Skip to content

Account deployment failed using paymaster sponsered transaction #1481

@sunny334

Description

@sunny334

Describe the bug
Trying to deploy an account with paymaster sponsered transaction it worked with (Argent) wallet extension but we need to implement within backend server code to deploy the starknet wallet without connecting wallet extension. We have contacted with AVNU team but they have refered the case to you please look into it.

To Reproduce

import { RpcProvider, Account, PaymasterRpc } from 'starknet';

async function performPaymasterTransactionWithExistingArgentAccount() {
  const EXISTING_ARGENT_ACCOUNT_ADDRESS = "existing wallet account address";
  const EXISTING_ARGENT_PRIVATE_KEY = "private key";

  const myProvider = new RpcProvider({
    nodeUrl: "https://starknet-mainnet.public.blastapi.io/rpc/v0_8"
  });
  const paymasterRpc = new PaymasterRpc({
    nodeUrl: 'https://starknet.paymaster.avnu.fi/',
    headers: { 'x-paymaster-api-key': 'api key' },
  });
  const MyWalletAccount = new Account(
    myProvider, 
    EXISTING_ARGENT_ACCOUNT_ADDRESS, 
    EXISTING_ARGENT_PRIVATE_KEY, 
    paymasterRpc
  );
  const deployAccountPayload = {
    address: "0x034981dA10e5F3b63E875D4284a7764470747477F130C1f594B66D0143be7E42",
    class_hash: "0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f",
    salt: "0x07b24741db922a1c266330a2edcd6bc7a00a1f415ea6b6841f5ee4e230bd8e89",
    calldata: [
      "0x0",
      "0x07b24741db922a1c266330a2edcd6bc7a00a1f415ea6b6841f5ee4e230bd8e89",
      "0x1"
    ],
    version: 1
  };
  const feesDetails = {
    deploymentData: { ...deployAccountPayload, version: 1 },
    feeMode: { mode: 'sponsored' },
  };
  console.log('Executing Paymaster transaction...');
  const resp = await MyWalletAccount.executePaymasterTransaction(
    [],
    feesDetails,
  );
  console.log('Transaction hash =', resp.transaction_hash);
  console.log('Waiting for transaction confirmation...');
  const txR = await myProvider.waitForTransaction(resp.transaction_hash);
  console.log('Transaction status:', txR.transaction_status);
}
performPaymasterTransactionWithExistingArgentAccount().catch(console.error);

Expected behavior
it should deploy the account with paymaster sponsered mode

Screenshots

163: An error occurred (UNKNOWN_ERROR): "x-paymaster-api-key is invalid"
    at _PaymasterRpc.errorHandler (file:///home/haris/workspace/loop_starknet_nft_js/node_modules/starknet/dist/index.mjs:9287:13)
    at _PaymasterRpc.fetchEndpoint (file:///home/haris/workspace/loop_starknet_nft_js/node_modules/starknet/dist/index.mjs:9301:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async _PaymasterRpc.buildTransaction (file:///home/haris/workspace/loop_starknet_nft_js/node_modules/starknet/dist/index.mjs:9343:22)
    at async Account.executePaymasterTransaction (file:///home/haris/workspace/loop_starknet_nft_js/node_modules/starknet/dist/index.mjs:9761:33)
    at async performPaymasterTransactionWithExistingArgentAccount (file:///home/haris/workspace/loop_starknet_nft_js/deploywallet.js:43:16) {
  request: {
    method: 'paymaster_buildTransaction',
    params: { transaction: [Object], parameters: [Object] }
  },
  baseError: {
    code: 163,
    message: 'An error occurred (UNKNOWN_ERROR)',
    data: 'x-paymaster-api-key is invalid'
  }

Desktop

  • firefox [142.0]
  • Node version [22.14.0]
  • starknet [^7.6.4]
  • Network [mainnet]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions