Move.

Publication

Partagez vos connaissances.

farshad.
Feb 13, 2025
Questions et Réponses avec des Experts

Why does sponsored transaction fail with JsonRpcError?

I've been working on creating a sponsored transaction. I first create and sign the transaction with the gas sponsor and then the sender. But when I send it to the blockchain, I get a JsonRpcError: Deserialization error. Oddly enough, if I sign it without a sponsor, it works fine. Can anyone help me figure out what's going wrong with the sponsored transaction setup?

  • Move CLI
  • Move
2
2
Partager
Commentaires
.

Réponses

2
Xavier.eth.
Feb 13 2025, 11:09

Il semble qu'il y ait un problème avec la commande ou le processus de signature de la transaction. Assurez-vous de créer correctement la transaction, puis de signer la transaction sérialisée. Voici un exemple de code qui pourrait vous aider :

async function signSerializedTransaction({
  signer,
  serializedTransaction,
}: {
  signer: Keypair;
  serializedTransaction: string;
}) {
  const txBytes = fromB64(serializedTransaction);
  const signatureWithBytes = await signer.signTransaction(txBytes);

  return signatureWithBytes.signature;
}

async function run() {
  const client = new SuiClient({ url: FULLNODE_URL });
  const tx = ...;

  ...

  tx.setSender(USER_KEYPAIR.toSuiAddress());

  tx.setGasOwner(SPONS_KEYPAIR.toSuiAddress());

  const txBytes = await tx.build({ client });
  const txSerialized = toB64(txBytes);

  const userSignature = await signSerializedTransaction({
    signer: USER_KEYPAIR,
    serializedTransaction: txSerialized,
  });


  const sponsorSignature = await signSerializedTransaction({
    signer: SPONS_KEYPAIR,
    serializedTransaction: txSerialized,
  });

 
  const resp = await client.executeTransactionBlock({
    transactionBlock: txBytes,
    signature: [userSignature, sponsorSignature],
    options: {
      showObjectChanges: true,
      showEffects: true,
      showBalanceChanges: true,
    },
  });
  console.log(resp);
}
2
Meilleure réponse
Commentaires
.
jogador_1.
Feb 13 2025, 11:08

Assurez-vous que les signatures sont correctement gérées et dans le bon ordre lors de l'envoi de la transaction. Le message d'erreur indique qu'il peut y avoir un problème de formatage des données ou une interruption de communication dans la façon dont la transaction est sérialisée et signée.

1
Commentaires
.

Connaissez-vous la réponse ?

Veuillez vous connecter et la partager.

Move is an executable bytecode language used to implement custom transactions and smart contracts.

148Publications231Réponses
Sui.X.Peera.

Gagne ta part de 1000 Sui

Gagne des points de réputation et obtiens des récompenses pour avoir aidé la communauté Sui à se développer.

Campagne de RécompensesJuillet