Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to serialize a transaction from mempool and sign it into a bundle #83

Open
jactttttt opened this issue Dec 15, 2022 · 1 comment
Open

Comments

@jactttttt
Copy link

i just test signBundle via flashbots, i feel confused. there is the code

// the transaction is get from geth mempool
const transaction = {
                    "blockHash": null,
                    "blockNumber": null,
                    "from": "0x0160ea15d2125dd9c211f23169c4e4f4fb7957a8",
                    "gas": "0x4c4b40",
                    "gasPrice": "0x1ca10",
                    "hash": "0x696968e15c7174609adca25769c4e7c0e2c18d1eedbca8e4b71e3a0f59c52797",
                    "input": "0xc652885f0000000000000000000000009bd2aa38429c356be17c8c7bb07dab299200eeb84178ca8820c1a8dae966f1fdd132a2a874394233000000000000000000000054000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000010000000000000000000000004178ca8820c1a8dae966f1fdd132a2a8743942330000000000000000000000000000000000000000000000000000000000000320",
                    "nonce": "0x163",
                    "to": "0x7ede79ed0d3acf3d4843c919975fb7bd97ecccba",
                    "transactionIndex": null,
                    "value": "0x0",
                    "type": "0x0",
                    "chainId": "0x5",
                    "v": "0x2e",
                    "r": "0xf4556687cb3df0f345ab903a2c9c46bb1a9fb413a0f498e8dba3b74253caa313",
                    "s": "0x281adb2e3f2b73c685aaaec10120b9ade46d6c2cd069d1106ae5093833d0bbf1"
};

const signedBundle = await flashbotsProvider.signBundle([
        {
          signer: transactionFromSigner.connect(provider),
          transaction: {
            ...baseTransaction,
            gasPrice: '',
            data: '0x'
          },
        },
        {
            // there, i don't know how to serialize transaction from mempool
            signedTransaction: ethers.utils.serializeTransaction(transaction)
        }
    ]);
@jactttttt jactttttt changed the title How should I serialize a transaction from mempool and pack it into a bundle How to serialize a transaction from mempool and sign it into a bundle Dec 16, 2022
@cervaens
Copy link

I use something like this in TypeScript:
const transactionTxSign: SignatureLike = { r: transaction.r || 'any', s: transaction.s, v: transaction.v };
signedTransaction: ethers.utils.serializeTransaction(transaction, transactionTxSign);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants