Skip to content

Commit

Permalink
add decode raw tx
Browse files Browse the repository at this point in the history
  • Loading branch information
zkbenny committed Jul 22, 2024
1 parent cd87b1c commit d93951d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/zklinkNova/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require('@nomicfoundation/hardhat-toolbox');
require('./scripts/getTxStatus');
require('./scripts/decodeRawTx');

const BaseConfig = require('../../hardhat.base.config');

Expand Down
13 changes: 13 additions & 0 deletions examples/zklinkNova/scripts/decodeRawTx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const zksync = require('zksync-ethers');
const { recoverAddress } = require('ethers');
const { task, types } = require('hardhat/config');

task('decodeRawTx', 'Decode the raw tx of nova')
.addParam('rawTx', 'The raw tx', undefined, types.string)
.setAction(async taskArgs => {
const rawTx = taskArgs.rawTx;
const tx = zksync.types.Transaction.from(rawTx);
console.log(JSON.stringify(tx.toJSON()));
const from = recoverAddress(tx.unsignedHash, tx.signature);
console.log(from);
});

0 comments on commit d93951d

Please sign in to comment.