xclud / web3dart

Ethereum library, written in Dart.
https://pub.dev/packages/web3dart
MIT License
170 stars 94 forks source link

Add EIP4844 support #149

Open gtmickey opened 2 weeks ago

gtmickey commented 2 weeks ago

refer from java version

impl by dart and tested transaction detail

usage:

 final eip4844 = Transaction(
      to: address,
      maxFeePerGas: EtherAmount.fromBigInt(EtherUnit.wei,maxFeePerGas),
      maxPriorityFeePerGas:
          EtherAmount.fromBigInt(EtherUnit.wei, maxPriorityFeePerGasInt),
      maxGas: (gasLimit * BigInt.from(12) / BigInt.from(10)).toInt(),
      maxFeePerBlobGas: EtherAmount.fromBigInt(EtherUnit.wei, blobFeeCap),
      blobVersionedHashes: sidecar!.blobHashes(),
      nonce: nonce,
      value: EtherAmount.fromInt(EtherUnit.wei, 111),
      /// kzg from  https://github.com/weishirongzhen/dart_kzg_4844_util
      sidecar: Sidecar(
        blobs: sidecar!.blobs.map((e) => e.blob).toList(growable: false),
        commitment: sidecar!.commitments
            .map((e) => e.commitment)
            .toList(growable: false),
        proof: sidecar!.proofs.map((e) => e.proof).toList(growable: false),
      ),
    );
    final signedTx = await client.signTransaction(credentials, eip4844,
        chainId: chainId.toInt());
    result = await client.sendTransaction(
      credentials,
      eip4844,
      chainId: chainId.toInt(),
    );
xclud commented 2 weeks ago

Thanks for the great job. Please do not modify the version in pubspec.yml. I will merge immediately.