Open ishfx opened 7 months ago
Hi, thank you; I appreciate your feedback. Adding Flashbot relays has definitely been on my radar for a while. I have a question regarding some stats: Do you mostly submit multiple transactions in a bundle, or just a single transaction?
Thanks for the reply. I'd say multiple transactions in a bundle.
Hi @ishfx,
I've been working to integrate Flashbots support. Here are the key updates:
The default configuration now includes relay URLs for Ethereum chains.
TypeScript classes for the contracts have a new wrapper, $signed
, for generating signed transactions. For example:
import { FooContract } from '@0xc/eth/FooContract';
import { ChainAccountService } from '@dequanto/ChainAccountService';
const sender = await ChainAccountService.get('myaccount');
const foo = new FooContract();
const { error, signed } = await foo.$signed().myTxMethod(sender, param1, param2);
// "signed" is the raw transaction hex for myTxMethod
This feature facilitates the collection of signed transactions for later submission to the Flashbots service.
Flashbots RPC methods have been implemented in Rpc.ts, derived from flashbots.json.
FlashbotsProvider.ts has been added to submit signed transactions to the Flashbots relays.
You can review some integration tests in flashbots.spec.ts.
Nonce management: per default, when a transaction is being submitted, we calculate automatically the nonce, based on transaction count. In case, where multiple transactions must be first signed, and then submitted to the relay, you must pass the nonce manager to tx signer:
import { TxNonceManager } from '@dequanto/txs/TxNonceManager';
let nonce = TxNonceManager.create(foo.client, sender);
let { signed: tx1 } = await foo.$signed({ nonce }).myTxMethod(sender, param1, param2);
let { signed: tx2 } = await foo.$signed({ nonce }).otherTxMethod(sender);
// ..
In this example the first tx1
gets the current nonce from the blockchain, tx2..txN
will get incremented nonce accordingly.
I would appreciate your feedback on this implementation and its potential improvements.
Hello @tenbits
In terms of implementation, LGTM. I didn't go into detail, but the fundamentals are there.
I tried running the lib locally but quickly realized that it depends heavily on your own framework. I guess I can't test it using standard ts-node
?
ts-node shouldn't be the problem. Maybe some ts configuration issue. It uses additional npm dependencies, maybe they should be additionally installed, if you install dequanto as git submodule. Could you elaborate more regarding your setup, and what is the error?
It's a basic setup:
git submodule add https://github.com/0xweb-org/dequanto
npm install
in dequanto
npx 0xweb init
npx 0xweb install 0x5f4ec3df9cbd43714fe2740f5e3616155c5b8419 --name chainlink/oracle-eth --chain eth
npm run dev1
=> uses ts-node, errornpm run dev2
=> uses atma, okHere is the repo: https://github.com/ishfx/dequanto-test/tree/main
Thank you very much for the example. It seems that by default, ts-node
prioritizes .json
files over .ts
.
https://github.com/microsoft/TypeScript/issues/47870
https://github.com/ishfx/dequanto-test/tree/main/0xc/eth/chainlink/oracle-eth In this case, there are two files - one ABI json and another a TypeScript class.
However, there is a ts-node
flag --preferTsExts that can be used to override this behavior.
I have also noticed that ts-node
throws some typecheck errors. I use TypeScript in a sloppy mode but plan to address all the typecheck errors soon. For now, you should include the "--transpileOnly" flag with the ts-node
command to avoid these issues.
Alright, thank you for the debug.
I'll wait for the typescript support because I'm not comfortable with disabling the ts checks. What could be better, also, is to publish it as a lib on npm.
Hi,
First of all, kudos for this great web3 lib :tada:
It would be a great addition if this libs could handle flashbots bundle submission.
A good start is the well know flashbots for ethereum network: https://docs.flashbots.net/flashbots-auction/advanced/rpc-endpoint Others can be added for BSC, Polygon, etc after too.
Is this something you consider adding ?
Thanks in advance!