flashbots / ethers-provider-flashbots-bundle

Flashbots provider for ethers.js
549 stars 215 forks source link

error in signature check wallet #110

Closed pixelpawnshop closed 11 months ago

pixelpawnshop commented 11 months ago

Hello flashbots community! I try to send a transaction to flashbots relay, but when executing Im get a signature error which looks like this

Request failed with status code 403 Response data: { error: 'error in signature check 0xEcDC4f8318e2E5d92369530871626d54A4eD9c9E' }

So I guess it has something to do with how Ive set up the signature in X-Flashbots-Signature. But I dont know whats wrong there as Ive set it up as mentioned in the docs.

My script looks like this

async function sendAsyncTransaction() {
    try {
        const pending = await provider.getTransactionCount(signer.address, "pending");

        const exampleTx = {
            to: "0x0C7172c8c5C000F39E2A11b04c52805aF29d945b",
            value: 1,
            gasLimit: "21000",
            maxFeePerGas: 60000000000,
            maxPriorityFeePerGas: 5000000000,
            nonce: pending,
            type: 2,
            chainId: 1,
        };

        // sign tx
        const txs = await signer.signTransaction(exampleTx);

        // get current block
        const blockNumber = '0x' + (await provider.getBlockNumber() + 1).toString(16);

        const data = {
            jsonrpc: '2.0',
            id: '1',
            method: "eth_sendPrivateTransaction",
            params: [
                {
                    tx: txs,
                    maxBlockNumber: blockNumber,
                    preferences: {
                        privacy: {
                            hints: ["calldata", "transaction_hash"],
                            builders: ["default"]
                        }
                    }
                }
            ]
        };

        const signature = signer.address + ":" + await signer.signMessage(utils.id(data));

        const config = {
            headers: {
                'Content-Type': 'application/json',
                'X-Flashbots-Signature': `${signature}` // Add your Flashbots signature here
            },
        };

        const response = await axios.post('https://relay.flashbots.net', data, config);

        // Check the response status
        if (response.status === 200) {
            console.log(response.data);
        } else {
            console.error(`Unexpected response status: ${response.status}`);
            console.error(response.data);
        }

    } catch (error: any) {
        console.error("Error sending transaction:", error.message);
        if (error.response) {
            console.error("Response data:", error.response.data);
        }
    }
}

I hope someone here can help me out. Thanks in advance!

pixelpawnshop commented 11 months ago

@Ryanpoint1 I dont think so^^ Why do you want to run the code on your mobile phone instead of a computer?